aboutsummaryrefslogtreecommitdiff
path: root/stdio-common/vfscanf.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-10-04 22:50:20 +0000
committerUlrich Drepper <drepper@redhat.com>2000-10-04 22:50:20 +0000
commitd64e603ae7cd3bbede9acf62d402c9d9492d2faa (patch)
tree30157b6eec9c0ecfa1bbb77783006020561c9daa /stdio-common/vfscanf.c
parent883ba31595b0b4660756c80befc0b5fe52f42a6d (diff)
downloadglibc-d64e603ae7cd3bbede9acf62d402c9d9492d2faa.tar
glibc-d64e603ae7cd3bbede9acf62d402c9d9492d2faa.tar.gz
glibc-d64e603ae7cd3bbede9acf62d402c9d9492d2faa.tar.bz2
glibc-d64e603ae7cd3bbede9acf62d402c9d9492d2faa.zip
Update.
2000-10-04 Jakub Jelinek <jakub@redhat.com> * stdio-common/vfscanf.c (_IO_vfscanf): For [ conversion do input_error() if EOF is seen before processing. * stdio-common/tstscanf.c (main): Add testcase.
Diffstat (limited to 'stdio-common/vfscanf.c')
-rw-r--r--stdio-common/vfscanf.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c
index 43d25ee7a7..cf3befd399 100644
--- a/stdio-common/vfscanf.c
+++ b/stdio-common/vfscanf.c
@@ -1973,13 +1973,13 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
{
size_t now = read_in;
#ifdef COMPILE_WSCANF
+ if (inchar () == WEOF)
+ input_error ();
+
do
{
wchar_t *runp;
- if (inchar () == WEOF)
- break;
-
/* Test whether it's in the scanlist. */
runp = tw;
while (runp < wp)
@@ -2063,21 +2063,20 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
}
}
}
- while (--width > 0);
+ while (--width > 0 && inchar () != WEOF);
out:
#else
char buf[MB_LEN_MAX];
size_t cnt = 0;
mbstate_t cstate;
+ if (inchar () == EOF)
+ input_error ();
+
memset (&cstate, '\0', sizeof (cstate));
do
{
- again:
- if (inchar () == EOF)
- break;
-
if (wp[c] == not_in)
{
ungetc_not_eof (c, s);
@@ -2097,7 +2096,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
/* Possibly correct character, just not enough
input. */
assert (cnt < MB_CUR_MAX);
- goto again;
+ continue;
}
if (n != cnt)
@@ -2142,8 +2141,11 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
}
}
}
+
+ if (--width <= 0)
+ break;
}
- while (--width > 0);
+ while (inchar () != EOF);
if (cnt != 0)
/* We stopped in the middle of recognizing another
@@ -2175,6 +2177,10 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
else
{
size_t now = read_in;
+
+ if (inchar () == EOF)
+ input_error ();
+
#ifdef COMPILE_WSCANF
memset (&state, '\0', sizeof (state));
@@ -2184,9 +2190,6 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
wchar_t *runp;
size_t n;
- if (inchar () == WEOF)
- break;
-
/* Test whether it's in the scanlist. */
runp = tw;
while (runp < wp)
@@ -2275,14 +2278,11 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
assert (n <= MB_CUR_MAX);
str += n;
}
- while (--width > 0);
+ while (--width > 0 && inchar () != WEOF);
out2:
#else
do
{
- if (inchar () == EOF)
- break;
-
if (wp[c] == not_in)
{
ungetc_not_eof (c, s);
@@ -2328,7 +2328,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
}
}
}
- while (--width > 0);
+ while (--width > 0 && inchar () != EOF);
#endif
if (now == read_in)