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

14
cmp.c
View File

@@ -16,7 +16,7 @@ main(int argc, char *argv[])
{
FILE *fp[2];
size_t line = 1, n;
int lflag = 0, sflag = 0, same = 1, b[2];
int ret = 0, lflag = 0, sflag = 0, same = 1, b[2];
ARGBEGIN {
case 'l':
@@ -72,9 +72,11 @@ main(int argc, char *argv[])
}
}
enfshut(2, fp[0], argv[0]);
if (fp[0] != fp[1])
enfshut(2, fp[1], argv[1]);
enfshut(2, stdout, "<stdout>");
return !same;
if (!ret)
ret = !same;
if (fshut(fp[0], argv[0]) | (fp[0] != fp[1] && fshut(fp[1], argv[1])) |
fshut(stdout, "<stdout>"))
ret = 2;
return ret;
}