projects
/
fw
/
pdclib
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed EOF handling.
[fw/pdclib]
/
functions
/
stdio
/
vfscanf.c
diff --git
a/functions/stdio/vfscanf.c
b/functions/stdio/vfscanf.c
index 99a752ff2db0258fc8ccc67d47faae2162f3e5ac..8f121e95e4a73cac03d000cf6a96132e2163e5ab 100644
(file)
--- a/
functions/stdio/vfscanf.c
+++ b/
functions/stdio/vfscanf.c
@@
-42,7
+42,7
@@
int vfscanf( FILE * _PDCLIB_restrict stream, const char * _PDCLIB_restrict forma
{
++status.i;
}
{
++status.i;
}
- if (
c != EOF )
+ if (
! feof( stream ) ) /* TODO: Check EOF status directly */
{
ungetc( c, stream );
}
{
ungetc( c, stream );
}
@@
-50,10
+50,13
@@
int vfscanf( FILE * _PDCLIB_restrict stream, const char * _PDCLIB_restrict forma
else
{
/* Non-whitespace char in format string: Match verbatim */
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 */
{
/* Matching error */
- ungetc( c, stream );
+ if ( ! feof( stream ) ) /* TODO: Check EOF status directly */
+ {
+ ungetc( c, stream );
+ }
return status.n;
}
else
return status.n;
}
else