]> granicus.if.org Git - python/commitdiff
Cleanup PyUnicode_FromFormatV() for zero padding
authorVictor Stinner <victor.stinner@gmail.com>
Sat, 6 Oct 2012 21:55:33 +0000 (23:55 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Sat, 6 Oct 2012 21:55:33 +0000 (23:55 +0200)
Skip the "0" instead of parsing it twice: detect zero padding and then parsed
as a digit of the width.

Objects/unicodeobject.c

index 0ed38fef8f554efdfb4dae831d04a55325ed8003..73a3dc48d23144f2f7623cce3d724c9e2333a0a8 100644 (file)
@@ -2349,7 +2349,11 @@ unicode_fromformat_arg(_PyUnicodeWriter *writer,
 
     p = f;
     f++;
-    zeropad = (*f == '0');
+    zeropad = 0;
+    if (*f == '0') {
+        zeropad = 1;
+        f++;
+    }
 
     /* parse the width.precision part, e.g. "%2.5s" => width=2, precision=5 */
     width = 0;