* device/lib/printf_large.c: fixed bug 1193299
[fw/sdcc] / device / lib / printf_large.c
index 1dfb9bd6d2237aeeaf8ce368b262f51c28096955..e087f64d95f3873336d00b01c3ddda5fda90ba5d 100644 (file)
@@ -464,6 +464,10 @@ get_conversion_spec:
 #else
         length = strlen(PTR);
 #endif
+        if ( decimals == -1 )
+        {
+          decimals = length;
+        }
         if ( ( !left_justify ) && (length < width) )
         {
           width -= length;
@@ -474,7 +478,7 @@ get_conversion_spec:
           }
         }
 
-        while ( *PTR )
+        while ( *PTR  && (decimals-- > 0))
         {
           output_char( *PTR++, p );
           charsOutputted++;