1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-30 22:43:12 +03:00
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.
This commit is contained in:
Ulrich Drepper
2000-10-04 22:50:20 +00:00
parent 883ba31595
commit d64e603ae7
3 changed files with 30 additions and 18 deletions

View File

@ -1,3 +1,9 @@
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.
2000-10-04 Ulrich Drepper <drepper@redhat.com> 2000-10-04 Ulrich Drepper <drepper@redhat.com>
* argp/argp-help.c: Make sure we get the correct gettext and * argp/argp-help.c: Make sure we get the correct gettext and

View File

@ -46,6 +46,12 @@ main (int argc, char **argv)
result = 1; result = 1;
} }
if (sscanf ("", "%10[a-z]", buf) != EOF)
{
fputs ("test failed!\n", stdout);
result = 1;
}
sscanf ("conversion] Zero flag Ze]ro#\n", "%*[^]] %[^#]\n", buf); sscanf ("conversion] Zero flag Ze]ro#\n", "%*[^]] %[^#]\n", buf);
if (strcmp (buf, "] Zero flag Ze]ro") != 0) if (strcmp (buf, "] Zero flag Ze]ro") != 0)
{ {

View File

@ -1973,13 +1973,13 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
{ {
size_t now = read_in; size_t now = read_in;
#ifdef COMPILE_WSCANF #ifdef COMPILE_WSCANF
if (inchar () == WEOF)
input_error ();
do do
{ {
wchar_t *runp; wchar_t *runp;
if (inchar () == WEOF)
break;
/* Test whether it's in the scanlist. */ /* Test whether it's in the scanlist. */
runp = tw; runp = tw;
while (runp < wp) 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: out:
#else #else
char buf[MB_LEN_MAX]; char buf[MB_LEN_MAX];
size_t cnt = 0; size_t cnt = 0;
mbstate_t cstate; mbstate_t cstate;
if (inchar () == EOF)
input_error ();
memset (&cstate, '\0', sizeof (cstate)); memset (&cstate, '\0', sizeof (cstate));
do do
{ {
again:
if (inchar () == EOF)
break;
if (wp[c] == not_in) if (wp[c] == not_in)
{ {
ungetc_not_eof (c, s); ungetc_not_eof (c, s);
@ -2097,7 +2096,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
/* Possibly correct character, just not enough /* Possibly correct character, just not enough
input. */ input. */
assert (cnt < MB_CUR_MAX); assert (cnt < MB_CUR_MAX);
goto again; continue;
} }
if (n != cnt) 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) if (cnt != 0)
/* We stopped in the middle of recognizing another /* We stopped in the middle of recognizing another
@ -2175,6 +2177,10 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
else else
{ {
size_t now = read_in; size_t now = read_in;
if (inchar () == EOF)
input_error ();
#ifdef COMPILE_WSCANF #ifdef COMPILE_WSCANF
memset (&state, '\0', sizeof (state)); memset (&state, '\0', sizeof (state));
@ -2184,9 +2190,6 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
wchar_t *runp; wchar_t *runp;
size_t n; size_t n;
if (inchar () == WEOF)
break;
/* Test whether it's in the scanlist. */ /* Test whether it's in the scanlist. */
runp = tw; runp = tw;
while (runp < wp) while (runp < wp)
@ -2275,14 +2278,11 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
assert (n <= MB_CUR_MAX); assert (n <= MB_CUR_MAX);
str += n; str += n;
} }
while (--width > 0); while (--width > 0 && inchar () != WEOF);
out2: out2:
#else #else
do do
{ {
if (inchar () == EOF)
break;
if (wp[c] == not_in) if (wp[c] == not_in)
{ {
ungetc_not_eof (c, s); 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 #endif
if (now == read_in) if (now == read_in)