From 9f739445cd3deddd0343c3a8d5a981ede26bef30 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Sat, 16 Dec 2006 23:49:13 +0000 Subject: inline strcmp(s, "-") [actually macro-ize it for now - gcc is too stupid] --- coreutils/cut.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'coreutils/cut.c') diff --git a/coreutils/cut.c b/coreutils/cut.c index a538e3d20..a72b2c29a 100644 --- a/coreutils/cut.c +++ b/coreutils/cut.c @@ -168,6 +168,8 @@ int cut_main(int argc, char **argv) opt_complementary = "b--bcf:c--bcf:f--bcf"; getopt32(argc, argv, optstring, &sopt, &sopt, &sopt, <ok); +// argc -= optind; + argv += optind; if (!(option_mask32 & (CUT_OPT_BYTE_FLGS | CUT_OPT_CHAR_FLGS | CUT_OPT_FIELDS_FLGS))) bb_error_msg_and_die("expected a list of bytes, characters, or fields"); if (option_mask32 & BB_GETOPT_ERROR) @@ -262,22 +264,21 @@ int cut_main(int argc, char **argv) qsort(cut_lists, nlists, sizeof(struct cut_list), cmpfunc); } - /* argv[(optind)..(argc-1)] should be names of file to process. If no + /* argv[0..argc-1] should be names of file to process. If no * files were specified or '-' was specified, take input from stdin. * Otherwise, we process all the files specified. */ - if (argv[optind] == NULL - || (argv[optind][0] == '-' && argv[optind][1] == '\0')) { + if (argv[0] == NULL || LONE_DASH(argv[0])) { cut_file(stdin); } else { FILE *file; - for (; optind < argc; optind++) { - file = fopen_or_warn(argv[optind], "r"); + do { + file = fopen_or_warn(argv[0], "r"); if (file) { cut_file(file); fclose(file); } - } + } while (*++argv); } if (ENABLE_FEATURE_CLEAN_UP) free(cut_lists); -- cgit v1.2.3