fgets() returns NULL at EOF??

karl at haddock karl at haddock
Thu Sep 4 05:35:00 AEST 1986


bzs at bu-cs.BU.EDU (Barry Shein) writes:

>Traditionally, any function that cannot return a promised pointer ...
>returns NULL (there exists a few syscalls which return ((char *) -1) or
>equivalent, c'est la vie, this has been hashed out, I guess the rule that
>syscalls return -1 won [eg. sbrk].)

Last time I used a pdp11, there was a bug in lseek().  The error return,
which should have been (long)-1 (i.e. 0xffffffff) was 0xffff0000.  I never
determined whether this was an AT&T standard bug or a local glitch.  The
surprising thing is that lseek *was* making the check, but it explicitly
set r1 (the lower half) to 0 instead of -1!  On systems where char* is wider
than int, sbrk() could have a similar problem.

Karl W. Z. Heuer (ima!haddock!karl; karl at haddock.isc.com), The Walking Lint



More information about the Comp.lang.c mailing list