cmp: dont output EOF difference is sflag is set

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
This commit is contained in:
Hiltjo Posthuma 2014-04-01 15:14:21 +02:00 committed by sin
parent a7954e8cab
commit ce28f6ca90

11
cmp.c
View File

@ -56,11 +56,14 @@ main(int argc, char *argv[])
line++;
if(b[0] == b[1])
continue;
for(i = 0; i < 2; i++)
if(b[i] == EOF)
enprintf(Diff, "cmp: EOF on %s\n",
for(i = 0; i < 2; i++) {
if(b[i] == EOF) {
if(!sflag)
fprintf(stderr, "cmp: EOF on %s\n",
!argv[i] ? "<stdin>" : argv[i]);
if(!lflag) {
exit(Diff);
}
}
if(!sflag)
printf("%s %s differ: char %ld, line %ld\n",
argv[0], !argv[1] ? "<stdin>" : argv[1], n, line);