Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "plstr.h" |
michael@0 | 7 | #include <string.h> |
michael@0 | 8 | |
michael@0 | 9 | PR_IMPLEMENT(char *) |
michael@0 | 10 | PL_strpbrk(const char *s, const char *list) |
michael@0 | 11 | { |
michael@0 | 12 | if( ((const char *)0 == s) || ((const char *)0 == list) ) return (char *)0; |
michael@0 | 13 | |
michael@0 | 14 | return strpbrk(s, list); |
michael@0 | 15 | } |
michael@0 | 16 | |
michael@0 | 17 | PR_IMPLEMENT(char *) |
michael@0 | 18 | PL_strprbrk(const char *s, const char *list) |
michael@0 | 19 | { |
michael@0 | 20 | const char *p; |
michael@0 | 21 | const char *r; |
michael@0 | 22 | |
michael@0 | 23 | if( ((const char *)0 == s) || ((const char *)0 == list) ) return (char *)0; |
michael@0 | 24 | |
michael@0 | 25 | for( r = s; *r; r++ ) |
michael@0 | 26 | ; |
michael@0 | 27 | |
michael@0 | 28 | for( r--; r >= s; r-- ) |
michael@0 | 29 | for( p = list; *p; p++ ) |
michael@0 | 30 | if( *r == *p ) |
michael@0 | 31 | return (char *)r; |
michael@0 | 32 | |
michael@0 | 33 | return (char *)0; |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | PR_IMPLEMENT(char *) |
michael@0 | 37 | PL_strnpbrk(const char *s, const char *list, PRUint32 max) |
michael@0 | 38 | { |
michael@0 | 39 | const char *p; |
michael@0 | 40 | |
michael@0 | 41 | if( ((const char *)0 == s) || ((const char *)0 == list) ) return (char *)0; |
michael@0 | 42 | |
michael@0 | 43 | for( ; max && *s; s++, max-- ) |
michael@0 | 44 | for( p = list; *p; p++ ) |
michael@0 | 45 | if( *s == *p ) |
michael@0 | 46 | return (char *)s; |
michael@0 | 47 | |
michael@0 | 48 | return (char *)0; |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | PR_IMPLEMENT(char *) |
michael@0 | 52 | PL_strnprbrk(const char *s, const char *list, PRUint32 max) |
michael@0 | 53 | { |
michael@0 | 54 | const char *p; |
michael@0 | 55 | const char *r; |
michael@0 | 56 | |
michael@0 | 57 | if( ((const char *)0 == s) || ((const char *)0 == list) ) return (char *)0; |
michael@0 | 58 | |
michael@0 | 59 | for( r = s; max && *r; r++, max-- ) |
michael@0 | 60 | ; |
michael@0 | 61 | |
michael@0 | 62 | for( r--; r >= s; r-- ) |
michael@0 | 63 | for( p = list; *p; p++ ) |
michael@0 | 64 | if( *r == *p ) |
michael@0 | 65 | return (char *)r; |
michael@0 | 66 | |
michael@0 | 67 | return (char *)0; |
michael@0 | 68 | } |