X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fctype%2Ftolower.c;fp=functions%2Fctype%2Ftolower.c;h=28c435ded8377d125f49ece8b5a8c8b2767007d4;hb=eb9211f1090ef05e8490a6b35acbe16c9ed9f89a;hp=0000000000000000000000000000000000000000;hpb=0058cd39ef8d38f4dece8c05e4c45619ab99d6f5;p=pdclib.old diff --git a/functions/ctype/tolower.c b/functions/ctype/tolower.c new file mode 100644 index 0000000..28c435d --- /dev/null +++ b/functions/ctype/tolower.c @@ -0,0 +1,37 @@ +/* $Id$ */ + +/* tolower( int ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +int tolower( int c ) +{ + if ( ( c >= 'A' ) && ( c <= 'Z' ) ) + { + c += ( 'a' - 'A' ); + } + return c; +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + TESTCASE( tolower( 'A' ) == 'a' ); + TESTCASE( tolower( 'Z' ) == 'z' ); + TESTCASE( tolower( 'a' ) == 'a' ); + TESTCASE( tolower( 'z' ) == 'z' ); + TESTCASE( tolower( '@' ) == '@' ); + TESTCASE( tolower( '[' ) == '[' ); + return TEST_RESULTS; +} +#endif