NEW - Bug in compress program (really C compiler)
Spencer W. Thomas
thomas at utah-gr.UUCP
Wed Jul 18 03:22:51 AEST 1984
(This is a reposting with a fix in my original bug fix.)
Jim McKie (mcvax!jim) has uncovered what is apparently a bug in the C
compiler which causes the compress program to improperly compress large
files. The calls to the output routine, coded as
output( (code_int) ent->code );
cause sign extension of the code (oops). Since they are declared as
unsigned ints, I can only assume that the C compiler is at fault here.
Unfortunately, code_int can't be declared as unsigned, since it is
necessary to pass a -1 to output(). His proposed fix is to recode the
statement as
output( (code_int) ent->code & (maxmaxcode - 1) );
or
output( (code_int) ent->code & ((1 << BITS) - 1) );
Another possibility is to declare code_int as unsigned, then instead of
passing -1 to output, to pass (1 << BITS) (also an illegal code). I
haven't tested this possibility, but it seems as if it should work.
(It won't work on those C compilers which don't allow unsigned long,
if BITS is >= 16.)
Also, another warning to those of you using pcc on a vax - do NOT
compile compress with -O unless you have installed the bug fix to c2
dealing with extv->cvtwl conversion.
=Spencer
(I hope I haven't lost anything for anyone. Aren't you glad it doesn't
delete the original file, like compact does?)
More information about the Comp.sources.unix
mailing list