Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!seismo!columbia!rutgers!sri-spam!mordor!lll-tis!ptsfa!ihnp4!occrsh!uokmax!rmtodd
From: rmtodd@uokmax.UUCP (Richard Michael Todd)
Newsgroups: comp.os.minix
Subject: bug in diff.c
Message-ID: <632@uokmax.UUCP>
Date: Wed, 22-Jul-87 01:39:26 EDT
Article-I.D.: uokmax.632
Posted: Wed Jul 22 01:39:26 1987
Date-Received: Fri, 24-Jul-87 04:08:37 EDT
Reply-To: rmtodd@uokmax.UUCP (Richard Michael Todd)
Organization: University of Oklahoma, Norman
Lines: 15


Surprising that nobody's noticed this before--the diff.c that recently
appeared on the net (in the MINIX 1.2 files) won't work when compiled with
MINIX cc--the resulting program gives bogus output.  The problem is in the
line in read_line():
	if (p[1] != '\377' && *p != '\n') {
Can you say "non-portable character comparison"? Sure. I knew you could.
Lint can say it too.  Under the MINIX C compiler, p[1] gets sign-extended
and '\377' doesn't when converted to int, so the comparison fails even when
p[1] has 255 (0377) in it.  The quick fix is to change it to read
	if ((p[1]&255) != '\377' && *p != '\n') {
--------------------------------------------------------------------------
Richard Todd
USSnail:820 Annie Court,Norman OK 73069
UUCP: {allegra!cbosgd|ihnp4}!okstate!uokmax!rmtodd