🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.sources.bugs
Article #979

Bug in (System V at least) UNIX ARC

#979
From: john
Date: Tue, 24 Mar 1987 19:43
58 lines
3286 bytes
There is a bug in the System V port of ARC 5.12; in the gocode()
function of arclzw.c, getc_unp(), which returns an int, is called, and
the return value is assigned to an unsigned.  The result of this is
then checked against EOF.  The new Sun C compiler loudly complains
(with a verbose, 3-line, warning message for each assignment).
ANSI-compliant C compilers will likely complain as well (at least for
libraries where EOF == -1 !).

The fixes are below, in context diff form, suitable for patching.

*** /tmp/,RCSt1a03521	Tue Mar 24 14:38:19 1987
--- arclzw.c	Tue Mar 24 14:37:53 1987
***************
*** 674,680
  static INT gocode(fd)                      /* read in a twelve bit code */
  FILE *fd;                              /* file to get code from */
  {
!     unsigned INT localbuf, returnval;
  
      if(inbuf==EMPTY)                   /* if on a code boundary */
      {    if((localbuf=getc_unp(fd))==EOF)   /* get start of next code */

--- 674,680 -----
  static INT gocode(fd)                      /* read in a twelve bit code */
  FILE *fd;                              /* file to get code from */
  {
!     INT localbuf, returnval, intemp;
  
      if(inbuf==EMPTY)                   /* if on a code boundary */
      {    if((localbuf=getc_unp(fd))==EOF)   /* get start of next code */
***************
*** 680,688
      {    if((localbuf=getc_unp(fd))==EOF)   /* get start of next code */
                return EOF;              /* pass back end of file status */
           localbuf &= 0xFF;             /* mask down to true byte value */
!          if((inbuf=getc_unp(fd))==EOF) /* get end of code, start of next */
!               return EOF;              /* this should never happen */
!          inbuf &= 0xFF;                /* mask down to true byte value */
  
           returnval = ((localbuf<<4)&0xFF0) + ((inbuf>>4)&0x00F);
           inbuf &= 0x000F;              /* leave partial code pending */

--- 680,688 -----
      {    if((localbuf=getc_unp(fd))==EOF)   /* get start of next code */
                return EOF;              /* pass back end of file status */
           localbuf &= 0xFF;             /* mask down to true byte value */
!          if((intemp=getc_unp(fd))==EOF) /* get end of code, start of next */
!               {inbuf=intemp; return EOF;}     /* this should never happen */
!          inbuf = intemp & 0xFF;           /* mask down to true byte value */
  
           returnval = ((localbuf<<4)&0xFF0) + ((inbuf>>4)&0x00F);
           inbuf &= 0x000F;              /* leave partial code pending */


-- 
John Owens		Old Dominion University - Norfolk, Virginia, USA
john@ODU.EDU		old arpa: john%odu.edu@RELAY.CS.NET
+1 804 440 3915		old uucp: {seismo,harvard,sun,hoptoad}!xanth!john
Technical Details
Message-ID: <732@xanth.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watnot!watmath!clyde!rutgers!pyrnj!mirror!xanth!john

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watnot!watmath!clyde!rutgers!pyrnj!mirror!xanth!john
From: john@xanth.UUCP
Newsgroups: net.sources.bugs
Subject: Bug in (System V at least) UNIX ARC
Message-ID: <732@xanth.UUCP>
Date: Tue, 24-Mar-87 14:43:11 EST
Article-I.D.: xanth.732
Posted: Tue Mar 24 14:43:11 1987
Date-Received: Thu, 26-Mar-87 03:15:21 EST
Organization: Old Dominion University, Norfolk Va.
Lines: 58
Keywords: unsigned