(vfprintf: %s): Never search past the limit specified by the precision.
authorroland <roland>
Fri, 25 Aug 1995 16:50:59 +0000 (16:50 +0000)
committerroland <roland>
Fri, 25 Aug 1995 16:50:59 +0000 (16:50 +0000)
stdio/vfprintf.c

index 1246229..06aa0a0 100644 (file)
@@ -533,21 +533,16 @@ vfprintf (s, format, ap)
                }
               else if (specs[cnt].info.prec != -1)
                {
+                 /* Search for the end of the string, but don't search
+                     past the length specified by the precision.  */
                  const char *end = memchr (str, '\0', specs[cnt].info.prec);
                  if (end)
                    len = end - str;
                  else
-                   len = strlen (str);
-               }
-             else
-               {
-                 len = strlen (str);
-
-                 if (specs[cnt].info.prec != -1
-                     && (size_t) specs[cnt].info.prec < len)
-                   /* Limit the length to the precision.  */
                    len = specs[cnt].info.prec;
                }
+             else
+               len = strlen (str);
 
               specs[cnt].info.width -= len;