X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstring%2Fstrspn.c;fp=functions%2Fstring%2Fstrspn.c;h=d58ec9e46c996cf0d709d3207a00a4d2b2bfcce8;hb=d35060079d924391f4c36ab8b859bbfd7bb38ffe;hp=0000000000000000000000000000000000000000;hpb=152fbc0b4bdc5362c8d65c3cdac3bd68040be599;p=pdclib diff --git a/functions/string/strspn.c b/functions/string/strspn.c new file mode 100644 index 0000000..d58ec9e --- /dev/null +++ b/functions/string/strspn.c @@ -0,0 +1,35 @@ +/* $Id$ */ + +/* Release $Name$ */ + +/* strspn( const char *, 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 strspn( const char * s1, const char * s2 ) +{ + size_t len = 0; + const char * p; + while ( s1[ len ] ) + { + p = s2; + while ( *p ) + { + if ( s1[len] == *p ) + { + break; + } + ++p; + } + if ( ! *p ) + { + return len; + } + ++len; + } + return len; +}