Reworked scanf() testing. General cleanups.
[fw/pdclib] / functions / stdio / scanf.c
1 /* $Id$ */
2
3 /* scanf( const char *, ... )
4
5    This file is part of the Public Domain C Library (PDCLib).
6    Permission is granted to use, modify, and / or redistribute at will.
7 */
8
9 #include <stdio.h>
10 #include <stdarg.h>
11
12 #ifndef REGTEST
13
14 int scanf( const char * _PDCLIB_restrict format, ... )
15 {
16     va_list ap;
17     va_start( ap, format );
18     return vfscanf( stdin, format, ap );
19 }
20
21 #endif
22
23 #ifdef TEST
24 #define _PDCLIB_FILEID "stdio/scanf.c"
25 #define _PDCLIB_FILEIO
26
27 #include <_PDCLIB_test.h>
28
29 #define testscanf( stream, format, ... ) scanf( format, __VA_ARGS__ )
30
31 int main( void )
32 {
33     FILE * source;
34     TESTCASE( ( source = freopen( testfile, "wb+", stdin ) ) != NULL );
35 #include "scanf_testcases.h"
36     TESTCASE( fclose( source ) == 0 );
37     TESTCASE( remove( testfile ) == 0 );
38     return TEST_RESULTS;
39 }
40
41 #endif