aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2000-07-13 06:33:12 +0000
committerMatt Kraai <kraai@debian.org>2000-07-13 06:33:12 +0000
commitac48461da9b04ecf8548f4a0497e3b622a0ae5f1 (patch)
tree4c844e6ffedcb3b78b0c33765acdbea069e1f635
parent37653aaf9c6ca3f21165e247ad385fb81d1b0112 (diff)
downloadbusybox-w32-ac48461da9b04ecf8548f4a0497e3b622a0ae5f1.tar.gz
busybox-w32-ac48461da9b04ecf8548f4a0497e3b622a0ae5f1.tar.bz2
busybox-w32-ac48461da9b04ecf8548f4a0497e3b622a0ae5f1.zip
Correct argument parsing and other minor cleanups.
-rw-r--r--cat.c22
-rw-r--r--coreutils/cat.c22
2 files changed, 22 insertions, 22 deletions
diff --git a/cat.c b/cat.c
index 800443460..6c17ee620 100644
--- a/cat.c
+++ b/cat.c
@@ -24,7 +24,6 @@
24#include "internal.h" 24#include "internal.h"
25#include <stdio.h> 25#include <stdio.h>
26 26
27
28static void print_file(FILE * file) 27static void print_file(FILE * file)
29{ 28{
30 int c; 29 int c;
@@ -35,6 +34,13 @@ static void print_file(FILE * file)
35 fflush(stdout); 34 fflush(stdout);
36} 35}
37 36
37static const char cat_usage[] =
38 "cat [FILE]...\n"
39#ifndef BB_FEATURE_TRIVIAL_HELP
40 "\nConcatenates FILE(s) and prints them to stdout.\n"
41#endif
42 ;
43
38extern int cat_main(int argc, char **argv) 44extern int cat_main(int argc, char **argv)
39{ 45{
40 FILE *file; 46 FILE *file;
@@ -44,17 +50,11 @@ extern int cat_main(int argc, char **argv)
44 exit(TRUE); 50 exit(TRUE);
45 } 51 }
46 52
47 if (**(argv + 1) == '-') { 53 if (**(argv + 1) == '-')
48 usage("cat [FILE ...]\n" 54 usage(cat_usage);
49#ifndef BB_FEATURE_TRIVIAL_HELP
50 "\nConcatenates FILE(s) and prints them to the standard output.\n"
51#endif
52 );
53 }
54 argc--;
55 55
56 while (argc-- > 0 && *(argv++) != '\0' && strlen(*argv)) { 56 while (--argc > 0) {
57 file = fopen(*argv, "r"); 57 file = fopen(*++argv, "r");
58 if (file == NULL) { 58 if (file == NULL) {
59 perror(*argv); 59 perror(*argv);
60 exit(FALSE); 60 exit(FALSE);
diff --git a/coreutils/cat.c b/coreutils/cat.c
index 800443460..6c17ee620 100644
--- a/coreutils/cat.c
+++ b/coreutils/cat.c
@@ -24,7 +24,6 @@
24#include "internal.h" 24#include "internal.h"
25#include <stdio.h> 25#include <stdio.h>
26 26
27
28static void print_file(FILE * file) 27static void print_file(FILE * file)
29{ 28{
30 int c; 29 int c;
@@ -35,6 +34,13 @@ static void print_file(FILE * file)
35 fflush(stdout); 34 fflush(stdout);
36} 35}
37 36
37static const char cat_usage[] =
38 "cat [FILE]...\n"
39#ifndef BB_FEATURE_TRIVIAL_HELP
40 "\nConcatenates FILE(s) and prints them to stdout.\n"
41#endif
42 ;
43
38extern int cat_main(int argc, char **argv) 44extern int cat_main(int argc, char **argv)
39{ 45{
40 FILE *file; 46 FILE *file;
@@ -44,17 +50,11 @@ extern int cat_main(int argc, char **argv)
44 exit(TRUE); 50 exit(TRUE);
45 } 51 }
46 52
47 if (**(argv + 1) == '-') { 53 if (**(argv + 1) == '-')
48 usage("cat [FILE ...]\n" 54 usage(cat_usage);
49#ifndef BB_FEATURE_TRIVIAL_HELP
50 "\nConcatenates FILE(s) and prints them to the standard output.\n"
51#endif
52 );
53 }
54 argc--;
55 55
56 while (argc-- > 0 && *(argv++) != '\0' && strlen(*argv)) { 56 while (--argc > 0) {
57 file = fopen(*argv, "r"); 57 file = fopen(*++argv, "r");
58 if (file == NULL) { 58 if (file == NULL) {
59 perror(*argv); 59 perror(*argv);
60 exit(FALSE); 60 exit(FALSE);