changeset 240:5e781dba6136

Some preparation for %f support .. if it ever happens.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 16 Feb 2016 16:10:41 +0200
parents 10f596441e75
children d0bf513f2118
files th_string.c
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/th_string.c	Tue Feb 16 16:01:32 2016 +0200
+++ b/th_string.c	Tue Feb 16 16:10:41 2016 +0200
@@ -241,7 +241,7 @@
         {
             char padMode = ' ', padChar = 0;
             BOOL sign = FALSE;
-            int width = 0;
+            int width = 0, prec = 0;
 
             fmt++;
 
@@ -269,6 +269,16 @@
             while (th_isdigit(*fmt))
                 width = width * 10 + (*fmt++ - '0');
 
+            if (*fmt == '.')
+            {
+                fmt++;
+                if (!th_isdigit(*fmt))
+                    goto out;
+
+                while (th_isdigit(*fmt))
+                    prec = prec * 10 + (*fmt++ - '0');
+            }
+
             switch (*fmt)
             {
                 case '%':
@@ -298,6 +308,7 @@
 
                 case 'f':
                     goto out;
+                    break;
 
                 case 's':
                     if ((padMode != '-' && padMode != ' ') || sign)