Bug in compress - (nf)

Joe Orost joe at petsd.UUCP
Mon Jan 14 23:52:33 AEST 1985


In article <53800002 at ccvaxa.UUCP> willcox at ccvaxa.UUCP writes:
>I did run into one bug that shows up when you try to run compress on a
>machine that correctly implements comparison between signed and
>unsigned ints.  The following code appears in two places in
>compress.c:
>
>    while ( (c = getchar()) != (unsigned) EOF ) {
>
>The problem is that ((unsigned) -1) is not the same thing as ((int) -1).
>The vax (and many other machines) do 32-bit compares, and say they are
>equal, but other machines (correctly) do not.  The program drops into
>an infinite loop looking for EOF.
>
>The "(unsigned)" in the above expression should be removed.  It won't
>break the program on machines that do the compare wrong, and will make
>it work on machines that do it right.
>
>With this change, compress works on the Gould machines.

You are absolutely correct.  The above code was inserted for the
Perkin-Elmer machine which outputs a 4 times slower compare instruction
without the "(unsigned)".  The correct fix follows:

Index: compress.c
710a711
> #ifdef interdata
711a713,715
> #else !interdata
>     while ( (c = getchar()) != EOF ) {
> #endif interdata
741a746
> #ifdef interdata
742a748,750
> #else !interdata
>     while ( (c = getchar()) != EOF ) {
> #endif interdata

					regards,
					joe

--
Full-Name:  Joseph M. Orost
UUCP:       ..!{decvax,ucbvax,ihnp4}!vax135!petsd!joe
US Mail:    MS 313; Perkin-Elmer; 106 Apple St; Tinton Falls, NJ 07724
Phone:      (201) 870-5844
Location:   40 19'49" N / 74 04'37" W



More information about the Comp.sources.bugs mailing list