fgetc() returns EOF before end of file.
Posted: Mon Sep 18, 2006 12:39 am
When I open a binary file and try to read 0xFF with fgetc(), I get EOF (= 0xFFFFFFFF) instead.
The problem is in ps2sdk/ee/libc/src/stdio.c:
"char c;" need to be replaced by "unsigned char c;", because casting to int will extend the sign. All negative values will be wrongly converted. Can someone change it in the svn repository?
The problem is in ps2sdk/ee/libc/src/stdio.c:
Code: Select all
int fgetc(FILE *stream)
{
char c;
int ret;
switch(stream->type) {
case STD_IOBUF_TYPE_GS:
case STD_IOBUF_TYPE_SIO:
case STD_IOBUF_TYPE_STDOUTHOST:
/* cannot read from stdout or stderr. */
ret = EOF;
break;
default:
ret = ((fread(&c, 1, 1, stream) == 1) ? (int)c : EOF);
}
return (ret);
}