Mercurial > hg > th-libs
changeset 568:2fbe42d957c4
Actually, partially revert the previous commit and unbreak the API. Leave
the format specifier code in a separate function tho, it's cleaner.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 08 Jan 2020 02:25:04 +0200 |
parents | b75f42ca08ef |
children | ccff3eb8dbb6 |
files | th_printf.c th_string.c th_string.h |
diffstat | 3 files changed, 9 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/th_printf.c Wed Jan 08 02:17:37 2020 +0200 +++ b/th_printf.c Wed Jan 08 02:25:04 2020 +0200 @@ -393,8 +393,7 @@ } -int th_vprintf_do(th_vprintf_ctx *ctx, th_vprintf_putch vputch, - th_vprintf_format vformat, const char *fmt, va_list ap) +int th_vprintf_do(th_vprintf_ctx *ctx, th_vprintf_putch vputch, const char *fmt, va_list ap) { int ret = 0; @@ -507,10 +506,11 @@ case 'j': case 'z': case 't': + // Unsupported for now return -202; } - ret = vformat(ctx, vputch, f_width, f_prec, f_flags, *fmt, ap); + ret = th_vprintf_do_format(ctx, vputch, f_width, f_prec, f_flags, *fmt, ap); if (ret == EOF) goto out; if (ret < 0)
--- a/th_string.c Wed Jan 08 02:17:37 2020 +0200 +++ b/th_string.c Wed Jan 08 02:25:04 2020 +0200 @@ -157,7 +157,7 @@ ctx.pos = 0; ctx.ipos = 0; - ret = th_vprintf_do(&ctx, th_pbuf_vputch, th_vprintf_do_format, fmt, ap); + ret = th_vprintf_do(&ctx, th_pbuf_vputch, fmt, ap); if (ctx.pos < size) buf[ctx.pos] = 0; @@ -205,7 +205,7 @@ ctx.pos = 0; ctx.ipos = 0; - return th_vprintf_do(&ctx, th_stdio_vputch, th_vprintf_do_format, fmt, ap); + return th_vprintf_do(&ctx, th_stdio_vputch, fmt, ap); #else return vfprintf(fh, fmt, ap); #endif @@ -226,7 +226,7 @@ ctx.pos = 0; ctx.ipos = 0; - ret = th_vprintf_do(&ctx, th_stdio_vputch, th_vprintf_do_format, fmt, ap); + ret = th_vprintf_do(&ctx, th_stdio_vputch, fmt, ap); #else ret = fprintf(fh, fmt, ap); #endif @@ -263,7 +263,7 @@ // Get size va_copy(ap, args); ctx.pos = 0; - th_vprintf_do(&ctx, th_pbuf_alloc_vputch1, th_vprintf_do_format, fmt, ap); + th_vprintf_do(&ctx, th_pbuf_alloc_vputch1, fmt, ap); va_end(ap); // Allocate memory @@ -273,7 +273,7 @@ va_copy(ap, args); ctx.pos = 0; - th_vprintf_do(&ctx, th_pbuf_alloc_vputch2, th_vprintf_do_format, fmt, ap); + th_vprintf_do(&ctx, th_pbuf_alloc_vputch2, fmt, ap); va_end(ap); ctx.buf[ctx.pos] = 0;
--- a/th_string.h Wed Jan 08 02:17:37 2020 +0200 +++ b/th_string.h Wed Jan 08 02:25:04 2020 +0200 @@ -88,14 +88,6 @@ typedef int (*th_vprintf_putch)(th_vprintf_ctx *ctx, const char ch); -/** @def formatting helper function typedef for internal printf() implementation - */ -typedef int (*th_vprintf_format)( - th_vprintf_ctx *ctx, th_vprintf_putch vputch, - int f_width, int f_prec, int f_flags, - const char fmt, va_list ap); - - /* Normal NUL-terminated string functions */ char *th_strdup(const char *src); @@ -136,8 +128,7 @@ 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, - th_vprintf_format vformat, const char *fmt, va_list ap); +int th_vprintf_do(th_vprintf_ctx *ctx, th_vprintf_putch vputch, const char *fmt, va_list ap); int th_vprintf_put_str(th_vprintf_ctx *ctx, th_vprintf_putch vputch, const char *str, int f_flags, const int f_width, const int f_prec);