summaryrefslogtreecommitdiff
path: root/nsprpub/lib/libc
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
parent26b297510a11758727438df4669357a2a2bc42ce (diff)
downloaduxp-f7d30133221896638f7bf4f66c504255c4b14f48.tar.gz
Issue #1338 - Part 1: Update NSPR to 4.24
Diffstat (limited to 'nsprpub/lib/libc')
-rw-r--r--nsprpub/lib/libc/include/plbase64.h8
-rw-r--r--nsprpub/lib/libc/include/plgetopt.h68
-rw-r--r--nsprpub/lib/libc/include/plstr.h30
-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
18 files changed, 293 insertions, 172 deletions
diff --git a/nsprpub/lib/libc/include/plbase64.h b/nsprpub/lib/libc/include/plbase64.h
index 7d17ea78fc..8f2117cc29 100644
--- a/nsprpub/lib/libc/include/plbase64.h
+++ b/nsprpub/lib/libc/include/plbase64.h
@@ -19,11 +19,11 @@ PR_BEGIN_EXTERN_C
* is zero, the source data is assumed to be null-terminated, and PL_strlen
* is used to determine the source length. If the "dest" parameter is not
* null, it is assumed to point to a buffer of sufficient size (which may be
- * calculated: ((srclen + 2)/3)*4) into which the encoded data is placed
+ * calculated: ((srclen + 2)/3)*4) into which the encoded data is placed
* (without any termination). If the "dest" parameter is null, a buffer is
* allocated from the heap to hold the encoded data, and the result *will*
- * be terminated with an extra null character. It is the caller's
- * responsibility to free the result when it is allocated. A null is returned
+ * be terminated with an extra null character. It is the caller's
+ * responsibility to free the result when it is allocated. A null is returned
* if the allocation fails.
*
* NOTE: when calculating ((srclen + 2)/3)*4), first ensure that
@@ -56,7 +56,7 @@ PL_Base64Encode
* caller's responsibility to free the result when it is allocated. A null
* is retuned if the allocation fails, or if the source is not well-coded.
*
- * NOTE: when calculating (srclen * 3)/4, first ensure that
+ * NOTE: when calculating (srclen * 3)/4, first ensure that
* srclen <= PR_UINT32_MAX/3
* to avoid PRUint32 overflow. Alternatively, calculate
* (srclen/4) * 3 + ((srclen%4) * 3)/4
diff --git a/nsprpub/lib/libc/include/plgetopt.h b/nsprpub/lib/libc/include/plgetopt.h
index 19cafa6009..bd5181b1db 100644
--- a/nsprpub/lib/libc/include/plgetopt.h
+++ b/nsprpub/lib/libc/include/plgetopt.h
@@ -16,13 +16,13 @@
PR_BEGIN_EXTERN_C
-typedef struct PLOptionInternal PLOptionInternal;
+typedef struct PLOptionInternal PLOptionInternal;
typedef enum
{
- PL_OPT_OK, /* all's well with the option */
- PL_OPT_EOL, /* end of options list */
- PL_OPT_BAD /* invalid option (and value) */
+ PL_OPT_OK, /* all's well with the option */
+ PL_OPT_EOL, /* end of options list */
+ PL_OPT_BAD /* invalid option (and value) */
} PLOptStatus;
typedef struct PLLongOpt
@@ -30,7 +30,7 @@ typedef struct PLLongOpt
const char * longOptName; /* long option name string */
PRIntn longOption; /* value put in PLOptState for this option. */
PRBool valueRequired; /* If option name not followed by '=', */
- /* value is the next argument from argv. */
+ /* value is the next argument from argv. */
} PLLongOpt;
typedef struct PLOptState
@@ -47,27 +47,27 @@ typedef struct PLOptState
/*
* PL_CreateOptState
*
- * The argument "options" points to a string of single-character option
- * names. Option names that may have an option argument value must be
- * followed immediately by a ':' character.
+ * The argument "options" points to a string of single-character option
+ * names. Option names that may have an option argument value must be
+ * followed immediately by a ':' character.
*/
PR_EXTERN(PLOptState*) PL_CreateOptState(
- PRIntn argc, char **argv, const char *options);
+ PRIntn argc, char **argv, const char *options);
-/*
+/*
* PL_CreateLongOptState
*
- * Alternative to PL_CreateOptState.
- * Allows caller to specify BOTH a string of single-character option names,
- * AND an array of structures describing "long" (keyword) option names.
- * The array is terminated by a structure in which longOptName is NULL.
+ * Alternative to PL_CreateOptState.
+ * Allows caller to specify BOTH a string of single-character option names,
+ * AND an array of structures describing "long" (keyword) option names.
+ * The array is terminated by a structure in which longOptName is NULL.
* Long option values (arguments) may always be given as "--name=value".
- * If PLLongOpt.valueRequired is not PR_FALSE, and the option name was not
- * followed by '=' then the next argument from argv is taken as the value.
+ * If PLLongOpt.valueRequired is not PR_FALSE, and the option name was not
+ * followed by '=' then the next argument from argv is taken as the value.
*/
PR_EXTERN(PLOptState*) PL_CreateLongOptState(
- PRIntn argc, char **argv, const char *options,
- const PLLongOpt *longOpts);
+ PRIntn argc, char **argv, const char *options,
+ const PLLongOpt *longOpts);
/*
* PL_DestroyOptState
*
@@ -79,39 +79,39 @@ PR_EXTERN(void) PL_DestroyOptState(PLOptState *opt);
/*
* PL_GetNextOpt
*
- * When this function returns PL_OPT_OK,
- * - opt->option will hold the single-character option name that was parsed,
- * or zero.
- * When opt->option is zero, the token parsed was either a "long" (keyword)
- * option or a positional parameter.
- * For a positional parameter,
+ * When this function returns PL_OPT_OK,
+ * - opt->option will hold the single-character option name that was parsed,
+ * or zero.
+ * When opt->option is zero, the token parsed was either a "long" (keyword)
+ * option or a positional parameter.
+ * For a positional parameter,
* - opt->longOptIndex will contain -1, and
* - opt->value will point to the positional parameter string.
- * For a long option name,
- * - opt->longOptIndex will contain the non-negative index of the
- * PLLongOpt structure in the caller's array of PLLongOpt structures
- * corresponding to the long option name, and
- * For a single-character or long option,
+ * For a long option name,
+ * - opt->longOptIndex will contain the non-negative index of the
+ * PLLongOpt structure in the caller's array of PLLongOpt structures
+ * corresponding to the long option name, and
+ * For a single-character or long option,
* - opt->longOption will contain the value of the single-character option
* name, or the value of the longOption from the PLLongOpt structure
* for that long option. See notes below.
* - opt->value will point to the argument option string, or will
* be NULL if option does not require argument. If option requires
* argument but it is not provided, PL_OPT_BAD is returned.
- * When opt->option is non-zero,
+ * When opt->option is non-zero,
* - opt->longOptIndex will be -1
* When this function returns PL_OPT_EOL, or PL_OPT_BAD, the contents of
* opt are undefined.
*
- * Notes: It is possible to ignore opt->option, and always look at
+ * Notes: It is possible to ignore opt->option, and always look at
* opt->longOption instead. opt->longOption will contain the same value
* as opt->option for single-character option names, and will contain the
* value of longOption from the PLLongOpt structure for long option names.
- * This means that it is possible to equivalence long option names to
+ * This means that it is possible to equivalence long option names to
* single character names by giving the longOption in the PLLongOpt struct
- * the same value as the single-character option name.
+ * the same value as the single-character option name.
* For long options that are NOT intended to be equivalent to any single-
- * character option, the longOption value should be chosen to not match
+ * character option, the longOption value should be chosen to not match
* any possible single character name. It might be advisable to choose
* longOption values greater than 0xff for such long options.
*/
diff --git a/nsprpub/lib/libc/include/plstr.h b/nsprpub/lib/libc/include/plstr.h
index 57814c704b..ea59832a35 100644
--- a/nsprpub/lib/libc/include/plstr.h
+++ b/nsprpub/lib/libc/include/plstr.h
@@ -10,13 +10,13 @@
* plstr.h
*
* This header file exports the API to the NSPR portable library or string-
- * handling functions.
- *
- * This API was not designed as an "optimal" or "ideal" string library; it
+ * handling functions.
+ *
+ * This API was not designed as an "optimal" or "ideal" string library; it
* was based on the good ol' unix string.3 functions, and was written to
*
- * 1) replace the libc functions, for cross-platform consistency,
- * 2) complete the API on platforms lacking common functions (e.g.,
+ * 1) replace the libc functions, for cross-platform consistency,
+ * 2) complete the API on platforms lacking common functions (e.g.,
* strcase*), and
* 3) to implement some obvious "closure" functions that I've seen
* people hacking around in our code.
@@ -76,13 +76,13 @@ PL_strncpy(char *dest, const char *src, PRUint32 max);
/*
* PL_strncpyz
*
- * Copies the source string into the destination buffer, up to and including
- * the trailing '\0' or up but not including the max'th character, whichever
+ * Copies the source string into the destination buffer, up to and including
+ * the trailing '\0' or up but not including the max'th character, whichever
* comes first. It does not (can not) verify that the destination buffer is
* large enough. The destination string is always terminated with a '\0',
* unlike the traditional libc implementation. It returns the "dest" argument.
*
- * NOTE: If you call this with a source "abcdefg" and a max of 5, the
+ * NOTE: If you call this with a source "abcdefg" and a max of 5, the
* destination will end up with "abcd\0" (i.e., its strlen length will be 4)!
*
* This means you can do this:
@@ -152,7 +152,7 @@ PL_strcat(char *dst, const char *src);
* Appends a copy of the string pointed to by the second argument, up to
* the maximum size specified, to the end of the string pointed to by the
* first. The destination buffer is not (can not be) checked for sufficient
- * size. A null destination argument returns null; otherwise, the first
+ * size. A null destination argument returns null; otherwise, the first
* argument is returned. If the maximum size limits the copy, then the
* result will *not* be null-terminated (JLRU). A null destination
* returns null; otherwise, the destination argument is returned.
@@ -189,10 +189,10 @@ PL_strcmp(const char *a, const char *b);
/*
* PL_strncmp
- *
+ *
* Returns an integer, the sign of which -- positive, zero, or negative --
* reflects the lexical sorting order of the two strings indicated, up to
- * the maximum specified. The result is positive if the first string comes
+ * the maximum specified. The result is positive if the first string comes
* after the second. The NSPR implementation is not i18n. If the maximum
* is zero, only the existance or non-existance (pointer is null) of the
* strings is compared.
@@ -206,7 +206,7 @@ PL_strncmp(const char *a, const char *b, PRUint32 max);
*
* Returns an integer, the sign of which -- positive, zero or negative --
* reflects the case-insensitive lexical sorting order of the two strings
- * indicated. The result is positive if the first string comes after the
+ * indicated. The result is positive if the first string comes after the
* second. The NSPR implementation is not i18n.
*/
@@ -218,7 +218,7 @@ PL_strcasecmp(const char *a, const char *b);
*
* Returns an integer, the sign of which -- positive, zero or negative --
* reflects the case-insensitive lexical sorting order of the first n characters
- * of the two strings indicated. The result is positive if the first string comes
+ * of the two strings indicated. The result is positive if the first string comes
* after the second. The NSPR implementation is not i18n.
*/
@@ -249,7 +249,7 @@ PL_strrchr(const char *s, char c);
/*
* PL_strnchr
- *
+ *
* Returns a pointer to the first instance of the specified character within the
* first n characters of the provided string. It returns null if the character
* is not found, or if the provided string is null. The character may be the
@@ -386,7 +386,7 @@ PL_strcaserstr(const char *big, const char *little);
* PL_strncasestr
*
* Returns a pointer to the first instance of the little string within the first
- * n characters of the big one, ignoring case. It returns null if either string is
+ * n characters of the big one, ignoring case. It returns null if either string is
* null. It returns null if the length of the little string is greater than n.
*/
diff --git a/nsprpub/lib/libc/src/Makefile.in b/nsprpub/lib/libc/src/Makefile.in
index e8a6d9fd0e..be488e956f 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 07a4902f5b..fc1cc51eb8 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 bb8e08d29f..2a3510f89f 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 960decfec5..4e37e65f51 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 c4bc7a8317..ffa2e95d2d 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 ad542587ba..f1ab038cd9 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 05b7b46d90..df847d36aa 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 523378b49e..7de1887dc3 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 296d716318..9b00bbc521 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 9d319aa118..f49b3e75e6 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 c267147ce9..d2deae43c4 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 ba6c612dec..2888175dfc 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 0d2be98105..89ccbe698e 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 a90d8226dc..dd27a23ee7 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 2daaea36c5..df404494fb 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++ )