[comp.os.minix] Bug in cc => fix for diff

news@santra.UUCP (news) (08/11/87)

I've got strange line numbers from 1.2 diff and last night I
looked in it.  The problems are only with minix cc and everybody
else using diff for sending files for fix seems to be using some
other compiler (?). 
 
It's easy to find out if your diff has problems.  Get a text 
file, change something in second line and diff the versions.
Broken diff doesn't notice it.  It never sees the second line
and when there are differences it misses other lines too.  
Line numbers in hunks are always too small, fix will not work
with them (patch works with lot of complains, it's still nice
to have patch working under minix, thanks to Alan Bishop for
good instructions how to make it).
 
The problem were in read_line().  In line 108 the code checks
if fgets() has found too long line for buffer to hold.  This
check is bit odd, chars tend to be unsigned ints.  Minix cc
gets confused of the comparison to '\377' and produces code
to compare *16-bit* memory area against this pattern and newer
succeeds.  This is probably a bug in cc ?  I fixed this with 
following diff.  Changing  p to 
	register unsigned char *p;
also fixed it, but l_text still is plain char array and 
changing it...
 
--------------------- cut here for diff.diff ----------------------------------
108c108
< 	if (p[1] != '\377' && *p != '\n') {
---
> 	if (p[1] != -1 && *p != '\n') {
--------------------------- _end_cut ------------------------------------------
 
 
P.S.
	Me too: Please post list of cc's flags !


---------------------------------------------------------------------------
Pertti Kasanen                      Internet: ptk@hutcs.hut.fi
+358 0 753 3779                       Bitnet: ptk%hutcs.uucp@fingate.bitnet
Helsinki University of Technology       UUCP: mcvax!hutcs!ptk