X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fstring%2Fstrnlen.c;h=915fa76c0747cbe030b8c0d58dc275df4fe46a9b;hp=a4b5a9eadf134301a286bf4652b1e1537e5b5164;hb=abc15df6b9fae3374d24c7cf5c3ab94c605b2a6d;hpb=8894c921674bb116d0a7b8f23a55311e7a768019 diff --git a/functions/string/strnlen.c b/functions/string/strnlen.c index a4b5a9e..915fa76 100644 --- a/functions/string/strnlen.c +++ b/functions/string/strnlen.c @@ -1,36 +1,36 @@ -/* strnlen( const char *, size_t len ) - - This file is part of the Public Domain C Library (PDCLib). - Permission is granted to use, modify, and / or redistribute at will. -*/ - -#include -#include - -#ifndef REGTEST - -size_t strnlen( const char * s, size_t maxlen ) -{ - for( size_t len = 0; len != maxlen; len++ ) - { - if(s[len] == '\0') - return len; - } - return maxlen; -} - -#endif - -#ifdef TEST -#include "_PDCLIB_test.h" - -int main( void ) -{ -#ifndef REGTEST - TESTCASE( strnlen( abcde, 5 ) == 5 ); - TESTCASE( strnlen( abcde, 3 ) == 3 ) - TESTCASE( strnlen( "", SIZE_MAX ) == 0 ); -#endif - return TEST_RESULTS; -} -#endif +/* strnlen( const char *, size_t len ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include +#include + +#ifndef REGTEST + +size_t strnlen( const char * s, size_t maxlen ) +{ + for( size_t len = 0; len != maxlen; len++ ) + { + if(s[len] == '\0') + return len; + } + return maxlen; +} + +#endif + +#ifdef TEST +#include "_PDCLIB_test.h" + +int main( void ) +{ +#ifndef REGTEST + TESTCASE( strnlen( abcde, 5 ) == 5 ); + TESTCASE( strnlen( abcde, 3 ) == 3 ) + TESTCASE( strnlen( "", SIZE_MAX ) == 0 ); +#endif + return TEST_RESULTS; +} +#endif