X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2F_PDCLIB%2Ffilemode.c;h=454810626d74a616dc47a75380487a2976560033;hb=cc343a7e1383e2f6b8309cb7cb36ab8250586cb4;hp=0e293aba2cfc55a6a4f1487b569b20efb8cd70c7;hpb=0d54a75af25ca44411e7c4190cc2a93a390e61a2;p=pdclib.old diff --git a/functions/_PDCLIB/filemode.c b/functions/_PDCLIB/filemode.c index 0e293ab..4548106 100644 --- a/functions/_PDCLIB/filemode.c +++ b/functions/_PDCLIB/filemode.c @@ -8,12 +8,15 @@ #include +#ifndef REGTEST /* Helper function that parses the C-style mode string passed to fopen() into the PDCLib flags FREAD, FWRITE, FAPPEND, FRW (read-write) and FBIN (binary mode). */ unsigned int _PDCLIB_filemode( char const * const mode ) { + if(!mode) return 0; + unsigned rc = 0; switch ( mode[0] ) { @@ -53,12 +56,14 @@ unsigned int _PDCLIB_filemode( char const * const mode ) /* Longer than three chars - invalid. */ return 0; } +#endif #ifdef TEST #include <_PDCLIB_test.h> int main( void ) { +#ifndef REGTEST TESTCASE( _PDCLIB_filemode( "r" ) == _PDCLIB_FREAD ); TESTCASE( _PDCLIB_filemode( "w" ) == _PDCLIB_FWRITE ); TESTCASE( _PDCLIB_filemode( "a" ) == ( _PDCLIB_FAPPEND | _PDCLIB_FWRITE ) ); @@ -78,6 +83,7 @@ int main( void ) TESTCASE( _PDCLIB_filemode( "r++" ) == 0 ); TESTCASE( _PDCLIB_filemode( "wbb" ) == 0 ); TESTCASE( _PDCLIB_filemode( "a+bx" ) == 0 ); +#endif return TEST_RESULTS; }