{
++status.i;
}
- if ( c != EOF )
+ if ( ! feof( stream ) ) /* TODO: Check EOF status directly */
{
ungetc( c, stream );
}
else
{
/* Non-whitespace char in format string: Match verbatim */
- if ( ( c = getc( stream ) ) != *format )
+ if ( ( ( c = getc( stream ) ) != *format ) || feof( stream ) ) /* TODO: Check EOF status directly */
{
/* Matching error */
- ungetc( c, stream );
+ if ( ! feof( stream ) ) /* TODO: Check EOF status directly */
+ {
+ ungetc( c, stream );
+ }
return status.n;
}
else