[En-Nut-Discussion] Bug in fgetc
Ralph Mason
ralph.mason at telogis.com
Sat Apr 12 03:08:30 CEST 2003
fgetc currently reads a char from the stream, this means that when the char
0xff is promoted to an in it returns -1 (EOF), the correct result is 0xFF
Below is an update.
-Ralph
int fgetc(FILE * stream)
{
u_char ch;
if (stream->iob_flags & _IOUNG) {
stream->iob_flags &= ~_IOUNG;
return stream->iob_unget;
}
if (_read(stream->iob_fd, &ch, 1) != 1)
return EOF;
return (int) ch;
}
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.461 / Virus Database: 260 - Release Date: 10/03/2003
More information about the En-Nut-Discussion
mailing list