X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fctype%2Ftolower.c;fp=functions%2Fctype%2Ftolower.c;h=28c435ded8377d125f49ece8b5a8c8b2767007d4;hb=5bcc00c1b85feff1996e3f34a1a9ebf3b624161e;hp=0000000000000000000000000000000000000000;hpb=68525aefa7b7b1f2f769e287e1f2f3a4585005ff;p=pdclib 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