diff options
| author | Jakob Kaivo <jkk@ung.org> | 2019-02-28 15:33:03 -0500 |
|---|---|---|
| committer | Jakob Kaivo <jkk@ung.org> | 2019-02-28 15:33:03 -0500 |
| commit | 3cf39d63902bdbdff2450e542a80e103ceb34571 (patch) | |
| tree | 14adb95c65ebea7ea3f796a2c48ac6cf64987733 /src | |
| parent | a7b88fa1dacaf822fb0b12c62705eff45d551bc7 (diff) | |
implement in terms of __printf()
Diffstat (limited to 'src')
| -rw-r--r-- | src/stdio/snprintf.c | 12 | ||||
| -rw-r--r-- | src/stdio/vsnprintf.c | 10 | ||||
| -rw-r--r-- | src/wchar/vfwprintf.c | 2 |
3 files changed, 22 insertions, 2 deletions
diff --git a/src/stdio/snprintf.c b/src/stdio/snprintf.c index bc6df080..acf234b1 100644 --- a/src/stdio/snprintf.c +++ b/src/stdio/snprintf.c @@ -1,7 +1,19 @@ #include <stdio.h> +#include "stdarg.h" +#include "nonstd/io.h" int snprintf(char * restrict s, size_t n, const char * restrict format, ...) { + int ret = 0; + va_list ap; + struct io_options opt = {0}; + opt.fnname = __func__; + opt.string = s; + opt.maxlen = n; + va_start(ap, format); + ret = __printf(&opt, format, ap); + va_end(ap); + return ret; } /* diff --git a/src/stdio/vsnprintf.c b/src/stdio/vsnprintf.c index 7c5a1e03..f54a15a1 100644 --- a/src/stdio/vsnprintf.c +++ b/src/stdio/vsnprintf.c @@ -1,8 +1,16 @@ #include <stdio.h> #include "stdarg.h" +#include "nonstd/io.h" -int vsnprintf(char * restrict s, size_t n, va_list ap) +int vsnprintf(char * restrict s, size_t n, const char *format, va_list arg) { + int ret = 0; + struct io_options opt = {0}; + opt.fnname = "fprintf"; + opt.string = s; + opt.maxlen = n; + ret = __printf(&opt, format, arg); + return ret; } /* diff --git a/src/wchar/vfwprintf.c b/src/wchar/vfwprintf.c index 55662dff..df9ab381 100644 --- a/src/wchar/vfwprintf.c +++ b/src/wchar/vfwprintf.c @@ -10,7 +10,7 @@ int vfwprintf(FILE * restrict stream, const wchar_t * restrict format, va_list a struct io_options opt = {0}; opt.fnname = "vfwprintf"; opt.stream = stream; - ret = __printf(&opt, NULL /* format */, arg); + ret = __printf(&opt, (const char*)format, arg); return ret; } |
