cut: clean up file loop

This commit is contained in:
Truls Becken 2014-12-17 21:14:14 +01:00 committed by sin
parent f08d798f77
commit 2433bb78cb
1 changed files with 8 additions and 10 deletions

18
cut.c
View File

@ -162,21 +162,19 @@ main(int argc, char *argv[])
if (!mode)
usage();
if (!argc)
if (!argc) {
cut(stdin);
else {
for (; argc--; argv++) {
if (strcmp(*argv, "-"))
fp = fopen(*argv, "r");
else
fp = stdin;
if (!fp) {
} else for (; argc--; argv++) {
if (!strcmp(*argv, "-")) {
cut(stdin);
} else {
if (!(fp = fopen(*argv, "r"))) {
weprintf("fopen %s:", *argv);
continue;
}
cut(fp);
if (fp != stdin)
fclose(fp);
fclose(fp);
}
}
return 0;