pabru / picoc

Automatically exported from code.google.com/p/picoc
0 stars 0 forks source link

Printf bug: %02d #172

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. printf("%02d:%02d", 1, 2);

What is the expected output? What do you see instead?
Expected: 01:02
I get 01:0000000000002 (22 digits on the second field)

What version of the product are you using? On what operating system?
2.1 release, BUILTIN_MINI_STDLIB, full source code at 
http://bitbucket.org/hudson/magic-lantern/src/tip/picoc/

Please provide any additional information below.

Fix:

@@ -241,6 +241,7 @@
         if (*FPos == '%')
         {
             FPos++;
+            FieldWidth = 0; // fix for %02d:%02d
             if (*FPos == '-')
             {
                 /* a leading '-' means left justify */

Original issue reported on code.google.com by broscuta...@gmail.com on 14 Jan 2013 at 2:45

GoogleCodeExporter commented 9 years ago
Nice find.

Fixed in r584.

Original comment by zik.sale...@gmail.com on 14 Jan 2013 at 10:09