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++; line++;
if(b[0] == b[1]) if(b[0] == b[1])
continue; continue;
for(i = 0; i < 2; i++) for(i = 0; i < 2; i++) {
if(b[i] == EOF) if(b[i] == EOF) {
enprintf(Diff, "cmp: EOF on %s\n", if(!sflag)
fprintf(stderr, "cmp: EOF on %s\n",
!argv[i] ? "<stdin>" : argv[i]); !argv[i] ? "<stdin>" : argv[i]);
if(!lflag) { exit(Diff);
}
}
if(!sflag) if(!sflag)
printf("%s %s differ: char %ld, line %ld\n", printf("%s %s differ: char %ld, line %ld\n",
argv[0], !argv[1] ? "<stdin>" : argv[1], n, line); argv[0], !argv[1] ? "<stdin>" : argv[1], n, line);