andre@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ andre@0: /* This Source Code Form is subject to the terms of the Mozilla Public andre@0: * License, v. 2.0. If a copy of the MPL was not distributed with this andre@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ andre@0: andre@0: #include "plstr.h" andre@0: #include andre@0: andre@0: PR_IMPLEMENT(char *) andre@0: PL_strchr(const char *s, char c) andre@0: { andre@0: if( (const char *)0 == s ) return (char *)0; andre@0: andre@0: return strchr(s, c); andre@0: } andre@0: andre@0: PR_IMPLEMENT(char *) andre@0: PL_strrchr(const char *s, char c) andre@0: { andre@0: if( (const char *)0 == s ) return (char *)0; andre@0: andre@0: return strrchr(s, c); andre@0: } andre@0: andre@0: PR_IMPLEMENT(char *) andre@0: PL_strnchr(const char *s, char c, PRUint32 n) andre@0: { andre@0: if( (const char *)0 == s ) return (char *)0; andre@0: andre@0: for( ; n && *s; s++, n-- ) andre@0: if( *s == c ) andre@0: return (char *)s; andre@0: andre@0: if( ((char)0 == c) && (n > 0) && ((char)0 == *s) ) return (char *)s; andre@0: andre@0: return (char *)0; andre@0: } andre@0: andre@0: PR_IMPLEMENT(char *) andre@0: PL_strnrchr(const char *s, char c, PRUint32 n) andre@0: { andre@0: const char *p; andre@0: andre@0: if( (const char *)0 == s ) return (char *)0; andre@0: andre@0: for( p = s; n && *p; p++, n-- ) andre@0: ; andre@0: andre@0: if( ((char)0 == c) && (n > 0) && ((char)0 == *p) ) return (char *)p; andre@0: andre@0: for( p--; p >= s; p-- ) andre@0: if( *p == c ) andre@0: return (char *)p; andre@0: andre@0: return (char *)0; andre@0: }