# HG changeset patch # User Matti Hamalainen # Date 1456174365 -7200 # Node ID 7bce1e9fa3973e6725077514ef9a079e90c0a74c # Parent d6a9db84d702485985b808ea4226acbca333778a Add f_prec arguments to helpers and call points. diff -r d6a9db84d702 -r 7bce1e9fa397 th_printf1.c --- a/th_printf1.c Mon Feb 22 22:51:24 2016 +0200 +++ b/th_printf1.c Mon Feb 22 22:52:45 2016 +0200 @@ -12,8 +12,8 @@ #else TH_PFUNC_TYPE_U val, #endif - const int radix, const int f_flags, - const int f_width, const BOOL unsig, const BOOL upcase) + const int radix, const int f_flags, const int f_width, const int f_prec, + const BOOL unsig, const BOOL upcase) { char buf[64]; size_t pos = 0; @@ -66,7 +66,7 @@ #endif // Output the data - return th_printf_vput_intstr(ctx, vputch, buf, f_width, pos, f_flags); + return th_printf_vput_intstr(ctx, vputch, buf, f_width, pos, f_prec, f_flags); #ifdef TH_PFUNC_SIGNED out: diff -r d6a9db84d702 -r 7bce1e9fa397 th_string.c --- a/th_string.c Mon Feb 22 22:51:24 2016 +0200 +++ b/th_string.c Mon Feb 22 22:52:45 2016 +0200 @@ -159,7 +159,7 @@ int th_printf_vput_intstr(th_printf_ctx *ctx, th_printf_vputch vputch, - const char *buf, const int f_width, int pos, const int f_flags) + const char *buf, const int f_width, int pos, int f_prec, int f_flags) { // Calculate necessary padding, if any int ret, nwidth = f_width - pos; @@ -200,7 +200,7 @@ static int th_printf_vput_str(th_printf_ctx *ctx, th_printf_vputch vputch, - const char *str, const int f_flags, const int f_width, const int f_prec) + const char *str, int f_flags, const int f_width, const int f_prec) { int nwidth, ret = 0; @@ -242,7 +242,7 @@ } else { - int f_width = 0, f_prec = 1, f_flags = 0; + int f_width = 0, f_prec = -1, f_flags = 0; BOOL end = FALSE; fmt++; @@ -327,7 +327,7 @@ case 'o': if ((ret = th_printf_vput_int(ctx, vputch, va_arg(ap, unsigned int), - 8, f_flags, f_width, FALSE, FALSE)) == EOF) + 8, f_flags, f_width, f_prec, TRUE, FALSE)) == EOF) goto out; break; @@ -335,25 +335,25 @@ case 'i': case 'd': if ((ret = th_printf_vput_int(ctx, vputch, va_arg(ap, unsigned int), - 10, f_flags, f_width, *fmt == 'u', FALSE)) == EOF) + 10, f_flags, f_width, f_prec, *fmt == 'u', FALSE)) == EOF) goto out; break; case 'x': case 'X': if ((ret = th_printf_vput_int(ctx, vputch, va_arg(ap, unsigned int), - 16, f_flags, f_width, TRUE, *fmt == 'X')) == EOF) + 16, f_flags, f_width, f_prec, TRUE, *fmt == 'X')) == EOF) goto out; break; case 'p': #if (TH_PTRSIZE == 32) if ((ret = th_printf_vput_int(ctx, vputch, (int32_t) va_arg(ap, void *), - 16, f_flags, f_width, TRUE, FALSE)) == EOF) + 16, f_flags, f_width, f_prec, TRUE, FALSE)) == EOF) goto out; #elif (TH_PTRSIZE == 64) if ((ret = th_printf_vput_int64(ctx, vputch, (int64_t) va_arg(ap, void *), - 16, f_flags, f_width, TRUE, FALSE)) == EOF) + 16, f_flags, f_width, f_prec, TRUE, FALSE)) == EOF) goto out; #else # error TH_PTRSIZE not defined