3 /* vfscanf( 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 vfscanf( FILE * _PDCLIB_restrict stream, const char * _PDCLIB_restrict format, va_list arg )
17 /* TODO: This function should interpret format as multibyte characters. */
18 struct _PDCLIB_status_t status;
27 status.stream = stream;
28 va_copy( status.arg, arg );
30 while ( *format != '\0' )
33 if ( ( *format != '%' ) || ( ( rc = _PDCLIB_scan( format, &status ) ) == format ) )
36 /* No conversion specifier, match verbatim */
37 if ( isspace( *format ) )
39 /* Whitespace char in format string: Skip all whitespaces */
40 /* No whitespaces in input does not result in matching error */
41 while ( isspace( c = getc( stream ) ) )
45 if ( ! feof( stream ) ) /* TODO: Check EOF status directly */
52 /* Non-whitespace char in format string: Match verbatim */
53 if ( ( ( c = getc( stream ) ) != *format ) || feof( stream ) ) /* TODO: Check EOF status directly */
56 if ( ! feof( stream ) && ! ferror( stream ) ) /* TODO: Check EOF status directly */
60 else if ( status.n == 0 )
75 /* NULL return code indicates matching error */
80 /* Continue parsing after conversion specifier */
91 #define _PDCLIB_FILEID "stdio/vfscanf.c"
92 #define _PDCLIB_FILEIO
94 #include <_PDCLIB_test.h>
96 static int testscanf( FILE * stream, char const * format, ... )
99 va_start( ap, format );
100 int result = vfscanf( stream, format, ap );
108 TESTCASE( ( source = tmpfile() ) != NULL );
109 #include "scanf_testcases.h"
110 TESTCASE( fclose( source ) == 0 );