X-Git-Url: https://pd.if.org/git/?p=pdclib.old;a=blobdiff_plain;f=functions%2Fstdio%2Fvsnprintf.c;fp=functions%2Fstdio%2Fvsnprintf.c;h=84ad51dc462d41a7e14c4b4a747a3ec076e1d2dc;hp=08f235530a68a8b843e53c06422bef19146b746a;hb=42e018009a78cdddd97fd18d2b6bb02d8e0fe16e;hpb=4045c52731204268642130c247afffb91f958293 diff --git a/functions/stdio/vsnprintf.c b/functions/stdio/vsnprintf.c index 08f2355..84ad51d 100644 --- a/functions/stdio/vsnprintf.c +++ b/functions/stdio/vsnprintf.c @@ -11,11 +11,27 @@ #ifndef REGTEST -int vsnprintf( char * str, size_t size, const char * format, _PDCLIB_va_list arg ) +int vsnprintf( char * s, size_t n, const char * format, _PDCLIB_va_list arg ) { - /* TODO: This function should interpret format as multibyte characters. */ - /* TODO: Implement */ - return 0; + /* TODO: This function should interpret format as multibyte characters. */ + /* Members: base, flags, n, i, this, s, width, prec, stream, arg */ + struct _PDCLIB_status_t status = { 0, 0, n, 0, 0, s, 0, 0, NULL, arg }; + while ( *format != '\0' ) + { + const char * rc; + if ( ( *format != '%' ) || ( ( rc = _PDCLIB_print( format, &status ) ) == format ) ) + { + /* No conversion specifier, print verbatim */ + s[ status.i++ ] = *(format++); + } + else + { + /* Continue parsing after conversion specifier */ + format = rc; + } + } + s[ status.i ] = '\0'; + return status.i; } #endif