]> sourceware.org Git - glibc.git/commitdiff
Tue Jul 25 09:14:53 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
authorRoland McGrath <roland@gnu.org>
Tue, 25 Jul 1995 14:47:53 +0000 (14:47 +0000)
committerRoland McGrath <roland@gnu.org>
Tue, 25 Jul 1995 14:47:53 +0000 (14:47 +0000)
* stdio/vfprintf.c (vfprintf): For %s with precision spec, use
  memchr instead of strlen to limit search for NUL by precision.

ChangeLog
stdio/vfprintf.c

index 5e22580c13c12f44f8e38af781692c45ef336201..c329a30a64a7b3c32523895610bc681a05c4a522 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Jul 25 09:14:53 1995  Roland McGrath  <roland@churchy.gnu.ai.mit.edu>
+
+       * stdio/vfprintf.c (vfprintf): For %s with precision spec, use
+       memchr instead of strlen to limit search for NUL by precision.
+
 Mon Jul 24 03:13:16 1995  Roland McGrath  <roland@churchy.gnu.ai.mit.edu>
 
        * sysdeps/posix/pathconf.c: New file.
index 056ea32bee89a5d3bafb784a9a7ad3caac486560..1246229a632dc865f74f5623ec998240ff95e10d 100644 (file)
@@ -531,13 +531,24 @@ vfprintf (s, format, ap)
                      len = 0;
                    }
                }
-              else
-                len = strlen (str);
+              else if (specs[cnt].info.prec != -1)
+               {
+                 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;
+               }
 
-              if (specs[cnt].info.prec != -1
-                 && (size_t) specs[cnt].info.prec < len)
-               /* Limit the length to the precision.  */
-                len = specs[cnt].info.prec;
               specs[cnt].info.width -= len;
 
               if (!specs[cnt].info.left)
This page took 0.045607 seconds and 5 git commands to generate.