Article View: comp.sys.atari.st
Article #2287Sozobon C bug report
From: S.Usher
Date: Fri, 07 Jul 1989 14:04
Date: Fri, 07 Jul 1989 14:04
38 lines
1383 bytes
1383 bytes
From: Stephen Usher <S.Usher@uk.ac.ucl.cs>
I have just found an unfortunate bug with Sozobon C. If you divide using
long integers you sometimes get a negative result, even when both the
integers have positive values.
The piece of code which highlighed the bug is part of a program which
emulates the UN*X MORE program. It's actual function is to work and display
the percentage of the file so far seen. Here is a code segment.
static long endoffile, bytes = 0, topbytes;
endoffile = endof(fp);
topbytes = bytes;
if (fp != stdin)
printf("(%ld%%)", ((bytes * 100) / endoffile));
long endof(fp)
FILE *fp;
{
return (lseek(fileno(fp), 0L, 2));
}
The variable "bytes" is always incremented and, therefore, can never become
negative, so topbytes can never become negative (topbytes holds the file
position of the top of the screen).
Stephen Usher
Addresses:-
(JANET)
S.Usher@uk.ac.ucl.cs or UCACMSU@uk.ac.ucl.euclid
--8<-------------- Cut --------------------- Here ------------------------
Technical Details
Message-ID:
<328@ucl-cs.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!sun-barr!cs.utexas.edu!uunet!mcvax!ukc!strath-cs!nott-cs!ucl-cs!S.UsherShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!sun-barr!cs.utexas.edu!uunet!mcvax!ukc!strath-cs!nott-cs!ucl-cs!S.Usher From: S.Usher@ucl-cs.UUCP Newsgroups: comp.sys.atari.st Subject: Sozobon C bug report Message-ID: <328@ucl-cs.UUCP> Date: 7 Jul 89 14:04:42 GMT Sender: S.Usher@ucl-cs.UUCP Lines: 38