summaryrefslogtreecommitdiffstats
path: root/nsprpub/lib/libc/src/strstr.c
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2020-01-02 21:01:38 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-01-02 21:01:38 +0100
commitf7d30133221896638f7bf4f66c504255c4b14f48 (patch)
tree5f3e07a049f388a3a309a615b8884318f6668a98 /nsprpub/lib/libc/src/strstr.c
parent26b297510a11758727438df4669357a2a2bc42ce (diff)
downloadUXP-f7d30133221896638f7bf4f66c504255c4b14f48.tar
UXP-f7d30133221896638f7bf4f66c504255c4b14f48.tar.gz
UXP-f7d30133221896638f7bf4f66c504255c4b14f48.tar.lz
UXP-f7d30133221896638f7bf4f66c504255c4b14f48.tar.xz
UXP-f7d30133221896638f7bf4f66c504255c4b14f48.zip
Issue #1338 - Part 1: Update NSPR to 4.24
Diffstat (limited to 'nsprpub/lib/libc/src/strstr.c')
-rw-r--r--nsprpub/lib/libc/src/strstr.c53
1 files changed, 39 insertions, 14 deletions
diff --git a/nsprpub/lib/libc/src/strstr.c b/nsprpub/lib/libc/src/strstr.c
index a90d8226d..dd27a23ee 100644
--- a/nsprpub/lib/libc/src/strstr.c
+++ b/nsprpub/lib/libc/src/strstr.c
@@ -9,8 +9,12 @@
PR_IMPLEMENT(char *)
PL_strstr(const char *big, const char *little)
{
- 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;
+ }
return strstr(big, little);
}
@@ -22,18 +26,25 @@ PL_strrstr(const char *big, const char *little)
size_t ll;
size_t bl;
- 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);
bl = strlen(big);
- if( bl < ll ) return (char *)0;
+ if( bl < ll ) {
+ return (char *)0;
+ }
p = &big[ bl - ll ];
for( ; p >= big; p-- )
if( *little == *p )
- if( 0 == strncmp(p, little, ll) )
+ if( 0 == strncmp(p, little, ll) ) {
return (char *)p;
+ }
return (char *)0;
}
@@ -43,18 +54,25 @@ PL_strnstr(const char *big, const char *little, PRUint32 max)
{
size_t 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 > (size_t)max ) return (char *)0;
+ if( ll > (size_t)max ) {
+ return (char *)0;
+ }
max -= (PRUint32)ll;
max++;
for( ; max && *big; big++, max-- )
if( *little == *big )
- if( 0 == strncmp(big, little, ll) )
+ if( 0 == strncmp(big, little, ll) ) {
return (char *)big;
+ }
return (char *)0;
}
@@ -65,8 +83,12 @@ PL_strnrstr(const char *big, const char *little, PRUint32 max)
const char *p;
size_t 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);
@@ -74,12 +96,15 @@ PL_strnrstr(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-- )
if( *little == *p )
- if( 0 == strncmp(p, little, ll) )
+ if( 0 == strncmp(p, little, ll) ) {
return (char *)p;
+ }
return (char *)0;
}