1 /* vsscanf( const char *, const char *, va_list arg )
3 This file is part of the Public Domain C Library (PDCLib).
4 Permission is granted to use, modify, and / or redistribute at will.
12 #include <_PDCLIB_io.h>
14 int vsscanf( const char * _PDCLIB_restrict s,
15 const char * _PDCLIB_restrict format,
18 /* TODO: This function should interpret format as multibyte characters. */
19 struct _PDCLIB_status_t status;
25 status.s = (char *) s;
29 va_copy( status.arg, arg );
31 while ( *format != '\0' )
34 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 do not result in matching error */
41 while ( isspace( *status.s ) )
49 /* Non-whitespace char in format string: Match verbatim */
50 if ( *status.s != *format )
52 if ( *status.s == '\0' && status.n == 0 )
54 /* Early input error */
70 /* NULL return code indicates error */
73 if ( ( *status.s == '\n' ) && ( status.n == 0 ) )
79 /* Continue parsing after conversion specifier */
90 #define _PDCLIB_FILEID "stdio/vsscanf.c"
91 #define _PDCLIB_STRINGIO
93 #include <_PDCLIB_test.h>
95 static int testscanf( char const * stream, char const * format, ... )
98 va_start( ap, format );
99 int result = vsscanf( stream, format, ap );
107 #include "scanf_testcases.h"