From 62766425fe3a552440228c78f13a2c1dd62e228b Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Fri, 18 Dec 2015 21:57:14 +0100 Subject: o Functional and tested printf. --- tmp/printf/printf.c | 10 +++++----- tmp/printf/printf.h | 15 ++++++++++----- 2 files changed, 15 insertions(+), 10 deletions(-) (limited to 'tmp') diff --git a/tmp/printf/printf.c b/tmp/printf/printf.c index 3950a5f..f10f61f 100755 --- a/tmp/printf/printf.c +++ b/tmp/printf/printf.c @@ -105,9 +105,9 @@ static int a2d(char ch) else return -1; } -static char a2i(char ch, char** src,int base,int* nump) +static char a2i(char ch, const char** src,int base,int* nump) { - char* p= *src; + const char* p= *src; int num=0; int digit; while ((digit=a2d(ch))>=0) { @@ -133,7 +133,7 @@ static void putchw(void* putp,putcf putf,int n, char z, char* bf) putf(putp,ch); } -void tfp_format(void* putp,putcf putf,char *fmt, va_list va) +void tfp_format(void* putp,putcf putf,const char *fmt, va_list va) { char bf[12]; @@ -218,7 +218,7 @@ void init_printf(void* putp,void (*putf) (void*,char)) stdout_putp=putp; } -void tfp_printf(char *fmt, ...) +void tfp_printf(const char *fmt, ...) { va_list va; va_start(va,fmt); @@ -233,7 +233,7 @@ static void putcp(void* p,char c) -void tfp_sprintf(char* s,char *fmt, ...) +void tfp_sprintf(char* s,const char *fmt, ...) { va_list va; va_start(va,fmt); diff --git a/tmp/printf/printf.h b/tmp/printf/printf.h index 9723b0f..f697ea6 100755 --- a/tmp/printf/printf.h +++ b/tmp/printf/printf.h @@ -108,17 +108,22 @@ regs Kusti, 23.10.2004 #include +#ifdef __cplusplus +extern "C" { +#endif + void init_printf(void* putp,void (*putf) (void*,char)); -void tfp_printf(char *fmt, ...); -void tfp_sprintf(char* s,char *fmt, ...); +void tfp_printf(const char *fmt, ...); +void tfp_sprintf(char* s,const char *fmt, ...); -void tfp_format(void* putp,void (*putf) (void*,char),char *fmt, va_list va); +void tfp_format(void* putp,void (*putf) (void*,char),const char *fmt, va_list va); #define printf tfp_printf #define sprintf tfp_sprintf +#ifdef __cplusplus +}; #endif - - +#endif -- cgit v1.2.3