diff options
author | Eric Andersen | 1999-10-12 22:26:06 +0000 |
---|---|---|
committer | Eric Andersen | 1999-10-12 22:26:06 +0000 |
commit | 3cf52d19581b2077480e7d2e63010baa1f5399c1 (patch) | |
tree | d91b0cb332ebc976126e36a394655dde7a15d8b1 /coreutils/cat.c | |
parent | 2ce1edcf544ac675e6762c9861a6b918401ea716 (diff) | |
download | busybox-3cf52d19581b2077480e7d2e63010baa1f5399c1.zip busybox-3cf52d19581b2077480e7d2e63010baa1f5399c1.tar.gz |
More stuff...
Diffstat (limited to 'coreutils/cat.c')
-rw-r--r-- | coreutils/cat.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/coreutils/cat.c b/coreutils/cat.c index 8718c4d..5c54c49 100644 --- a/coreutils/cat.c +++ b/coreutils/cat.c @@ -22,15 +22,27 @@ #include "internal.h" #include <stdio.h> -const char cat_usage[] = "[file ...]"; -extern int cat_more_main(int argc, char **argv) +static void print_file( FILE *file) { int c; - FILE *file = stdin; + while ((c = getc(file)) != EOF) + putc(c, stdout); + fclose(file); + fflush(stdout); +} + +extern int cat_more_main(int argc, char **argv) +{ + FILE *file; + + if (argc==1) { + print_file( stdin); + exit( TRUE); + } - if ( (argc < 2) || (**(argv+1) == '-') ) { - fprintf(stderr, "Usage: %s %s", *argv, cat_usage); + if ( **(argv+1) == '-' ) { + fprintf(stderr, "Usage: cat [file ...]\n"); exit(FALSE); } argc--; @@ -42,11 +54,7 @@ extern int cat_more_main(int argc, char **argv) perror(*argv); exit(FALSE); } - while ((c = getc(file)) != EOF) - putc(c, stdout); - fclose(file); - fflush(stdout); - + print_file( file); argc--; argv++; } |