3 /* vsnprintf( char *, size_t, const char *, va_list ap )
5 This file is part of the Public Domain C Library (PDCLib).
6 Permission is granted to use, modify, and / or redistribute at will.
14 int vsnprintf( char * _PDCLIB_restrict s, size_t n, const char * _PDCLIB_restrict format, _PDCLIB_va_list arg )
16 /* TODO: This function should interpret format as multibyte characters. */
17 struct _PDCLIB_status_t status;
27 va_copy( status.arg, arg );
29 while ( *format != '\0' )
32 if ( ( *format != '%' ) || ( ( rc = _PDCLIB_print( format, &status ) ) == format ) )
34 /* No conversion specifier, print verbatim */
35 s[ status.i++ ] = *(format++);
39 /* Continue parsing after conversion specifier */
51 #include <_PDCLIB_test.h>
57 static int testprintf( char * s, const char * format, ... )
61 va_start( arg, format );
62 i = vsnprintf( s, 100, format, arg );
67 #define TESTCASE_SPRINTF( x ) if ( strcmp( target, x ) == 0 ) {} \
68 else { TEST_RESULTS += 1; printf( "FAILED: " __FILE__ ", line %d - \"%s\" != %s\n", __LINE__, target, #x ); }
73 #include "printf_testcases.incl"