]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Update.
authorUlrich Drepper <drepper@redhat.com>
Sun, 12 Sep 1999 21:23:32 +0000 (21:23 +0000)
committerUlrich Drepper <drepper@redhat.com>
Sun, 12 Sep 1999 21:23:32 +0000 (21:23 +0000)
* stdio-common/vfprintf.c: Remove limitation on size of precision
for integers.

ChangeLog
stdio-common/vfprintf.c

index c4f86938db64ab08e1b80310f7194fe020a05859..eed31e6480c15d8247c16238c85aff16e144e109 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 1999-09-12  Ulrich Drepper  <drepper@cygnus.com>
 
+       * stdio-common/vfprintf.c: Remove limitation on size of precision
+       for integers.
+
        * posix/fnmatch.c (internal_fnmatch): Make it compilable outside
        glibc by defining internal_function if it isn't already.
 
index 9a8ebabd428313a569a17ce4d6cc8252bca8877c..0f892b19a33c370a2b326a5aab6d14d9de1e0f91 100644 (file)
@@ -687,19 +687,15 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
            }                                                                 \
        }                                                                     \
                                                                              \
-      prec -= workend - string;                                                      \
-                                                                             \
-      if (prec > 0)                                                          \
-       /* Add zeros to the precision.  */                                    \
-       while (prec-- > 0)                                                    \
-         *string-- = L_('0');                                                \
-      else if (number.word != 0 && alt && base == 8)                         \
+      if (prec <= workend - string && number.word != 0 && alt && base == 8)   \
        /* Add octal marker.  */                                              \
        *string-- = L_('0');                                                  \
                                                                              \
+      prec = MAX (0, prec - (workend - string));                             \
+                                                                             \
       if (!left)                                                             \
        {                                                                     \
-         width -= workend - string;                                          \
+         width -= workend - string + prec;                                   \
                                                                              \
          if (number.word != 0 && alt && base == 16)                          \
            /* Account for 0X hex marker.  */                                 \
@@ -708,63 +704,67 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
          if (is_negative || showsign || space)                               \
            --width;                                                          \
                                                                              \
-         if (pad == L_('0'))                                                 \
+         if (pad == L_(' '))                                                 \
            {                                                                 \
-             while (width-- > 0)                                             \
-               *string-- = L_('0');                                          \
-                                                                             \
-             if (number.word != 0 && alt && base == 16)                      \
-               {                                                             \
-                 *string-- = spec;                                           \
-                 *string-- = L_('0');                                        \
-               }                                                             \
-                                                                             \
-             if (is_negative)                                                \
-               *string-- = L_('-');                                          \
-             else if (showsign)                                              \
-               *string-- = L_('+');                                          \
-             else if (space)                                                 \
-               *string-- = L_(' ');                                          \
+             PAD (L_(' '));                                                  \
+             width = 0;                                                      \
            }                                                                 \
-         else                                                                \
+                                                                             \
+         if (is_negative)                                                    \
+           PUTC (L_('-'), s);                                                \
+         else if (showsign)                                                  \
+           PUTC (L_('+'), s);                                                \
+         else if (space)                                                     \
+           PUTC (L_(' '), s);                                                \
+                                                                             \
+         if (number.word != 0 && alt && base == 16)                          \
            {                                                                 \
-             if (number.word != 0 && alt && base == 16)                      \
-               {                                                             \
-                 *string-- = spec;                                           \
-                 *string-- = L_('0');                                        \
-               }                                                             \
-                                                                             \
-             if (is_negative)                                                \
-               *string-- = L_('-');                                          \
-             else if (showsign)                                              \
-               *string-- = L_('+');                                          \
-             else if (space)                                                 \
-               *string-- = L_(' ');                                          \
-                                                                             \
-             while (width-- > 0)                                             \
-               *string-- = L_(' ');                                          \
+             PUTC (L_('0'), s);                                              \
+             PUTC (spec, s);                                                 \
            }                                                                 \
                                                                              \
+         width += prec;                                                      \
+         PAD (L_('0'));                                                      \
+                                                                             \
          outstring (string + 1, workend - string);                           \
                                                                              \
          break;                                                              \
        }                                                                     \
       else                                                                   \
        {                                                                     \
-         if (number.word != 0 && alt && base == 16)                          \
+         if (is_negative)                                                    \
            {                                                                 \
-             *string-- = spec;                                               \
-             *string-- = L_('0');                                            \
+             PUTC (L_('-'), s);                                              \
+             --width;                                                        \
            }                                                                 \
-                                                                             \
-         if (is_negative)                                                    \
-           *string-- = L_('-');                                              \
          else if (showsign)                                                  \
-           *string-- = L_('+');                                              \
+           {                                                                 \
+             PUTC (L_('+'), s);                                              \
+             --width;                                                        \
+           }                                                                 \
          else if (space)                                                     \
-           *string-- = L_(' ');                                              \
+           {                                                                 \
+             PUTC (L_(' '), s);                                              \
+             --width;                                                        \
+           }                                                                 \
+                                                                             \
+         if (number.word != 0 && alt && base == 16)                          \
+           {                                                                 \
+             PUTC (L_('0'), s);                                              \
+             PUTC (spec, s);                                                 \
+             width -= 2;                                                     \
+           }                                                                 \
+                                                                             \
+         width -= workend - string + prec;                                   \
+                                                                             \
+         if (prec > 0)                                                       \
+           {                                                                 \
+             int temp = width;                                               \
+             width = prec;                                                   \
+             PAD (L_('0'));;                                                 \
+             width = temp;                                                   \
+           }                                                                 \
                                                                              \
-         width -= workend - string;                                          \
          outstring (string + 1, workend - string);                           \
                                                                              \
          PAD (L_(' '));                                                      \