sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit 1059cf5f175fa6d6edb313ad3151a55bae9dcf20
parent 24a5006f57193bc6f65e21eff3cd4ab3122114c1
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Tue,  1 Apr 2014 15:06:42 +0200

cmp: make EOF check more clear

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>

Diffstat:
Mcmp.c | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/cmp.c b/cmp.c @@ -47,9 +47,11 @@ main(int argc, char *argv[]) if (!fp[1]) enprintf(Error, "fopen %s:", argv[1]); - for(n = 1; ((b[0] = getc(fp[0])) != EOF) \ - | ((b[1] = getc(fp[1])) != EOF); n++) { - if(b[0] == '\n') + for(n = 1; ; n++) { + b[0] = getc(fp[0]); + b[1] = getc(fp[1]); + if(b[0] == EOF && b[1] == EOF) + break; line++; if(b[0] == b[1]) continue;