# HG changeset patch # User Matti Hamalainen # Date 1456757374 -7200 # Node ID ff8a991fdb2d6748504422a4f8c0dbd31f2b6d6d # Parent 04a273cce4fad256ed0d477086fd11f7facc25bf Pass also numeric buffer and return value from th_printf_vbuf_int*() to altfmt helper functions. diff -r 04a273cce4fa -r ff8a991fdb2d th_string.c --- a/th_string.c Mon Feb 29 16:35:05 2016 +0200 +++ b/th_string.c Mon Feb 29 16:49:34 2016 +0200 @@ -169,7 +169,7 @@ static int th_vprintf_put_int(th_vprintf_ctx *ctx, th_vprintf_putch vputch, va_list ap, const int f_radix, int f_flags, int f_width, int f_prec, - const BOOL f_unsig, char *(f_alt)(const int flags)) + const BOOL f_unsig, char *(f_alt)(const char *buf, const int vret, const int flags)) { char buf[64]; int f_len = 0, ret = 0, vret, nwidth; @@ -207,7 +207,7 @@ } } - f_altstr = vret != 0 && (f_flags & TH_PF_ALT) && f_alt != NULL ? f_alt(f_flags) : NULL; + f_altstr = vret != 0 && (f_flags & TH_PF_ALT) && f_alt != NULL ? f_alt(buf, vret, f_flags) : NULL; // Are we using a sign prefix? f_sign = f_unsig ? 0 : ((f_flags & TH_PF_SIGN) ? @@ -300,15 +300,19 @@ } -static char * th_printf_altfmt_oct(const int flags) +static char * th_printf_altfmt_oct(const char *buf, const int vret, const int flags) { + (void) vret; (void) flags; - return "0"; + return (buf[0] != '0') ? "0" : ""; +; } -static char * th_printf_altfmt_hex(const int flags) +static char * th_printf_altfmt_hex(const char *buf, const int vret, const int flags) { + (void) buf; + (void) vret; return (flags & TH_PF_UPCASE) ? "0X" : "0x"; }