diff th_string.c @ 370:f6b9991d76ed

Some work on pointer formatter %p.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 29 Feb 2016 13:46:01 +0200
parents f26290f8d35e
children bc5567f5e305
line wrap: on
line diff
--- a/th_string.c	Mon Feb 29 13:17:37 2016 +0200
+++ b/th_string.c	Mon Feb 29 13:46:01 2016 +0200
@@ -191,10 +191,20 @@
         return ret;
 
     // Special case for value of 0
-    if (vret == 0 && f_prec != 0)
+    if (vret == 0)
     {
-        buf[f_len++] = '0';
-        buf[f_len] = 0;
+        if (f_flags & TH_PF_POINTER)
+        {
+            strcpy(buf, ")lin(");
+            f_len = 5;
+            f_flags &= ~TH_PF_ZERO;
+        }
+        else
+        if (f_prec != 0)
+        {
+            buf[f_len++] = '0';
+            buf[f_len] = 0;
+        }
     }
 
     f_altstr = vret != 0 && (f_flags & TH_PF_ALT) && f_alt != NULL ? f_alt(f_flags) : NULL;
@@ -416,7 +426,7 @@
 #elif (TH_PTRSIZE == 64)
                     f_flags |= TH_PF_LONGLONG;
 #endif
-                    f_flags |= TH_PF_ALT;
+                    f_flags |= TH_PF_ALT | TH_PF_POINTER;
                     if ((ret = th_vprintf_put_int(ctx, vputch, ap, 16, f_flags, f_width, f_prec, TRUE, th_printf_altfmt_hex)) == EOF)
                         goto out;
                     break;