changeset 277:7450d744e633

Rename internal functions and add a typedef for function pointer used for vputch().
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 22 Feb 2016 11:47:54 +0200
parents 56b0de9f9d44
children a6088507317b
files th_string.c th_string.h
diffstat 2 files changed, 9 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/th_string.c	Wed Feb 17 17:24:02 2016 +0200
+++ b/th_string.c	Mon Feb 22 11:47:54 2016 +0200
@@ -124,7 +124,7 @@
 //
 // Simple implementations of printf() type functions
 //
-static int th_vput_int(th_printf_ctx *ctx, int (*vputch)(th_printf_ctx *ctx, const char ch),
+static int th_printf_vput_int(th_printf_ctx *ctx, th_printf_vputch vputch,
     int pval, const int radix, const char padMode, const char padChar,
     const int width, const BOOL unsig, const BOOL upcase, const BOOL sign)
 {
@@ -205,7 +205,7 @@
 }
 
 
-static int th_vput_str(th_printf_ctx *ctx, int (*vputch)(th_printf_ctx *ctx, const char ch),
+static int th_printf_vput_str(th_printf_ctx *ctx, th_printf_vputch vputch,
     const char *str, const char padMode, const char padChar,
     const int width, const int prec)
 {
@@ -248,9 +248,7 @@
 }
 
 
-int th_vprintf_do(th_printf_ctx *ctx,
-    int (*vputch)(th_printf_ctx *ctx, const char ch),
-    const char *fmt, va_list ap)
+int th_vprintf_do(th_printf_ctx *ctx, th_printf_vputch vputch, const char *fmt, va_list ap)
 {
     int ret = 0;
 
@@ -326,7 +324,7 @@
                     if ((padMode != '0' && padMode != '-' && padMode != ' ') || prec >= 0)
                         return -105;
 
-                    if ((ret = th_vput_int(ctx, vputch, va_arg(ap, unsigned int),
+                    if ((ret = th_printf_vput_int(ctx, vputch, va_arg(ap, unsigned int),
                         10, padMode, padChar, width, *fmt == 'u', FALSE, sign)) == EOF)
                         goto out;
                     break;
@@ -336,7 +334,7 @@
                     if ((padMode != '0' && padMode != '-' && padMode != ' ') || prec >= 0)
                         return -106;
 
-                    if ((ret = th_vput_int(ctx, vputch, va_arg(ap, unsigned int),
+                    if ((ret = th_printf_vput_int(ctx, vputch, va_arg(ap, unsigned int),
                         16, padMode, padChar, width, TRUE, *fmt == 'X', FALSE)) == EOF)
                         goto out;
                     break;
@@ -349,7 +347,7 @@
                     if ((padMode != '-' && padMode != ' ') || sign)
                         return -108;
 
-                    if ((ret = th_vput_str(ctx, vputch, va_arg(ap, char *), padMode, padChar, width, prec)) == EOF)
+                    if ((ret = th_printf_vput_str(ctx, vputch, va_arg(ap, char *), padMode, padChar, width, prec)) == EOF)
                         goto out;
                     break;
 
--- a/th_string.h	Wed Feb 17 17:24:02 2016 +0200
+++ b/th_string.h	Mon Feb 22 11:47:54 2016 +0200
@@ -56,6 +56,9 @@
 } th_printf_ctx;
 
 
+typedef int (*th_printf_vputch)(th_printf_ctx *ctx, const char ch);
+
+
 /* Normal NUL-terminated string functions
  */
 size_t   th_strlen(const char *str);