3 /* vfprintf( FILE *, const char *, va_list )
5 This file is part of the Public Domain C Library (PDCLib).
6 Permission is granted to use, modify, and / or redistribute at will.
16 int vfprintf_unlocked( struct _PDCLIB_file_t * _PDCLIB_restrict stream,
17 const char * _PDCLIB_restrict format,
20 /* TODO: This function should interpret format as multibyte characters. */
21 struct _PDCLIB_status_t status;
30 status.stream = stream;
31 va_copy( status.arg, arg );
33 while ( *format != '\0' )
36 if ( ( *format != '%' ) || ( ( rc = _PDCLIB_print( format, &status ) ) == format ) )
38 /* No conversion specifier, print verbatim */
39 putc( *(format++), stream );
44 /* Continue parsing after conversion specifier */
52 int vfprintf( struct _PDCLIB_file_t * _PDCLIB_restrict stream,
53 const char * _PDCLIB_restrict format,
57 int r = vfprintf_unlocked( stream, format, arg );
58 funlockfile( stream );
65 #define _PDCLIB_FILEID "stdio/vfprintf.c"
66 #define _PDCLIB_FILEIO
68 #include <_PDCLIB_test.h>
70 static int testprintf( FILE * stream, const char * format, ... )
74 va_start( arg, format );
75 i = vfprintf( stream, format, arg );
83 TESTCASE( ( target = tmpfile() ) != NULL );
84 #include "printf_testcases.h"
85 TESTCASE( fclose( target ) == 0 );