]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Remove limitation on size of precision for integers.
authorUlrich Drepper <drepper@redhat.com>
Sat, 25 Sep 1999 06:52:45 +0000 (06:52 +0000)
committerUlrich Drepper <drepper@redhat.com>
Sat, 25 Sep 1999 06:52:45 +0000 (06:52 +0000)
stdio-common/vfprintf.c

index 3249911cc7e8073560eeed9348ea0ba844b0c8c6..ce565e70d5b1fe03f9b035064437228e4300571e 100644 (file)
@@ -653,19 +653,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-- = '0';                                                    \
-      else if (number.word != 0 && alt && base == 8)                         \
+      if (prec <= workend - string && number.word != 0 && alt && base == 8)   \
        /* Add octal marker.  */                                              \
        *string-- = '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.  */                                 \
@@ -674,63 +670,67 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
          if (is_negative || showsign || space)                               \
            --width;                                                          \
                                                                              \
-         if (pad == '0')                                                     \
+         if (pad == ' ')                                                     \
            {                                                                 \
-             while (width-- > 0)                                             \
-               *string-- = '0';                                              \
-                                                                             \
-             if (number.word != 0 && alt && base == 16)                      \
-               {                                                             \
-                 *string-- = spec;                                           \
-                 *string-- = '0';                                            \
-               }                                                             \
-                                                                             \
-             if (is_negative)                                                \
-               *string-- = '-';                                              \
-             else if (showsign)                                              \
-               *string-- = '+';                                              \
-             else if (space)                                                 \
-               *string-- = ' ';                                              \
+             PAD (L_(' '));                                                  \
+             width = 0;                                                      \
            }                                                                 \
-         else                                                                \
-           {                                                                 \
-             if (number.word != 0 && alt && base == 16)                      \
-               {                                                             \
-                 *string-- = spec;                                           \
-                 *string-- = '0';                                            \
-               }                                                             \
                                                                              \
-             if (is_negative)                                                \
-               *string-- = '-';                                              \
-             else if (showsign)                                              \
-               *string-- = '+';                                              \
-             else if (space)                                                 \
-               *string-- = ' ';                                              \
+         if (is_negative)                                                    \
+           PUTC (L_('-'), s);                                                \
+         else if (showsign)                                                  \
+           PUTC (L_('+'), s);                                                \
+         else if (space)                                                     \
+           PUTC (L_(' '), s);                                                \
                                                                              \
-             while (width-- > 0)                                             \
-               *string-- = ' ';                                              \
+         if (number.word != 0 && alt && base == 16)                          \
+           {                                                                 \
+             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-- = '0';                                                \
+             PUTC (L_('-'), s);                                              \
+             --width;                                                        \
            }                                                                 \
-                                                                             \
-         if (is_negative)                                                    \
-           *string-- = '-';                                                  \
          else if (showsign)                                                  \
-           *string-- = '+';                                                  \
+           {                                                                 \
+             PUTC (L_('+'), s);                                              \
+             --width;                                                        \
+           }                                                                 \
          else if (space)                                                     \
-           *string-- = ' ';                                                  \
+           {                                                                 \
+             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 (' ');                                                          \