Thu Jul 4 01:34:04 1996 Ulrich Drepper <drepper@cygnus.com>
authorroland <roland>
Tue, 9 Jul 1996 18:49:42 +0000 (18:49 +0000)
committerroland <roland>
Tue, 9 Jul 1996 18:49:42 +0000 (18:49 +0000)
* stdio-common/printf-parse.h: Initialize state variable before
calling mbrlen.
* stdio-common/printf-prs.c: Don't initialize state variable here.
* stdio-common/vfprintf.c: Don't initialize state variable.
(vfprintf): While determining length of multibyte string don't
try to be clever in determining characters to use for first
call.

stdio-common/printf-parse.h
stdio-common/vfprintf.c

index a7960e6..9a5cfba 100644 (file)
@@ -97,6 +97,8 @@ find_spec (const char *format, mbstate_t *ps)
     {
       int len;
 
+      /* Remove any hints of a wrong encoding.  */
+      ps->count = 0;
       if (isascii (*format) || (len = mbrlen (format, MB_CUR_MAX, ps)) <= 0)
        ++format;
       else
index 8031b99..3fa53a6 100644 (file)
@@ -735,16 +735,14 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
        else                                                                  \
          {                                                                   \
            const wchar_t *s2 = (const wchar_t *) string;                     \
-           mbstate_t mbstate = 0;                                            \
+           mbstate_t mbstate;                                                \
                                                                              \
-           len = wcsrtombs (NULL, &s2, prec != -1 ? prec : UINT_MAX,         \
-                            &mbstate);                                       \
+           len = wcsrtombs (NULL, &s2, 0, &mbstate);                         \
            if (len == (size_t) -1)                                           \
              /* Illegal wide-character string.  */                           \
              return -1;                                                      \
                                                                              \
            s2 = (const wchar_t *) string;                                    \
-           mbstate = 0;                                                      \
            string = alloca (len + 1);                                        \
            (void) wcsrtombs (string, &s2, prec != -1 ? prec : UINT_MAX,      \
                              &mbstate);                                      \
@@ -841,7 +839,6 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
   /* Initialize local variables.  */
   done = 0;
   grouping = (const char *) -1;
-  mbstate = 0;
   ap_save = ap;
   nspecs_done = 0;