summaryrefslogtreecommitdiff
path: root/coreutils/cut.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-12-16 23:49:13 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-12-16 23:49:13 +0000
commit9f739445cd3deddd0343c3a8d5a981ede26bef30 (patch)
tree6dc013e44d2281eb1e6f61c4bca1ae7546001f79 /coreutils/cut.c
parenta597aaddfa76d589d3e1a37b1f1c3401c2decffd (diff)
downloadbusybox-w32-9f739445cd3deddd0343c3a8d5a981ede26bef30.tar.gz
busybox-w32-9f739445cd3deddd0343c3a8d5a981ede26bef30.tar.bz2
busybox-w32-9f739445cd3deddd0343c3a8d5a981ede26bef30.zip
inline strcmp(s, "-") [actually macro-ize it for now - gcc is too stupid]
Diffstat (limited to 'coreutils/cut.c')
-rw-r--r--coreutils/cut.c13
1 files changed, 7 insertions, 6 deletions
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)
168 168
169 opt_complementary = "b--bcf:c--bcf:f--bcf"; 169 opt_complementary = "b--bcf:c--bcf:f--bcf";
170 getopt32(argc, argv, optstring, &sopt, &sopt, &sopt, &ltok); 170 getopt32(argc, argv, optstring, &sopt, &sopt, &sopt, &ltok);
171// argc -= optind;
172 argv += optind;
171 if (!(option_mask32 & (CUT_OPT_BYTE_FLGS | CUT_OPT_CHAR_FLGS | CUT_OPT_FIELDS_FLGS))) 173 if (!(option_mask32 & (CUT_OPT_BYTE_FLGS | CUT_OPT_CHAR_FLGS | CUT_OPT_FIELDS_FLGS)))
172 bb_error_msg_and_die("expected a list of bytes, characters, or fields"); 174 bb_error_msg_and_die("expected a list of bytes, characters, or fields");
173 if (option_mask32 & BB_GETOPT_ERROR) 175 if (option_mask32 & BB_GETOPT_ERROR)
@@ -262,22 +264,21 @@ int cut_main(int argc, char **argv)
262 qsort(cut_lists, nlists, sizeof(struct cut_list), cmpfunc); 264 qsort(cut_lists, nlists, sizeof(struct cut_list), cmpfunc);
263 } 265 }
264 266
265 /* argv[(optind)..(argc-1)] should be names of file to process. If no 267 /* argv[0..argc-1] should be names of file to process. If no
266 * files were specified or '-' was specified, take input from stdin. 268 * files were specified or '-' was specified, take input from stdin.
267 * Otherwise, we process all the files specified. */ 269 * Otherwise, we process all the files specified. */
268 if (argv[optind] == NULL 270 if (argv[0] == NULL || LONE_DASH(argv[0])) {
269 || (argv[optind][0] == '-' && argv[optind][1] == '\0')) {
270 cut_file(stdin); 271 cut_file(stdin);
271 } else { 272 } else {
272 FILE *file; 273 FILE *file;
273 274
274 for (; optind < argc; optind++) { 275 do {
275 file = fopen_or_warn(argv[optind], "r"); 276 file = fopen_or_warn(argv[0], "r");
276 if (file) { 277 if (file) {
277 cut_file(file); 278 cut_file(file);
278 fclose(file); 279 fclose(file);
279 } 280 }
280 } 281 } while (*++argv);
281 } 282 }
282 if (ENABLE_FEATURE_CLEAN_UP) 283 if (ENABLE_FEATURE_CLEAN_UP)
283 free(cut_lists); 284 free(cut_lists);