diff th_printf1.c @ 320:0362ea9872f0

Some work on sign handling.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 23 Feb 2016 01:42:34 +0200
parents f8c385739571
children 40ce4106f4ad
line wrap: on
line diff
--- a/th_printf1.c	Tue Feb 23 01:39:49 2016 +0200
+++ b/th_printf1.c	Tue Feb 23 01:42:34 2016 +0200
@@ -20,7 +20,7 @@
 {
     char buf[64];
     size_t pos = 0;
-    int ret = 0;
+    char f_sign = 0;
 #ifdef TH_PFUNC_SIGNED
     BOOL neg = FALSE;
 #endif
@@ -59,20 +59,11 @@
     // Do we want a sign prefix? Not for unsigned values
 #ifdef TH_PFUNC_SIGNED
     if (!unsig)
-    {
-        char ch = (f_flags & TH_PF_SIGN) ? (neg ? '-' : '+') : (neg ? '-' : ((f_flags & TH_PF_SPACE) ? ' ' : 0));
-        if (ch && (ret = vputch(ctx, ch)) == EOF)
-            goto out;
-    }
+        f_sign = (f_flags & TH_PF_SIGN) ? (neg ? '-' : '+') : (neg ? '-' : ((f_flags & TH_PF_SPACE) ? ' ' : 0));
 #endif
 
     // Output the data
-    return th_printf_vput_intstr(ctx, vputch, buf, f_width, pos, f_prec, f_flags);
-    
-#ifdef TH_PFUNC_SIGNED
-out:
-#endif
-    return ret;
+    return th_printf_vput_intstr(ctx, vputch, buf, f_width, pos, f_prec, f_flags, f_sign);
 }