diff th_string.c @ 320:0362ea9872f0

Some work on sign handling.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 23 Feb 2016 01:42:34 +0200
parents c532088b4f05
children f7d72b7bebf3
line wrap: on
line diff
--- a/th_string.c	Tue Feb 23 01:39:49 2016 +0200
+++ b/th_string.c	Tue Feb 23 01:42:34 2016 +0200
@@ -159,11 +159,15 @@
 
 
 int th_printf_vput_intstr(th_printf_ctx *ctx, th_printf_vputch vputch,
-    const char *buf, const int f_width, int pos, int f_prec, int f_flags)
+    const char *buf, const int f_width, int pos, int f_prec, int f_flags,
+    const char f_sign)
 {
     // Calculate necessary padding, if any
     int ret, nwidth = f_width - pos;
 
+    if (f_sign)
+        nwidth--;
+
     if (f_prec > 0 && f_prec > pos)
     {
         nwidth = nwidth - f_prec + 1;
@@ -174,6 +178,9 @@
     if ((ret = th_printf_pad_pre(ctx, vputch, nwidth, f_flags)) == EOF)
         return ret;
 
+    if (f_sign && (ret = vputch(ctx, f_sign)) == EOF)
+        return ret;
+
     if (f_prec > 0 && f_prec > pos)
     {
         while (--f_prec)