summaryrefslogtreecommitdiffstats
path: root/nsprpub/lib/libc/src
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
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')
-rw-r--r--nsprpub/lib/libc/src/Makefile.in4
-rw-r--r--nsprpub/lib/libc/src/base64.c8
-rw-r--r--nsprpub/lib/libc/src/plerror.c20
-rw-r--r--nsprpub/lib/libc/src/plgetopt.c33
-rw-r--r--nsprpub/lib/libc/src/plvrsion.c8
-rw-r--r--nsprpub/lib/libc/src/strcase.c80
-rw-r--r--nsprpub/lib/libc/src/strcat.c13
-rw-r--r--nsprpub/lib/libc/src/strchr.c30
-rw-r--r--nsprpub/lib/libc/src/strcmp.c12
-rw-r--r--nsprpub/lib/libc/src/strcpy.c31
-rw-r--r--nsprpub/lib/libc/src/strdup.c14
-rw-r--r--nsprpub/lib/libc/src/strlen.c13
-rw-r--r--nsprpub/lib/libc/src/strpbrk.c25
-rw-r--r--nsprpub/lib/libc/src/strstr.c53
-rw-r--r--nsprpub/lib/libc/src/strtok.c15
15 files changed, 240 insertions, 119 deletions
diff --git a/nsprpub/lib/libc/src/Makefile.in b/nsprpub/lib/libc/src/Makefile.in
index e8a6d9fd0..be488e956 100644
--- a/nsprpub/lib/libc/src/Makefile.in
+++ b/nsprpub/lib/libc/src/Makefile.in
@@ -52,10 +52,6 @@ OS_LIBS = -lc_r
endif
endif
-ifeq ($(OS_ARCH),IRIX)
-OS_LIBS = -lc
-endif
-
ifeq ($(OS_ARCH),SunOS)
OS_LIBS = -lc
MAPFILE = $(OBJDIR)/plcmap.sun
diff --git a/nsprpub/lib/libc/src/base64.c b/nsprpub/lib/libc/src/base64.c
index 07a4902f5..fc1cc51eb 100644
--- a/nsprpub/lib/libc/src/base64.c
+++ b/nsprpub/lib/libc/src/base64.c
@@ -100,8 +100,8 @@ encode
/*
* PL_Base64Encode
*
- * If the destination argument is NULL, a return buffer is
- * allocated, and the data therein will be null-terminated.
+ * If the destination argument is NULL, a return buffer is
+ * allocated, and the data therein will be null-terminated.
* If the destination argument is not NULL, it is assumed to
* be of sufficient size, and the contents will not be null-
* terminated by this routine.
@@ -341,8 +341,8 @@ decode
* If the destination argument is not null, it is assumed
* to be of sufficient size, and the data will not be null-
* terminated by this routine.
- *
- * Returns null if the allocation fails, or if the source string is
+ *
+ * Returns null if the allocation fails, or if the source string is
* not well-formed.
*/
diff --git a/nsprpub/lib/libc/src/plerror.c b/nsprpub/lib/libc/src/plerror.c
index bb8e08d29..2a3510f89 100644
--- a/nsprpub/lib/libc/src/plerror.c
+++ b/nsprpub/lib/libc/src/plerror.c
@@ -16,14 +16,16 @@
PR_IMPLEMENT(void) PL_FPrintError(PRFileDesc *fd, const char *msg)
{
-PRErrorCode error = PR_GetError();
-PRInt32 oserror = PR_GetOSError();
-const char *name = PR_ErrorToName(error);
+ PRErrorCode error = PR_GetError();
+ PRInt32 oserror = PR_GetOSError();
+ const char *name = PR_ErrorToName(error);
- if (NULL != msg) PR_fprintf(fd, "%s: ", msg);
+ if (NULL != msg) {
+ PR_fprintf(fd, "%s: ", msg);
+ }
if (NULL == name)
PR_fprintf(
- fd, " (%d)OUT OF RANGE, oserror = %d\n", error, oserror);
+ fd, " (%d)OUT OF RANGE, oserror = %d\n", error, oserror);
else
PR_fprintf(
fd, "%s(%d), oserror = %d\n",
@@ -32,9 +34,11 @@ const char *name = PR_ErrorToName(error);
PR_IMPLEMENT(void) PL_PrintError(const char *msg)
{
- static PRFileDesc *fd = NULL;
- if (NULL == fd) fd = PR_GetSpecialFD(PR_StandardError);
- PL_FPrintError(fd, msg);
+ static PRFileDesc *fd = NULL;
+ if (NULL == fd) {
+ fd = PR_GetSpecialFD(PR_StandardError);
+ }
+ PL_FPrintError(fd, msg);
} /* PL_PrintError */
/* plerror.c */
diff --git a/nsprpub/lib/libc/src/plgetopt.c b/nsprpub/lib/libc/src/plgetopt.c
index 960decfec..4e37e65f5 100644
--- a/nsprpub/lib/libc/src/plgetopt.c
+++ b/nsprpub/lib/libc/src/plgetopt.c
@@ -45,20 +45,20 @@ PR_IMPLEMENT(PLOptState*) PL_CreateOptState(
} /* PL_CreateOptState */
PR_IMPLEMENT(PLOptState*) PL_CreateLongOptState(
- PRIntn argc, char **argv, const char *options,
+ PRIntn argc, char **argv, const char *options,
const PLLongOpt *longOpts)
{
PLOptState *opt = NULL;
PLOptionInternal *internal;
- if (NULL == options)
+ if (NULL == options)
{
PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
return opt;
}
opt = PR_NEWZAP(PLOptState);
- if (NULL == opt)
+ if (NULL == opt)
{
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
return opt;
@@ -124,15 +124,15 @@ PR_IMPLEMENT(PLOptStatus) PL_GetNextOpt(PLOptState *opt)
}
internal->xargv = internal->argv[internal->xargc];
internal->minus = 0;
- if (!internal->endOfOpts && ('-' == *internal->xargv))
+ if (!internal->endOfOpts && ('-' == *internal->xargv))
{
internal->minus++;
internal->xargv++; /* and consume */
- if ('-' == *internal->xargv && internal->longOpts)
+ if ('-' == *internal->xargv && internal->longOpts)
{
internal->minus++;
internal->xargv++;
- if (0 == *internal->xargv)
+ if (0 == *internal->xargv)
{
internal->endOfOpts = PR_TRUE;
}
@@ -145,7 +145,7 @@ PR_IMPLEMENT(PLOptStatus) PL_GetNextOpt(PLOptState *opt)
** option. See if we can find a match in the list of possible
** options supplied.
*/
- if (internal->minus == 2)
+ if (internal->minus == 2)
{
char * foundEqual = strchr(internal->xargv,'=');
PRIntn optNameLen = foundEqual ? (foundEqual - internal->xargv) :
@@ -156,19 +156,21 @@ PR_IMPLEMENT(PLOptStatus) PL_GetNextOpt(PLOptState *opt)
opt->option = 0;
opt->value = NULL;
- for (; longOpt->longOptName; ++longOpt)
+ for (; longOpt->longOptName; ++longOpt)
{
- if (strncmp(longOpt->longOptName, internal->xargv, optNameLen))
- continue; /* not a possible match */
- if (strlen(longOpt->longOptName) != optNameLen)
- continue; /* not a match */
+ if (strncmp(longOpt->longOptName, internal->xargv, optNameLen)) {
+ continue; /* not a possible match */
+ }
+ if (strlen(longOpt->longOptName) != optNameLen) {
+ continue; /* not a match */
+ }
/* option name match */
opt->longOptIndex = longOpt - internal->longOpts;
opt->longOption = longOpt->longOption;
/* value is part of the current argv[] element if = was found */
/* note: this sets value even for long options that do not
* require option if specified as --long=value */
- if (foundEqual)
+ if (foundEqual)
{
opt->value = foundEqual + 1;
}
@@ -227,8 +229,9 @@ PR_IMPLEMENT(PLOptStatus) PL_GetNextOpt(PLOptState *opt)
internal->xargv = &static_Nul;
internal->minus = 0;
}
- else
- opt->value = NULL;
+ else {
+ opt->value = NULL;
+ }
return PL_OPT_OK;
}
}
diff --git a/nsprpub/lib/libc/src/plvrsion.c b/nsprpub/lib/libc/src/plvrsion.c
index c4bc7a831..ffa2e95d2 100644
--- a/nsprpub/lib/libc/src/plvrsion.c
+++ b/nsprpub/lib/libc/src/plvrsion.c
@@ -54,7 +54,7 @@ PRVersionDescription VERSION_DESC_NAME =
/* filename */ _PRODUCTION, /* the produced library name */
/* description */ "Portable runtime", /* what we are */
/* security */ "N/A", /* not applicable here */
- /* copywrite */ "Copyright (c) 1998 Netscape Communications Corporation. All Rights Reserved",
+ /* copywrite */ "This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.",
/* comment */ "http://www.mozilla.org/MPL/",
/* specialString */ ""
};
@@ -68,9 +68,9 @@ PRVersionDescription VERSION_DESC_NAME =
* must not end in a '$' to prevent rcs keyword substitution.
*/
static char rcsid[] = "$Header: NSPR " PR_VERSION _DEBUG_STRING
- " " _BUILD_STRING " $";
+ " " _BUILD_STRING " $";
static char sccsid[] = "@(#)NSPR " PR_VERSION _DEBUG_STRING
- " " _BUILD_STRING;
+ " " _BUILD_STRING;
#endif /* XP_UNIX */
@@ -86,7 +86,7 @@ PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint()
* from being optimized away as unused variables.
*/
const char *dummy;
-
+
dummy = rcsid;
dummy = sccsid;
#endif
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;
}
diff --git a/nsprpub/lib/libc/src/strcat.c b/nsprpub/lib/libc/src/strcat.c
index 05b7b46d9..df847d36a 100644
--- a/nsprpub/lib/libc/src/strcat.c
+++ b/nsprpub/lib/libc/src/strcat.c
@@ -9,8 +9,9 @@
PR_IMPLEMENT(char *)
PL_strcat(char *dest, const char *src)
{
- if( ((char *)0 == dest) || ((const char *)0 == src) )
+ if( ((char *)0 == dest) || ((const char *)0 == src) ) {
return dest;
+ }
return strcat(dest, src);
}
@@ -20,8 +21,9 @@ PL_strncat(char *dest, const char *src, PRUint32 max)
{
char *rv;
- if( ((char *)0 == dest) || ((const char *)0 == src) || (0 == max) )
+ if( ((char *)0 == dest) || ((const char *)0 == src) || (0 == max) ) {
return dest;
+ }
for( rv = dest; *dest; dest++ )
;
@@ -36,13 +38,16 @@ PL_strcatn(char *dest, PRUint32 max, const char *src)
char *rv;
PRUint32 dl;
- if( ((char *)0 == dest) || ((const char *)0 == src) )
+ if( ((char *)0 == dest) || ((const char *)0 == src) ) {
return dest;
+ }
for( rv = dest, dl = 0; *dest; dest++, dl++ )
;
- if( max <= dl ) return rv;
+ if( max <= dl ) {
+ return rv;
+ }
(void)PL_strncpyz(dest, src, max-dl);
return rv;
diff --git a/nsprpub/lib/libc/src/strchr.c b/nsprpub/lib/libc/src/strchr.c
index 523378b49..7de1887dc 100644
--- a/nsprpub/lib/libc/src/strchr.c
+++ b/nsprpub/lib/libc/src/strchr.c
@@ -9,7 +9,9 @@
PR_IMPLEMENT(char *)
PL_strchr(const char *s, char c)
{
- if( (const char *)0 == s ) return (char *)0;
+ if( (const char *)0 == s ) {
+ return (char *)0;
+ }
return strchr(s, c);
}
@@ -17,7 +19,9 @@ PL_strchr(const char *s, char c)
PR_IMPLEMENT(char *)
PL_strrchr(const char *s, char c)
{
- if( (const char *)0 == s ) return (char *)0;
+ if( (const char *)0 == s ) {
+ return (char *)0;
+ }
return strrchr(s, c);
}
@@ -25,13 +29,18 @@ PL_strrchr(const char *s, char c)
PR_IMPLEMENT(char *)
PL_strnchr(const char *s, char c, PRUint32 n)
{
- if( (const char *)0 == s ) return (char *)0;
+ if( (const char *)0 == s ) {
+ return (char *)0;
+ }
for( ; n && *s; s++, n-- )
- if( *s == c )
+ if( *s == c ) {
return (char *)s;
+ }
- if( ((char)0 == c) && (n > 0) && ((char)0 == *s) ) return (char *)s;
+ if( ((char)0 == c) && (n > 0) && ((char)0 == *s) ) {
+ return (char *)s;
+ }
return (char *)0;
}
@@ -41,16 +50,21 @@ PL_strnrchr(const char *s, char c, PRUint32 n)
{
const char *p;
- if( (const char *)0 == s ) return (char *)0;
+ if( (const char *)0 == s ) {
+ return (char *)0;
+ }
for( p = s; n && *p; p++, n-- )
;
- if( ((char)0 == c) && (n > 0) && ((char)0 == *p) ) return (char *)p;
+ if( ((char)0 == c) && (n > 0) && ((char)0 == *p) ) {
+ return (char *)p;
+ }
for( p--; p >= s; p-- )
- if( *p == c )
+ if( *p == c ) {
return (char *)p;
+ }
return (char *)0;
}
diff --git a/nsprpub/lib/libc/src/strcmp.c b/nsprpub/lib/libc/src/strcmp.c
index 296d71631..9b00bbc52 100644
--- a/nsprpub/lib/libc/src/strcmp.c
+++ b/nsprpub/lib/libc/src/strcmp.c
@@ -9,10 +9,12 @@
PR_IMPLEMENT(PRIntn)
PL_strcmp(const char *a, const 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;
+ }
return (PRIntn)strcmp(a, b);
}
@@ -20,10 +22,12 @@ PL_strcmp(const char *a, const char *b)
PR_IMPLEMENT(PRIntn)
PL_strncmp(const char *a, const char *b, PRUint32 max)
{
- 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;
+ }
return (PRIntn)strncmp(a, b, (size_t)max);
}
diff --git a/nsprpub/lib/libc/src/strcpy.c b/nsprpub/lib/libc/src/strcpy.c
index 9d319aa11..f49b3e75e 100644
--- a/nsprpub/lib/libc/src/strcpy.c
+++ b/nsprpub/lib/libc/src/strcpy.c
@@ -9,7 +9,9 @@
PR_IMPLEMENT(char *)
PL_strcpy(char *dest, const char *src)
{
- if( ((char *)0 == dest) || ((const char *)0 == src) ) return (char *)0;
+ if( ((char *)0 == dest) || ((const char *)0 == src) ) {
+ return (char *)0;
+ }
return strcpy(dest, src);
}
@@ -18,17 +20,22 @@ PR_IMPLEMENT(char *)
PL_strncpy(char *dest, const char *src, PRUint32 max)
{
char *rv;
-
- if( (char *)0 == dest ) return (char *)0;
- if( (const char *)0 == src ) return (char *)0;
+
+ if( (char *)0 == dest ) {
+ return (char *)0;
+ }
+ if( (const char *)0 == src ) {
+ return (char *)0;
+ }
for( rv = dest; max && ((*dest = *src) != 0); dest++, src++, max-- )
;
#ifdef JLRU
/* XXX I (wtc) think the -- and ++ operators should be postfix. */
- while( --max )
+ while( --max ) {
*++dest = '\0';
+ }
#endif /* JLRU */
return rv;
@@ -38,10 +45,16 @@ PR_IMPLEMENT(char *)
PL_strncpyz(char *dest, const char *src, PRUint32 max)
{
char *rv;
-
- if( (char *)0 == dest ) return (char *)0;
- if( (const char *)0 == src ) return (char *)0;
- if( 0 == max ) return (char *)0;
+
+ if( (char *)0 == dest ) {
+ return (char *)0;
+ }
+ if( (const char *)0 == src ) {
+ return (char *)0;
+ }
+ if( 0 == max ) {
+ return (char *)0;
+ }
for( rv = dest, max--; max && ((*dest = *src) != 0); dest++, src++, max-- )
;
diff --git a/nsprpub/lib/libc/src/strdup.c b/nsprpub/lib/libc/src/strdup.c
index c267147ce..d2deae43c 100644
--- a/nsprpub/lib/libc/src/strdup.c
+++ b/nsprpub/lib/libc/src/strdup.c
@@ -13,13 +13,16 @@ PL_strdup(const char *s)
char *rv;
size_t n;
- if( (const char *)0 == s )
+ if( (const char *)0 == s ) {
s = "";
+ }
n = strlen(s) + 1;
rv = (char *)malloc(n);
- if( (char *)0 == rv ) return rv;
+ if( (char *)0 == rv ) {
+ return rv;
+ }
(void)memcpy(rv, s, n);
@@ -38,13 +41,16 @@ PL_strndup(const char *s, PRUint32 max)
char *rv;
size_t l;
- if( (const char *)0 == s )
+ if( (const char *)0 == s ) {
s = "";
+ }
l = PL_strnlen(s, max);
rv = (char *)malloc(l+1);
- if( (char *)0 == rv ) return rv;
+ if( (char *)0 == rv ) {
+ return rv;
+ }
(void)memcpy(rv, s, l);
rv[l] = '\0';
diff --git a/nsprpub/lib/libc/src/strlen.c b/nsprpub/lib/libc/src/strlen.c
index ba6c612de..2888175df 100644
--- a/nsprpub/lib/libc/src/strlen.c
+++ b/nsprpub/lib/libc/src/strlen.c
@@ -13,17 +13,20 @@ PL_strlen(const char *str)
{
size_t l;
- if( (const char *)0 == str ) return 0;
+ if( (const char *)0 == str ) {
+ return 0;
+ }
l = strlen(str);
/* error checking in case we have a 64-bit platform -- make sure
* we don't have ultra long strings that overflow an int32
- */
+ */
if( sizeof(PRUint32) < sizeof(size_t) )
{
- if( l > PR_INT32_MAX )
+ if( l > PR_INT32_MAX ) {
PR_Assert("l <= PR_INT32_MAX", __FILE__, __LINE__);
+ }
}
return (PRUint32)l;
@@ -34,7 +37,9 @@ PL_strnlen(const char *str, PRUint32 max)
{
register const char *s;
- if( (const char *)0 == str ) return 0;
+ if( (const char *)0 == str ) {
+ return 0;
+ }
for( s = str; max && *s; s++, max-- )
;
diff --git a/nsprpub/lib/libc/src/strpbrk.c b/nsprpub/lib/libc/src/strpbrk.c
index 0d2be9810..89ccbe698 100644
--- a/nsprpub/lib/libc/src/strpbrk.c
+++ b/nsprpub/lib/libc/src/strpbrk.c
@@ -9,7 +9,9 @@
PR_IMPLEMENT(char *)
PL_strpbrk(const char *s, const char *list)
{
- if( ((const char *)0 == s) || ((const char *)0 == list) ) return (char *)0;
+ if( ((const char *)0 == s) || ((const char *)0 == list) ) {
+ return (char *)0;
+ }
return strpbrk(s, list);
}
@@ -20,15 +22,18 @@ PL_strprbrk(const char *s, const char *list)
const char *p;
const char *r;
- if( ((const char *)0 == s) || ((const char *)0 == list) ) return (char *)0;
+ if( ((const char *)0 == s) || ((const char *)0 == list) ) {
+ return (char *)0;
+ }
for( r = s; *r; r++ )
;
for( r--; r >= s; r-- )
for( p = list; *p; p++ )
- if( *r == *p )
+ if( *r == *p ) {
return (char *)r;
+ }
return (char *)0;
}
@@ -38,12 +43,15 @@ PL_strnpbrk(const char *s, const char *list, PRUint32 max)
{
const char *p;
- if( ((const char *)0 == s) || ((const char *)0 == list) ) return (char *)0;
+ if( ((const char *)0 == s) || ((const char *)0 == list) ) {
+ return (char *)0;
+ }
for( ; max && *s; s++, max-- )
for( p = list; *p; p++ )
- if( *s == *p )
+ if( *s == *p ) {
return (char *)s;
+ }
return (char *)0;
}
@@ -54,15 +62,18 @@ PL_strnprbrk(const char *s, const char *list, PRUint32 max)
const char *p;
const char *r;
- if( ((const char *)0 == s) || ((const char *)0 == list) ) return (char *)0;
+ if( ((const char *)0 == s) || ((const char *)0 == list) ) {
+ return (char *)0;
+ }
for( r = s; max && *r; r++, max-- )
;
for( r--; r >= s; r-- )
for( p = list; *p; p++ )
- if( *r == *p )
+ if( *r == *p ) {
return (char *)r;
+ }
return (char *)0;
}
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;
}
diff --git a/nsprpub/lib/libc/src/strtok.c b/nsprpub/lib/libc/src/strtok.c
index 2daaea36c..df404494f 100644
--- a/nsprpub/lib/libc/src/strtok.c
+++ b/nsprpub/lib/libc/src/strtok.c
@@ -14,21 +14,24 @@ PL_strtok_r(char *s1, const char *s2, char **lasts)
if( s1 == NULL )
{
- if( *lasts == NULL )
+ if( *lasts == NULL ) {
return NULL;
+ }
s1 = *lasts;
}
-
+
for( ; (c = *s1) != 0; s1++ )
{
for( sepp = s2 ; (sc = *sepp) != 0 ; sepp++ )
{
- if( c == sc )
+ if( c == sc ) {
break;
+ }
+ }
+ if( sc == 0 ) {
+ break;
}
- if( sc == 0 )
- break;
}
if( c == 0 )
@@ -36,7 +39,7 @@ PL_strtok_r(char *s1, const char *s2, char **lasts)
*lasts = NULL;
return NULL;
}
-
+
tok = s1++;
for( ; (c = *s1) != 0; s1++ )