aboutsummaryrefslogtreecommitdiff
path: root/stdio-common
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-08-09 20:23:16 +0000
committerUlrich Drepper <drepper@redhat.com>2001-08-09 20:23:16 +0000
commit2f278c9480ed5362c422526acb36d9450ed682d7 (patch)
tree08fb23850c2d923542be7a758b952e44edae5c8e /stdio-common
parent5569e0a6fb5c99cfb1b6b9ac020edfa95f710603 (diff)
downloadglibc-2f278c9480ed5362c422526acb36d9450ed682d7.zip
glibc-2f278c9480ed5362c422526acb36d9450ed682d7.tar.gz
glibc-2f278c9480ed5362c422526acb36d9450ed682d7.tar.bz2
Update.
* stdio-common/vfscanf.c: Fix reading of wide chars and strings if not COMPILE_WSCANF.
Diffstat (limited to 'stdio-common')
-rw-r--r--stdio-common/vfscanf.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c
index 29d96e4..6312af7 100644
--- a/stdio-common/vfscanf.c
+++ b/stdio-common/vfscanf.c
@@ -755,40 +755,35 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
{
/* We have to convert the multibyte input sequence to wide
characters. */
- char buf[MB_LEN_MAX];
+ char buf[0];
mbstate_t cstate;
memset (&cstate, '\0', sizeof (cstate));
do
{
- size_t cnt;
-
/* This is what we present the mbrtowc function first. */
buf[0] = c;
- cnt = 1;
while (1)
{
size_t n;
n = __mbrtowc (!(flags & SUPPRESS) ? wstr : NULL,
- buf, cnt, &cstate);
+ buf, 1, &cstate);
if (n == (size_t) -2)
{
/* Possibly correct character, just not enough
input. */
- assert (cnt < MB_CUR_MAX);
-
if (inchar () == EOF)
encode_error ();
- buf[cnt++] = c;
+ buf[0] = c;
continue;
}
- if (n != cnt)
+ if (n != 1)
encode_error ();
/* We have a match. */
@@ -1063,36 +1058,33 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
}
#else
{
- char buf[MB_LEN_MAX];
- size_t cnt;
+ char buf[0];
buf[0] = c;
- cnt = 1;
while (1)
{
size_t n;
n = __mbrtowc (!(flags & SUPPRESS) ? wstr : NULL,
- buf, cnt, &cstate);
+ buf, 1, &cstate);
if (n == (size_t) -2)
{
/* Possibly correct character, just not enough
input. */
- assert (cnt < MB_CUR_MAX);
-
if (inchar () == EOF)
encode_error ();
- buf[cnt++] = c;
+ buf[0] = c;
continue;
}
- if (n != cnt)
+ if (n != 1)
encode_error ();
/* We have a match. */
+ ++wstr;
break;
}