cut: clean up file loop
This commit is contained in:
parent
f08d798f77
commit
2433bb78cb
16
cut.c
16
cut.c
|
@ -162,20 +162,18 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user