[comp.graphics] A bug in PBM software

brian@ucselx.sdsu.edu (Brian Ho) (08/08/90)

I have find a bug (may not appear in other system) in the PBM software.
The bug is in the program which converts a .PCX (paint brush image format)
to a Pbm portable bitmap.

The bug (very small) appear at line 102 in program "pcxtopbm.c" which is
under /pbmplus/pbm/.  The orignal code read :

    if (b & 0xC0 == 0xC0) 
      ..
      ..

However, some system (e.g. Sun 3/50) does not like this.  It miss interpret it
as  
    if (b & (OxCO == 0xC0) 
      ..
      ..

Therefore,  I have simply put a parentesis around the '&' clause

    if ((b & OxC0) == 0xC0)
      ..
      ..

  and it works Great!!!!!!!


I don't if it (the bug) appears in other system.. keep me posted...

my E-mail address is

brian@yucatec.sdsu.edu
eden@cs.sdsu.edu

falk@peregrine.Sun.COM (Ed Falk) (08/12/90)

In article <1990Aug7.200352.1484@ucselx.sdsu.edu> brian@ucselx.sdsu.edu (Brian Ho) writes:
>I have find a bug (may not appear in other system) in the PBM software.
>The bug is in the program which converts a .PCX (paint brush image format)
>to a Pbm portable bitmap.
>
>The bug (very small) appear at line 102 in program "pcxtopbm.c" which is
>under /pbmplus/pbm/.  The orignal code read :
>
>    if (b & 0xC0 == 0xC0) 
>      ..
>      ..
>
>However, some system (e.g. Sun 3/50) does not like this.  It miss interpret it
>as  
>    if (b & (OxCO == 0xC0) 
>      ..
>      ..

According to "The C Programmer's Handbook" by AT&T Bell Labs, this is
the correct behavior.  If you find a compiler that *doesn't* parse
this way, contact the vendor immediately.

(personally, I think this is the wrong order of precedence, but K&R
defined it that way so that's the way it is.)

	-ed falk, sun microsystems -- sun!falk, falk@sun.com
	"What are politicians going to tell people when the
	Constitution is gone and we still have a drug problem?"
			-- William Simpson, A.C.L.U.