diff options
author | erik <erik@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2000-02-08 19:58:47 +0000 |
---|---|---|
committer | erik <erik@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2000-02-08 19:58:47 +0000 |
commit | a18125005d67c38a8ad7fb454571bb996664ad96 (patch) | |
tree | c90bda10731ad9333ce3b404f993354c9fc104b8 /cat.c | |
parent | 8ef3b44285a8ce5b83bed9cf32ce5f40b30ba72f (diff) | |
download | busybox-w32-a18125005d67c38a8ad7fb454571bb996664ad96.tar.gz busybox-w32-a18125005d67c38a8ad7fb454571bb996664ad96.tar.bz2 busybox-w32-a18125005d67c38a8ad7fb454571bb996664ad96.zip |
Some formatting updates (ran the code through indent)
-Erik
git-svn-id: svn://busybox.net/trunk/busybox@357 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'cat.c')
-rw-r--r-- | cat.c | 54 |
1 files changed, 28 insertions, 26 deletions
@@ -1,3 +1,4 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
1 | /* | 2 | /* |
2 | * Mini Cat implementation for busybox | 3 | * Mini Cat implementation for busybox |
3 | * | 4 | * |
@@ -24,36 +25,37 @@ | |||
24 | #include <stdio.h> | 25 | #include <stdio.h> |
25 | 26 | ||
26 | 27 | ||
27 | static void print_file( FILE *file) | 28 | static void print_file(FILE * file) |
28 | { | 29 | { |
29 | int c; | 30 | int c; |
30 | while ((c = getc(file)) != EOF) | 31 | |
31 | putc(c, stdout); | 32 | while ((c = getc(file)) != EOF) |
32 | fclose(file); | 33 | putc(c, stdout); |
33 | fflush(stdout); | 34 | fclose(file); |
35 | fflush(stdout); | ||
34 | } | 36 | } |
35 | 37 | ||
36 | extern int cat_main(int argc, char **argv) | 38 | extern int cat_main(int argc, char **argv) |
37 | { | 39 | { |
38 | FILE *file; | 40 | FILE *file; |
39 | 41 | ||
40 | if (argc==1) { | 42 | if (argc == 1) { |
41 | print_file( stdin); | 43 | print_file(stdin); |
42 | exit( TRUE); | 44 | exit(TRUE); |
43 | } | 45 | } |
44 | 46 | ||
45 | if ( **(argv+1) == '-' ) { | 47 | if (**(argv + 1) == '-') { |
46 | usage ("cat [file ...]\n"); | 48 | usage("cat [file ...]\n"); |
47 | } | 49 | } |
48 | argc--; | 50 | argc--; |
49 | 51 | ||
50 | while (argc-- > 0 && *(argv++) != '\0' && strlen(*argv) ) { | 52 | while (argc-- > 0 && *(argv++) != '\0' && strlen(*argv)) { |
51 | file = fopen(*argv, "r"); | 53 | file = fopen(*argv, "r"); |
52 | if (file == NULL) { | 54 | if (file == NULL) { |
53 | perror(*argv); | 55 | perror(*argv); |
54 | exit(FALSE); | 56 | exit(FALSE); |
57 | } | ||
58 | print_file(file); | ||
55 | } | 59 | } |
56 | print_file( file); | 60 | exit(TRUE); |
57 | } | ||
58 | exit(TRUE); | ||
59 | } | 61 | } |