cut: clean up file loop
This commit is contained in:
parent
f08d798f77
commit
2433bb78cb
18
cut.c
18
cut.c
|
@ -162,21 +162,19 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
if (!mode)
|
if (!mode)
|
||||||
usage();
|
usage();
|
||||||
if (!argc)
|
|
||||||
|
if (!argc) {
|
||||||
cut(stdin);
|
cut(stdin);
|
||||||
else {
|
} else for (; argc--; argv++) {
|
||||||
for (; argc--; argv++) {
|
if (!strcmp(*argv, "-")) {
|
||||||
if (strcmp(*argv, "-"))
|
cut(stdin);
|
||||||
fp = fopen(*argv, "r");
|
} else {
|
||||||
else
|
if (!(fp = fopen(*argv, "r"))) {
|
||||||
fp = stdin;
|
|
||||||
if (!fp) {
|
|
||||||
weprintf("fopen %s:", *argv);
|
weprintf("fopen %s:", *argv);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
cut(fp);
|
cut(fp);
|
||||||
if (fp != stdin)
|
fclose(fp);
|
||||||
fclose(fp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user