Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update.
2002-02-26  Ulrich Drepper  <drepper@redhat.com>

	* stdio-common/vfscanf.c (_IO_vfwscanf): Always use ungetc, never
	ungetwc.  It's a macro.
	* libio/tst-swscanf.c (do_test): Adjust for now fixed wscanf
	implementation.
	Reported by Jason Merrill <jason@redhat.com>.
  • Loading branch information
Ulrich Drepper committed Feb 26, 2002
1 parent b39d571 commit 73f1b06
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
@@ -1,3 +1,11 @@
2002-02-26 Ulrich Drepper <drepper@redhat.com>

* stdio-common/vfscanf.c (_IO_vfwscanf): Always use ungetc, never
ungetwc. It's a macro.
* libio/tst-swscanf.c (do_test): Adjust for now fixed wscanf
implementation.
Reported by Jason Merrill <jason@redhat.com>.

2002-02-25 Jakub Jelinek <jakub@redhat.com>

* libio/iofopen.c (__fopen_maybe_mmap): Set the initial
Expand Down
23 changes: 12 additions & 11 deletions libio/tst-swscanf.c
Expand Up @@ -26,18 +26,19 @@ static const struct
const wchar_t *fmt;
const wchar_t *wfmt;
const wchar_t *arg;
int retval;
const char *res;
const wchar_t *wres;
int only_C_locale;
} tests[] =
{
{ L"%[abc]", L"%l[abc]", L"aabbccddaabb", "aabbcc", L"aabbcc", 0 },
{ L"%[^def]", L"%l[^def]", L"aabbccddaabb", "aabbcc", L"aabbcc", 0 },
{ L"%[^abc]", L"%l[^abc]", L"aabbccddaabb", "", L"", 0 },
{ L"%[a-c]", L"%l[a-c]", L"aabbccddaabb", "aabbcc", L"aabbcc", 1 },
{ L"%[^d-f]", L"%l[^d-f]", L"aabbccddaabb", "aabbcc", L"aabbcc", 1 },
{ L"%[^a-c]", L"%l[^a-c]", L"aabbccddaabb", "", L"", 1 },
{ L"%[^a-c]", L"%l[^a-c]", L"bbccddaabb", "", L"", 1 }
{ L"%[abc]", L"%l[abc]", L"aabbccddaabb", 1 ,"aabbcc", L"aabbcc", 0 },
{ L"%[^def]", L"%l[^def]", L"aabbccddaabb", 1, "aabbcc", L"aabbcc", 0 },
{ L"%[^abc]", L"%l[^abc]", L"aabbccddaabb", 0, "", L"", 0 },
{ L"%[a-c]", L"%l[a-c]", L"aabbccddaabb", 1, "aabbcc", L"aabbcc", 1 },
{ L"%[^d-f]", L"%l[^d-f]", L"aabbccddaabb", 1, "aabbcc", L"aabbcc", 1 },
{ L"%[^a-c]", L"%l[^a-c]", L"aabbccddaabb", 0, "", L"", 1 },
{ L"%[^a-c]", L"%l[^a-c]", L"bbccddaabb", 0, "", L"", 1 }
};


Expand All @@ -63,13 +64,13 @@ do_test (const char *loc)
if (tests[n].only_C_locale && strcmp (loc, "C") != 0)
continue;

if (swscanf (tests[n].arg, tests[n].fmt, buf) != 1)
if (swscanf (tests[n].arg, tests[n].fmt, buf) != tests[n].retval)
{
printf ("swscanf (\"%S\", \"%S\", ...) failed\n",
tests[n].arg, tests[n].fmt);
result = 1;
}
else if (strcmp (buf, tests[n].res) != 0)
else if (tests[n].retval != 0 && strcmp (buf, tests[n].res) != 0)
{
printf ("swscanf (\"%S\", \"%S\", ...) return \"%s\", expected \"%s\"\n",
tests[n].arg, tests[n].fmt, buf, tests[n].res);
Expand All @@ -79,13 +80,13 @@ do_test (const char *loc)
printf ("swscanf (\"%S\", \"%S\", ...) OK\n",
tests[n].arg, tests[n].fmt);

if (swscanf (tests[n].arg, tests[n].wfmt, wbuf) != 1)
if (swscanf (tests[n].arg, tests[n].wfmt, wbuf) != tests[n].retval)
{
printf ("swscanf (\"%S\", \"%S\", ...) failed\n",
tests[n].arg, tests[n].wfmt);
result = 1;
}
else if (wcscmp (wbuf, tests[n].wres) != 0)
else if (tests[n].retval != 0 && wcscmp (wbuf, tests[n].wres) != 0)
{
printf ("swscanf (\"%S\", \"%S\", ...) return \"%S\", expected \"%S\"\n",
tests[n].arg, tests[n].wfmt, wbuf, tests[n].wres);
Expand Down
12 changes: 6 additions & 6 deletions stdio-common/vfscanf.c
Expand Up @@ -1996,7 +1996,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
{
/* The current character is not in the
scanset. */
ungetwc (c, s);
ungetc (c, s);
goto out;
}

Expand All @@ -2008,7 +2008,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
break;
if (*runp == c && not_in)
{
ungetwc (c, s);
ungetc (c, s);
goto out;
}

Expand All @@ -2018,7 +2018,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr)

if (runp == wp && !not_in)
{
ungetwc (c, s);
ungetc (c, s);
goto out;
}

Expand Down Expand Up @@ -2213,7 +2213,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
{
/* The current character is not in the
scanset. */
ungetwc (c, s);
ungetc (c, s);
goto out2;
}

Expand All @@ -2225,7 +2225,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
break;
if (*runp == c && not_in)
{
ungetwc (c, s);
ungetc (c, s);
goto out2;
}

Expand All @@ -2235,7 +2235,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr)

if (runp == wp && !not_in)
{
ungetwc (c, s);
ungetc (c, s);
goto out2;
}

Expand Down

0 comments on commit 73f1b06

Please sign in to comment.