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.
15 int vfprintf_unlocked( struct _PDCLIB_file_t * _PDCLIB_restrict stream,
16 const char * _PDCLIB_restrict format,
19 /* TODO: This function should interpret format as multibyte characters. */
20 struct _PDCLIB_status_t status;
29 status.stream = stream;
30 va_copy( status.arg, arg );
32 while ( *format != '\0' )
35 if ( ( *format != '%' ) || ( ( rc = _PDCLIB_print( format, &status ) ) == format ) )
37 /* No conversion specifier, print verbatim */
38 putc( *(format++), stream );
43 /* Continue parsing after conversion specifier */
51 int vfprintf( struct _PDCLIB_file_t * _PDCLIB_restrict stream,
52 const char * _PDCLIB_restrict format,
56 int r = vfprintf_unlocked( stream, format, arg );
57 funlockfile( stream );
64 #define _PDCLIB_FILEID "stdio/vfprintf.c"
65 #define _PDCLIB_FILEIO
67 #include <_PDCLIB_test.h>
69 static int testprintf( FILE * stream, const char * format, ... )
73 va_start( arg, format );
74 i = vfprintf( stream, format, arg );
82 TESTCASE( ( target = tmpfile() ) != NULL );
83 #include "printf_testcases.h"
84 TESTCASE( fclose( target ) == 0 );