Simplify return & fshut() logic

Get rid of the !!()-constructs and use ret where available (or introduce it).

In some cases, there would be an "abort" on the first fshut-error, but we want
to close all files and report all warnings and then quit, not just the warning
for the first file.
This commit is contained in:
FRIGN
2015-05-25 01:33:19 +02:00
committed by sin
parent e8a4f37884
commit d23cc72490
34 changed files with 142 additions and 72 deletions

7
nl.c
View File

@@ -113,6 +113,7 @@ main(int argc, char *argv[])
{
FILE *fp = NULL;
size_t l, s;
int ret = 0;
char *d, *formattype, *formatblit;
ARGBEGIN {
@@ -199,6 +200,8 @@ main(int argc, char *argv[])
nl(argv[0], fp);
}
return !!((fp && fp != stdin && fshut(fp, argv[0]))
+ fshut(stdin, "<stdin>") + fshut(stdout, "<stdout>"));
ret |= fp && fp != stdin && fshut(fp, argv[0]);
ret |= fshut(stdin, "<stdin>") | fshut(stdout, "<stdout>");
return ret;
}