3 /* vsscanf( const char *, const char *, va_list arg )
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 vsscanf( const char * _PDCLIB_restrict s,
16 const char * _PDCLIB_restrict format,
19 /* TODO: This function should interpret format as multibyte characters. */
20 struct _PDCLIB_status_t status;
26 status.s = (char *) s;
30 va_copy( status.arg, arg );
32 while ( *format != '\0' )
35 if ( ( *format != '%' ) || ( ( rc = _PDCLIB_scan( format, &status ) ) == format ) )
37 /* No conversion specifier, match verbatim */
38 if ( isspace( *format ) )
40 /* Whitespace char in format string: Skip all whitespaces */
41 /* No whitespaces in input do not result in matching error */
42 while ( isspace( *status.s ) )
50 /* Non-whitespace char in format string: Match verbatim */
51 if ( *status.s != *format )
53 if ( *status.s == '\0' && status.n == 0 )
55 /* Early input error */
71 /* NULL return code indicates error */
74 if ( ( *status.s == '\n' ) && ( status.n == 0 ) )
80 /* Continue parsing after conversion specifier */
91 #define _PDCLIB_FILEID "stdio/vsscanf.c"
92 #define _PDCLIB_STRINGIO
94 #include <_PDCLIB_test.h>
96 static int testscanf( char const * stream, char const * format, ... )
99 va_start( ap, format );
100 int result = vsscanf( stream, format, ap );
108 #include "scanf_testcases.h"