summaryrefslogtreecommitdiffhomepage
path: root/coreutils
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 /coreutils
parent37653aaf9c6ca3f21165e247ad385fb81d1b0112 (diff)
Correct argument parsing and other minor cleanups.
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/cat.c22
1 files changed, 11 insertions, 11 deletions
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 @@
#include "internal.h"
#include <stdio.h>
-
static void print_file(FILE * file)
{
int c;
@@ -35,6 +34,13 @@ static void print_file(FILE * file)
fflush(stdout);
}
+static const char cat_usage[] =
+ "cat [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nConcatenates FILE(s) and prints them to stdout.\n"
+#endif
+ ;
+
extern int cat_main(int argc, char **argv)
{
FILE *file;
@@ -44,17 +50,11 @@ extern int cat_main(int argc, char **argv)
exit(TRUE);
}
- if (**(argv + 1) == '-') {
- usage("cat [FILE ...]\n"
-#ifndef BB_FEATURE_TRIVIAL_HELP
- "\nConcatenates FILE(s) and prints them to the standard output.\n"
-#endif
- );
- }
- argc--;
+ if (**(argv + 1) == '-')
+ usage(cat_usage);
- while (argc-- > 0 && *(argv++) != '\0' && strlen(*argv)) {
- file = fopen(*argv, "r");
+ while (--argc > 0) {
+ file = fopen(*++argv, "r");
if (file == NULL) {
perror(*argv);
exit(FALSE);