cmp: make EOF check more clear
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
This commit is contained in:
parent
24a5006f57
commit
1059cf5f17
8
cmp.c
8
cmp.c
@ -47,9 +47,11 @@ main(int argc, char *argv[])
|
|||||||
if (!fp[1])
|
if (!fp[1])
|
||||||
enprintf(Error, "fopen %s:", argv[1]);
|
enprintf(Error, "fopen %s:", argv[1]);
|
||||||
|
|
||||||
for(n = 1; ((b[0] = getc(fp[0])) != EOF) \
|
for(n = 1; ; n++) {
|
||||||
| ((b[1] = getc(fp[1])) != EOF); n++) {
|
b[0] = getc(fp[0]);
|
||||||
if(b[0] == '\n')
|
b[1] = getc(fp[1]);
|
||||||
|
if(b[0] == EOF && b[1] == EOF)
|
||||||
|
break;
|
||||||
line++;
|
line++;
|
||||||
if(b[0] == b[1])
|
if(b[0] == b[1])
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user