sed: Simplify next_file slightly
This commit is contained in:
parent
5cf4544f2c
commit
71154d42aa
19
sed.c
19
sed.c
|
@ -1119,23 +1119,20 @@ next_file(void)
|
||||||
clearerr(file);
|
clearerr(file);
|
||||||
else if (file)
|
else if (file)
|
||||||
fshut(file, "<file>");
|
fshut(file, "<file>");
|
||||||
file = NULL;
|
/* given no files, default to stdin */
|
||||||
|
file = first && !*files ? stdin : NULL;
|
||||||
|
first = 0;
|
||||||
|
|
||||||
do {
|
while (!file && *files) {
|
||||||
if (!*files) {
|
if (!strcmp(*files, "-")) {
|
||||||
if (first) /* given no files, default to stdin */
|
|
||||||
file = stdin;
|
|
||||||
/* else we've used all our files, leave file = NULL */
|
|
||||||
} else if (!strcmp(*files, "-")) {
|
|
||||||
file = stdin;
|
file = stdin;
|
||||||
files++;
|
} else if (!(file = fopen(*files, "r"))) {
|
||||||
} else if (!(file = fopen(*files++, "r"))) {
|
|
||||||
/* warn this file didn't open, but move on to next */
|
/* warn this file didn't open, but move on to next */
|
||||||
weprintf("fopen:");
|
weprintf("fopen:");
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
} while (!file && *files);
|
files++;
|
||||||
first = 0;
|
}
|
||||||
|
|
||||||
return !file;
|
return !file;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user