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 #include <_PDCLIB_io.h>
17 int _PDCLIB_vfprintf_unlocked( FILE * _PDCLIB_restrict stream,
18 const char * _PDCLIB_restrict format,
21 /* TODO: This function should interpret format as multibyte characters. */
22 struct _PDCLIB_status_t status;
31 status.stream = stream;
32 va_copy( status.arg, arg );
34 while ( *format != '\0' )
37 if ( ( *format != '%' ) || ( ( rc = _PDCLIB_print( format, &status ) ) == format ) )
39 /* No conversion specifier, print verbatim */
40 _PDCLIB_putc_unlocked( *(format++), stream );
45 /* Continue parsing after conversion specifier */
53 int vfprintf( FILE * _PDCLIB_restrict stream,
54 const char * _PDCLIB_restrict format,
57 _PDCLIB_flockfile( stream );
58 int r = _PDCLIB_vfprintf_unlocked( stream, format, arg );
59 _PDCLIB_funlockfile( stream );
66 #define _PDCLIB_FILEID "stdio/vfprintf.c"
67 #define _PDCLIB_FILEIO
69 #include <_PDCLIB_test.h>
71 static int testprintf( FILE * stream, const char * format, ... )
75 va_start( arg, format );
76 i = vfprintf( stream, format, arg );
84 TESTCASE( ( target = tmpfile() ) != NULL );
85 #include "printf_testcases.h"
86 TESTCASE( fclose( target ) == 0 );