X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstring%2Fstrlen.c;h=02d105cf0b8e1b697dfddb97af47c5b33ade8770;hb=2f57d79a5a24856fdea69b2119d67e5fb5029b3e;hp=ec0c21e7134a8c96edbac8b28d353c2592b1abdf;hpb=19b4cc9a30c2ede7a0cd6c417b5f26851376b708;p=pdclib diff --git a/functions/string/strlen.c b/functions/string/strlen.c index ec0c21e..02d105c 100644 --- a/functions/string/strlen.c +++ b/functions/string/strlen.c @@ -1,18 +1,33 @@ -// ---------------------------------------------------------------------------- -// $Id$ -// ---------------------------------------------------------------------------- -// Public Domain C Library - http://pdclib.sourceforge.net -// This code is Public Domain. Use, modify, and redistribute at will. -// ---------------------------------------------------------------------------- +/* $Id$ */ -#include <__size_t.h> +/* Release $Name$ */ -size_t strlen( const char * src ) +/* strlen( const char * ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +size_t strlen( const char * s ) { - size_t len = 0; - while ( src[len] != '\0' ) + size_t rc = 0; + while ( s[rc] ) { - ++len; + ++rc; } - return len; + return rc; +} + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main() +{ + BEGIN_TESTS; + TESTCASE( strlen( abcde ) == 5 ); + TESTCASE( strlen( "" ) == 0 ); + return TEST_RESULTS; } +#endif