diff options
Diffstat (limited to 'nsprpub/lib/libc/src/strcase.c')
-rw-r--r-- | nsprpub/lib/libc/src/strcase.c | 80 |
1 files changed, 56 insertions, 24 deletions
diff --git a/nsprpub/lib/libc/src/strcase.c b/nsprpub/lib/libc/src/strcase.c index ad542587b..f1ab038cd 100644 --- a/nsprpub/lib/libc/src/strcase.c +++ b/nsprpub/lib/libc/src/strcase.c @@ -48,10 +48,12 @@ PL_strcasecmp(const char *a, const char *b) const unsigned char *ua = (const unsigned char *)a; const unsigned char *ub = (const unsigned char *)b; - if( (const char *)0 == a ) + if( (const char *)0 == a ) { return ((const char *)0 == b) ? 0 : -1; - if( (const char *)0 == b ) + } + if( (const char *)0 == b ) { return 1; + } while( (uc[*ua] == uc[*ub]) && ('\0' != *a) ) { @@ -69,10 +71,12 @@ PL_strncasecmp(const char *a, const char *b, PRUint32 max) const unsigned char *ua = (const unsigned char *)a; const unsigned char *ub = (const unsigned char *)b; - if( (const char *)0 == a ) + if( (const char *)0 == a ) { return ((const char *)0 == b) ? 0 : -1; - if( (const char *)0 == b ) + } + if( (const char *)0 == b ) { return 1; + } while( max && (uc[*ua] == uc[*ub]) && ('\0' != *a) ) { @@ -82,7 +86,9 @@ PL_strncasecmp(const char *a, const char *b, PRUint32 max) max--; } - if( 0 == max ) return (PRIntn)0; + if( 0 == max ) { + return (PRIntn)0; + } return (PRIntn)(uc[*ua] - uc[*ub]); } @@ -92,15 +98,20 @@ PL_strcasestr(const char *big, const char *little) { PRUint32 ll; - if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0; - if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0; + if( ((const char *)0 == big) || ((const char *)0 == little) ) { + return (char *)0; + } + if( ((char)0 == *big) || ((char)0 == *little) ) { + return (char *)0; + } ll = strlen(little); for( ; *big; big++ ) /* obvious improvement available here */ - if( 0 == PL_strncasecmp(big, little, ll) ) - return (char *)big; + if( 0 == PL_strncasecmp(big, little, ll) ) { + return (char *)big; + } return (char *)0; } @@ -111,18 +122,25 @@ PL_strcaserstr(const char *big, const char *little) const char *p; PRUint32 bl, ll; - if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0; - if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0; + if( ((const char *)0 == big) || ((const char *)0 == little) ) { + return (char *)0; + } + if( ((char)0 == *big) || ((char)0 == *little) ) { + return (char *)0; + } bl = strlen(big); ll = strlen(little); - if( bl < ll ) return (char *)0; + if( bl < ll ) { + return (char *)0; + } p = &big[ bl - ll ]; for( ; p >= big; p-- ) /* obvious improvement available here */ - if( 0 == PL_strncasecmp(p, little, ll) ) - return (char *)p; + if( 0 == PL_strncasecmp(p, little, ll) ) { + return (char *)p; + } return (char *)0; } @@ -132,18 +150,25 @@ PL_strncasestr(const char *big, const char *little, PRUint32 max) { PRUint32 ll; - if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0; - if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0; + if( ((const char *)0 == big) || ((const char *)0 == little) ) { + return (char *)0; + } + if( ((char)0 == *big) || ((char)0 == *little) ) { + return (char *)0; + } ll = strlen(little); - if( ll > max ) return (char *)0; + if( ll > max ) { + return (char *)0; + } max -= ll; max++; for( ; max && *big; big++, max-- ) /* obvious improvement available here */ - if( 0 == PL_strncasecmp(big, little, ll) ) - return (char *)big; + if( 0 == PL_strncasecmp(big, little, ll) ) { + return (char *)big; + } return (char *)0; } @@ -154,8 +179,12 @@ PL_strncaserstr(const char *big, const char *little, PRUint32 max) const char *p; PRUint32 ll; - if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0; - if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0; + if( ((const char *)0 == big) || ((const char *)0 == little) ) { + return (char *)0; + } + if( ((char)0 == *big) || ((char)0 == *little) ) { + return (char *)0; + } ll = strlen(little); @@ -163,12 +192,15 @@ PL_strncaserstr(const char *big, const char *little, PRUint32 max) ; p -= ll; - if( p < big ) return (char *)0; + if( p < big ) { + return (char *)0; + } for( ; p >= big; p-- ) /* obvious improvement available here */ - if( 0 == PL_strncasecmp(p, little, ll) ) - return (char *)p; + if( 0 == PL_strncasecmp(p, little, ll) ) { + return (char *)p; + } return (char *)0; } |