From 3cf39d63902bdbdff2450e542a80e103ceb34571 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Thu, 28 Feb 2019 15:33:03 -0500 Subject: implement in terms of __printf() --- src/stdio/snprintf.c | 12 ++++++++++++ src/stdio/vsnprintf.c | 10 +++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'src/stdio') 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 +#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 #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; } /* -- cgit v1.2.1