1 /* vfscanf( FILE *, const char *, va_list )
3 This file is part of the Public Domain C Library (PDCLib).
4 Permission is granted to use, modify, and / or redistribute at will.
13 int vfscanf( FILE * _PDCLIB_restrict stream, const char * _PDCLIB_restrict format, va_list arg )
15 /* TODO: This function should interpret format as multibyte characters. */
16 struct _PDCLIB_status_t status;
25 status.stream = stream;
26 va_copy( status.arg, arg );
28 while ( *format != '\0' )
31 if ( ( *format != '%' ) || ( ( rc = _PDCLIB_scan( format, &status ) ) == format ) )
34 /* No conversion specifier, match verbatim */
35 if ( isspace( *format ) )
37 /* Whitespace char in format string: Skip all whitespaces */
38 /* No whitespaces in input does not result in matching error */
39 while ( isspace( c = getc( stream ) ) )
43 if ( ! feof( stream ) )
50 /* Non-whitespace char in format string: Match verbatim */
51 if ( ( ( c = getc( stream ) ) != *format ) || feof( stream ) )
54 if ( ! feof( stream ) && ! ferror( stream ) )
58 else if ( status.n == 0 )
73 /* NULL return code indicates matching error */
78 /* Continue parsing after conversion specifier */
89 #define _PDCLIB_FILEID "stdio/vfscanf.c"
90 #define _PDCLIB_FILEIO
92 #include "_PDCLIB_test.h"
94 static int testscanf( FILE * stream, char const * format, ... )
97 va_start( ap, format );
98 int result = vfscanf( stream, format, ap );
106 TESTCASE( ( source = tmpfile() ) != NULL );
107 #include "scanf_testcases.h"
108 TESTCASE( fclose( source ) == 0 );