Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nccf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
702
Provoz
nccf
Commits
7ccb9800
Commit
7ccb9800
authored
12 years ago
by
Yorhel
Browse files
Options
Downloads
Patches
Plain Diff
Support exporting to stdout while still allowing -u 2 to work
parent
9d341950
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/dir_export.c
+4
-2
4 additions, 2 deletions
src/dir_export.c
src/main.c
+29
-4
29 additions, 4 deletions
src/main.c
with
33 additions
and
6 deletions
src/dir_export.c
+
4
−
2
View file @
7ccb9800
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#include
<stdlib.h>
#include
<stdlib.h>
#include
<stdio.h>
#include
<stdio.h>
#include
<string.h>
static
FILE
*
stream
;
static
FILE
*
stream
;
...
@@ -131,8 +132,9 @@ static int final(int fail) {
...
@@ -131,8 +132,9 @@ static int final(int fail) {
int
dir_export_init
(
const
char
*
fn
)
{
int
dir_export_init
(
const
char
*
fn
)
{
/* TODO: stdout support */
if
(
strcmp
(
fn
,
"-"
)
==
0
)
if
((
stream
=
fopen
(
fn
,
"w"
))
==
NULL
)
stream
=
stdout
;
else
if
((
stream
=
fopen
(
fn
,
"w"
))
==
NULL
)
return
1
;
return
1
;
level
=
0
;
level
=
0
;
...
...
This diff is collapsed.
Click to expand it.
src/main.c
+
29
−
4
View file @
7ccb9800
...
@@ -41,6 +41,7 @@ long update_delay = 100;
...
@@ -41,6 +41,7 @@ long update_delay = 100;
static
int
min_rows
=
17
,
min_cols
=
60
;
static
int
min_rows
=
17
,
min_cols
=
60
;
static
int
ncurses_init
=
0
;
static
int
ncurses_init
=
0
;
static
int
ncurses_tty
=
0
;
/* Explicitely open /dev/tty instead of using stdio */
static
long
lastupdate
=
999
;
static
long
lastupdate
=
999
;
...
@@ -165,17 +166,19 @@ static char *argv_parse(int argc, char **argv) {
...
@@ -165,17 +166,19 @@ static char *argv_parse(int argc, char **argv) {
}
}
if
(
export
)
{
if
(
export
)
{
/* TODO: Support exporting to stdout */
if
(
dir_export_init
(
export
))
{
if
(
dir_export_init
(
export
))
{
printf
(
"Can't open %s: %s
\n
"
,
export
,
strerror
(
errno
));
printf
(
"Can't open %s: %s
\n
"
,
export
,
strerror
(
errno
));
exit
(
1
);
exit
(
1
);
}
}
if
(
strcmp
(
export
,
"-"
)
==
0
)
ncurses_tty
=
1
;
}
else
}
else
dir_mem_init
(
NULL
);
dir_mem_init
(
NULL
);
/* Use the single-line scan feedback by default when exporting. */
/* Use the single-line scan feedback by default when exporting to file, no
* feedback when exporting to stdout. */
if
(
dir_ui
==
-
1
)
if
(
dir_ui
==
-
1
)
dir_ui
=
export
?
1
:
2
;
dir_ui
=
export
&&
strcmp
(
export
,
"-"
)
==
0
?
0
:
export
?
1
:
2
;
return
dir
;
return
dir
;
}
}
...
@@ -183,10 +186,32 @@ static char *argv_parse(int argc, char **argv) {
...
@@ -183,10 +186,32 @@ static char *argv_parse(int argc, char **argv) {
/* Initializes ncurses only when not done yet. */
/* Initializes ncurses only when not done yet. */
static
void
init_nc
()
{
static
void
init_nc
()
{
int
ok
=
0
;
FILE
*
tty
;
SCREEN
*
term
;
if
(
ncurses_init
)
if
(
ncurses_init
)
return
;
return
;
ncurses_init
=
1
;
ncurses_init
=
1
;
initscr
();
if
(
ncurses_tty
)
{
tty
=
fopen
(
"/dev/tty"
,
"r+"
);
if
(
!
tty
)
{
fprintf
(
stderr
,
"Error opening /dev/tty: %s
\n
"
,
strerror
(
errno
));
exit
(
1
);
}
term
=
newterm
(
NULL
,
tty
,
tty
);
if
(
term
)
set_term
(
term
);
ok
=
!!
term
;
}
else
ok
=
!!
initscr
();
if
(
!
ok
)
{
fprintf
(
stderr
,
"Error while initializing ncurses.
\n
"
);
exit
(
1
);
}
cbreak
();
cbreak
();
noecho
();
noecho
();
curs_set
(
0
);
curs_set
(
0
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment