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.
14 #include <_PDCLIB_io.h>
16 int vsscanf( const char * _PDCLIB_restrict s,
17 const char * _PDCLIB_restrict format,
20 /* TODO: This function should interpret format as multibyte characters. */
21 struct _PDCLIB_status_t status;
27 status.s = (char *) s;
31 va_copy( status.arg, arg );
33 while ( *format != '\0' )
36 if ( ( *format != '%' ) || ( ( rc = _PDCLIB_scan( format, &status ) ) == format ) )
38 /* No conversion specifier, match verbatim */
39 if ( isspace( *format ) )
41 /* Whitespace char in format string: Skip all whitespaces */
42 /* No whitespaces in input do not result in matching error */
43 while ( isspace( *status.s ) )
51 /* Non-whitespace char in format string: Match verbatim */
52 if ( *status.s != *format )
54 if ( *status.s == '\0' && status.n == 0 )
56 /* Early input error */
72 /* NULL return code indicates error */
75 if ( ( *status.s == '\n' ) && ( status.n == 0 ) )
81 /* Continue parsing after conversion specifier */
92 #define _PDCLIB_FILEID "stdio/vsscanf.c"
93 #define _PDCLIB_STRINGIO
95 #include <_PDCLIB_test.h>
97 static int testscanf( char const * stream, char const * format, ... )
100 va_start( ap, format );
101 int result = vsscanf( stream, format, ap );
109 #include "scanf_testcases.h"