changeset 547:c21051972015

Add int *prec and change int flags to int *flags in th_vprintf_altfmt_func function arguments.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 31 Dec 2019 05:22:15 +0200
parents edfe8ac12408
children 41efdd004c3a
files th_printf.c th_string.h
diffstat 2 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/th_printf.c	Tue Dec 31 05:19:11 2019 +0200
+++ b/th_printf.c	Tue Dec 31 05:22:15 2019 +0200
@@ -118,6 +118,7 @@
 {
     (void) vret;
     (void) flags;
+    (void) prec;
 
     return (buf[len - 1] != '0') ? "0" : NULL;
 }
@@ -127,9 +128,10 @@
 {
     (void) buf;
     (void) len;
+    (void) prec;
 
     if (vret != 0)
-        return (flags & TH_PF_UPCASE) ? "0X" : "0x";
+        return (*flags & TH_PF_UPCASE) ? "0X" : "0x";
     else
         return NULL;
 }
@@ -161,7 +163,7 @@
 
     // Get alternative format string, if needed and available
     f_altstr = (f_flags & TH_PF_ALT) && f_alt != NULL ?
-        f_alt(buf, f_len, vret, f_flags) : NULL;
+        f_alt(buf, f_len, vret, &f_prec, &f_flags) : NULL;
 
     // Are we using a sign prefix?
     f_sign = f_unsig ? 0 : ((f_flags & TH_PF_SIGN) ?
--- a/th_string.h	Tue Dec 31 05:19:11 2019 +0200
+++ b/th_string.h	Tue Dec 31 05:22:15 2019 +0200
@@ -122,10 +122,10 @@
 /* Internal printf() implementation. NOTICE! This API may be unstable.
  */
 #define TH_VPRINTF_ALTFMT_FUNC(fname) char * fname ( \
-    const char *buf, const size_t len, const int vret, const int flags)
+    const char *buf, const size_t len, const int vret, int *prec, int *flags)
 
 typedef char * (*th_vprintf_altfmt_func)(
-    const char *buf, const size_t len, const int vret, const int flags);
+    const char *buf, const size_t len, const int vret, int *prec, int *flags);
 
 
 int     th_vprintf_do(th_vprintf_ctx *ctx, th_vprintf_putch vputch, const char *fmt, va_list ap);