Bug 1162780 - Update NSPR to NSPR_4_10_9_BETA2. r=ted

This commit is contained in:
Jed Davis 2015-07-22 10:52:39 -07:00
parent 29cdefad1c
commit af478d2bb6
24 changed files with 481 additions and 44 deletions

View File

@ -1 +1 @@
NSPR_4_10_8_RTM
NSPR_4_10_9_BETA2

View File

@ -10,3 +10,4 @@
*/
#error "Do not include this header file."

37
nsprpub/configure vendored
View File

@ -2489,7 +2489,7 @@ test -n "$target_alias" &&
MOD_MAJOR_VERSION=4
MOD_MINOR_VERSION=10
MOD_PATCH_VERSION=8
MOD_PATCH_VERSION=9
NSPR_MODNAME=nspr20
_HAVE_PTHREADS=
USE_PTHREADS=
@ -2666,6 +2666,19 @@ fi
if test -n "$gonkdir" ; then
if test -z "$HOST_CPPFLAGS" ; then
HOST_CPPFLAGS=" "
fi
if test -z "$HOST_CFLAGS" ; then
HOST_CFLAGS=" "
fi
if test -z "$HOST_CXXFLAGS" ; then
HOST_CXXFLAGS=" "
fi
if test -z "$HOST_LDFLAGS" ; then
HOST_LDFLAGS=" "
fi
$as_echo "#define ANDROID 1" >>confdefs.h
else
@ -2750,6 +2763,19 @@ $as_echo "$android_platform" >&6; }
CXXFLAGS="-mandroid -I$android_platform/usr/include -fpic -fno-short-enums -fno-exceptions $CXXFLAGS"
LDFLAGS="-mandroid -L$android_platform/usr/lib -Wl,-rpath-link=$android_platform/usr/lib --sysroot=$android_platform $LDFLAGS"
if test -z "$HOST_CPPFLAGS" ; then
HOST_CPPFLAGS=" "
fi
if test -z "$HOST_CFLAGS" ; then
HOST_CFLAGS=" "
fi
if test -z "$HOST_CXXFLAGS" ; then
HOST_CXXFLAGS=" "
fi
if test -z "$HOST_LDFLAGS" ; then
HOST_LDFLAGS=" "
fi
$as_echo "#define ANDROID 1" >>confdefs.h
;;
@ -4595,6 +4621,12 @@ test -n "$HOST_CC" || HOST_CC=""""
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $HOST_CC" >&5
$as_echo "$HOST_CC" >&6; }
if test -z "$HOST_CFLAGS"; then
HOST_CFLAGS="$CFLAGS"
fi
if test -z "$HOST_LDFLAGS"; then
HOST_LDFLAGS="$LDFLAGS"
fi
CC="$HOST_CC"
CFLAGS="$HOST_CFLAGS"
@ -6552,6 +6584,7 @@ fi
fi
ac_fn_c_check_header_mongrel "$LINENO" "crt_externs.h" "ac_cv_header_crt_externs_h" "$ac_includes_default"
if test "x$ac_cv_header_crt_externs_h" = xyes; then :
$as_echo "#define HAVE_CRT_EXTERNS_H 1" >>confdefs.h
fi
@ -7284,6 +7317,8 @@ $as_echo "$as_me: WARNING: Unknown version of the Microsoft (R) Manifest Tool."
$as_echo "#define HAVE_BSD_FLOCK 1" >>confdefs.h
$as_echo "#define HAVE_SOCKLEN_T 1" >>confdefs.h
if test -z "$USE_NSPR_THREADS"; then
USE_PTHREADS=1
fi

View File

@ -16,7 +16,7 @@ dnl = Defaults
dnl ========================================================
MOD_MAJOR_VERSION=4
MOD_MINOR_VERSION=10
MOD_PATCH_VERSION=8
MOD_PATCH_VERSION=9
NSPR_MODNAME=nspr20
_HAVE_PTHREADS=
USE_PTHREADS=
@ -160,6 +160,20 @@ AC_ARG_WITH(gonk,
if test -n "$gonkdir" ; then
dnl Most things are directly configured by env vars when building for gonk
dnl prevent cross compile section from using these flags as host flags
if test -z "$HOST_CPPFLAGS" ; then
HOST_CPPFLAGS=" "
fi
if test -z "$HOST_CFLAGS" ; then
HOST_CFLAGS=" "
fi
if test -z "$HOST_CXXFLAGS" ; then
HOST_CXXFLAGS=" "
fi
if test -z "$HOST_LDFLAGS" ; then
HOST_LDFLAGS=" "
fi
AC_DEFINE(ANDROID)
else
case "$target" in
@ -243,6 +257,20 @@ case "$target" in
CXXFLAGS="-mandroid -I$android_platform/usr/include -fpic -fno-short-enums -fno-exceptions $CXXFLAGS"
LDFLAGS="-mandroid -L$android_platform/usr/lib -Wl,-rpath-link=$android_platform/usr/lib --sysroot=$android_platform $LDFLAGS"
dnl prevent cross compile section from using these flags as host flags
if test -z "$HOST_CPPFLAGS" ; then
HOST_CPPFLAGS=" "
fi
if test -z "$HOST_CFLAGS" ; then
HOST_CFLAGS=" "
fi
if test -z "$HOST_CXXFLAGS" ; then
HOST_CXXFLAGS=" "
fi
if test -z "$HOST_LDFLAGS" ; then
HOST_LDFLAGS=" "
fi
AC_DEFINE(ANDROID)
;;
esac
@ -625,6 +653,12 @@ if test "$target" != "$host"; then
AC_MSG_ERROR([no acceptable cc found in \$PATH])
fi
AC_MSG_RESULT([$HOST_CC])
if test -z "$HOST_CFLAGS"; then
HOST_CFLAGS="$CFLAGS"
fi
if test -z "$HOST_LDFLAGS"; then
HOST_LDFLAGS="$LDFLAGS"
fi
CC="$HOST_CC"
CFLAGS="$HOST_CFLAGS"
@ -1378,7 +1412,7 @@ case "$target" in
if test "`echo $CC | grep -c '\-arch '`" = "0"; then
CC="$CC -arch $CPU_ARCH"
fi
AC_CHECK_HEADER(crt_externs.h)
AC_CHECK_HEADER(crt_externs.h, AC_DEFINE(HAVE_CRT_EXTERNS_H))
DSO_CFLAGS=-fPIC
DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load -install_name @executable_path/$@ -headerpad_max_install_names'
_OPTIMIZE_FLAGS=-O2
@ -2086,6 +2120,7 @@ tools are selected during the Xcode/Developer Tools installation.])
AC_DEFINE(XP_UNIX)
AC_DEFINE(NETBSD)
AC_DEFINE(HAVE_BSD_FLOCK)
AC_DEFINE(HAVE_SOCKLEN_T)
if test -z "$USE_NSPR_THREADS"; then
USE_PTHREADS=1
fi

View File

@ -508,6 +508,52 @@
#error "Unknown MIPS endianness."
#endif
#ifdef _ABI64
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_ALIGN_OF_WORD 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#else /* _ABI64 */
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
@ -548,6 +594,8 @@
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#endif /* _ABI64 */
#elif defined(__arm__)
#ifdef __ARMEB__

View File

@ -113,6 +113,36 @@ NSPR_API(char*) PR_GetEnv(const char *var);
*/
NSPR_API(PRStatus) PR_SetEnv(const char *string);
/*
** PR_DuplicateEnvironment() -- Obtain a copy of the environment.
**
** Description:
** PR_DuplicateEnvironment() copies the environment so that it can be
** modified without changing the current process's environment, and
** then passed to interfaces such as POSIX execve(). In particular,
** this avoids needing to allocate memory or take locks in the child
** after a fork(); neither of these is allowed by POSIX after a
** multithreaded process calls fork(), and PR_SetEnv does both.
**
** Inputs:
** none
**
** Returns:
** A pointer to a null-terminated array of null-terminated strings,
** like the traditional global variable "environ". The array and
** the strings are allocated with PR_Malloc(), and it is the
** caller's responsibility to free them.
**
** In case of memory allocation failure, or if the operating system
** doesn't support reading the entire environment through the global
** variable "environ" or similar, returns NULL instead.
**
** Restrictions:
** Similarly to PR_GetEnv(), this function may not interoperate as
** expected with the operating system's native environment accessors.
*/
NSPR_API(char **) PR_DuplicateEnvironment(void);
PR_END_EXTERN_C
#endif /* prenv_h___ */

View File

@ -31,11 +31,11 @@ PR_BEGIN_EXTERN_C
** The format of the version string is
** "<major version>.<minor version>[.<patch level>] [<Beta>]"
*/
#define PR_VERSION "4.10.8"
#define PR_VERSION "4.10.9 Beta"
#define PR_VMAJOR 4
#define PR_VMINOR 10
#define PR_VPATCH 8
#define PR_BETA PR_FALSE
#define PR_VPATCH 9
#define PR_BETA PR_TRUE
/*
** PRVersionCheck

View File

@ -157,7 +157,8 @@ NSPR_API(void) PR_LogPrint(const char *fmt, ...);
*/
NSPR_API(void) PR_LogFlush(void);
NSPR_API(void) PR_Assert(const char *s, const char *file, PRIntn ln);
NSPR_API(void) PR_Assert(const char *s, const char *file, PRIntn ln)
PR_PRETEND_NORETURN;
#if defined(DEBUG) || defined(FORCE_PR_LOG)
#define PR_LOGGING 1

View File

@ -248,14 +248,14 @@ NSPR_API(PRStatus) PR_ParseTimeString (
/* Format a time value into a buffer. Same semantics as strftime() */
NSPR_API(PRUint32) PR_FormatTime(char *buf, int buflen, const char *fmt,
const PRExplodedTime *tm);
const PRExplodedTime *time);
/* Format a time value into a buffer. Time is always in US English format, regardless
* of locale setting.
/* Format a time value into a buffer. Time is always in US English format,
* regardless of locale setting.
*/
NSPR_API(PRUint32)
PR_FormatTimeUSEnglish( char* buf, PRUint32 bufSize,
const char* format, const PRExplodedTime* tm );
PR_FormatTimeUSEnglish(char *buf, PRUint32 bufSize,
const char *format, const PRExplodedTime *time);
PR_END_EXTERN_C

View File

@ -510,6 +510,31 @@ typedef long PRWord;
typedef unsigned long PRUword;
#endif
/*
* PR_PRETEND_NORETURN, specified at the end of a function declaration,
* indicates that for the purposes of static analysis, this function does not
* return. (The function definition does not need to be annotated.)
*
* void PR_Assert(const char *s, const char *file, PRIntn ln)
* PR_PRETEND_NORETURN;
*
* Some static analyzers, like scan-build from clang, can use this information
* to eliminate false positives. From the upstream documentation of
* scan-build:
* This attribute is useful for annotating assertion handlers that actually
* can return, but for the purpose of using the analyzer we want to pretend
* that such functions do not return.
*/
#ifdef __clang_analyzer__
#if __has_extension(attribute_analyzer_noreturn)
#define PR_PRETEND_NORETURN __attribute__((analyzer_noreturn))
#endif
#endif
#ifndef PR_PRETEND_NORETURN
#define PR_PRETEND_NORETURN /* no support */
#endif
#if defined(NO_NSPR_10_SUPPORT)
#else
/********* ???????????????? FIX ME ??????????????????????????? *****/

View File

@ -213,7 +213,6 @@ void _PR_InitFdCache(void)
void _PR_CleanupFdCache(void)
{
PRFileDesc *fd, *next;
PRStackElem *pop;
for (fd = _pr_fd_cache.head; fd != NULL; fd = next)
{

View File

@ -475,6 +475,7 @@ static PRStatus _MW_PollInternal(PRWaitGroup *group)
PR_Lock(group->ml);
if (_prmw_running != group->state)
{
PR_DELETE(poll_list);
PR_SetError(PR_INVALID_STATE_ERROR, 0);
goto aborted;
}

View File

@ -66,7 +66,11 @@ struct NumArg {
#define NAS_DEFAULT_NUM 20 /* default number of NumberedArgument array */
/*
** For numeric types, the signed versions must have even values,
** and their corresponding unsigned versions must have the subsequent
** odd value.
*/
#define TYPE_INT16 0
#define TYPE_UINT16 1
#define TYPE_INTN 2
@ -376,8 +380,8 @@ static int cvt_s(SprintfState *ss, const char *str, int width, int prec,
/*
** BuildArgArray stands for Numbered Argument list Sprintf
** for example,
** fmp = "%4$i, %2$d, %3s, %1d";
** for example,
** fmt = "%4$i, %2$d, %3s, %1d";
** the number must start from 1, and no gap among them
*/
@ -515,6 +519,15 @@ static struct NumArg* BuildArgArray( const char *fmt, va_list ap, int* rv, struc
nas[cn].type = TYPE_INT64;
c = *p++;
}
} else if (c == 'z') {
if (sizeof(size_t) == sizeof(PRInt32)) {
nas[ cn ].type = TYPE_INT32;
} else if (sizeof(size_t) == sizeof(PRInt64)) {
nas[ cn ].type = TYPE_INT64;
} else {
nas[ cn ].type = TYPE_UNKNOWN;
}
c = *p++;
}
/* format */
@ -809,6 +822,13 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap)
type = TYPE_INT64;
c = *fmt++;
}
} else if (c == 'z') {
if (sizeof(size_t) == sizeof(PRInt32)) {
type = TYPE_INT32;
} else if (sizeof(size_t) == sizeof(PRInt64)) {
type = TYPE_INT64;
}
c = *fmt++;
}
/* format */

View File

@ -5,6 +5,17 @@
#include <string.h>
#include "primpl.h"
#include "prmem.h"
#if defined(XP_UNIX)
#if defined(DARWIN)
#if defined(HAVE_CRT_EXTERNS_H)
#include <crt_externs.h>
#endif /* HAVE_CRT_EXTERNS_H */
#else /* DARWIN */
PR_IMPORT_DATA(char **) environ;
#endif /* DARWIN */
#endif /* XP_UNIX */
/* Lock used to lock the environment */
#if defined(_PR_NO_PREEMPT)
@ -58,10 +69,59 @@ PR_IMPLEMENT(PRStatus) PR_SetEnv(const char *string)
if (!_pr_initialized) _PR_ImplicitInitialization();
if ( !strchr(string, '=')) return(PR_FAILURE);
if (!strchr(string, '=')) return(PR_FAILURE);
_PR_LOCK_ENV();
result = _PR_MD_PUT_ENV(string);
result = _PR_MD_PUT_ENV((char*)string);
_PR_UNLOCK_ENV();
return (result)? PR_FAILURE : PR_SUCCESS;
return result ? PR_FAILURE : PR_SUCCESS;
}
#if defined(XP_UNIX) && (!defined(DARWIN) || defined(HAVE_CRT_EXTERNS_H))
PR_IMPLEMENT(char **) PR_DuplicateEnvironment(void)
{
char **the_environ, **result, **end, **src, **dst;
_PR_LOCK_ENV();
#ifdef DARWIN
the_environ = *(_NSGetEnviron());
#else
the_environ = environ;
#endif
for (end = the_environ; *end != NULL; end++)
/* empty loop body */;
result = (char **)PR_Malloc(sizeof(char *) * (end - the_environ + 1));
if (result != NULL) {
for (src = the_environ, dst = result; src != end; src++, dst++) {
size_t len;
len = strlen(*src) + 1;
*dst = PR_Malloc(len);
if (*dst == NULL) {
/* Allocation failed. Must clean up the half-copied env. */
char **to_delete;
for (to_delete = result; to_delete != dst; to_delete++) {
PR_Free(*to_delete);
}
PR_Free(result);
result = NULL;
goto out;
}
memcpy(*dst, *src, len);
}
*dst = NULL;
}
out:
_PR_UNLOCK_ENV();
return result;
}
#else
/* This platform doesn't support raw access to the environ block. */
PR_IMPLEMENT(char **) PR_DuplicateEnvironment(void)
{
return NULL;
}
#endif

View File

@ -1672,23 +1672,24 @@ PR_ParseTimeString(
*/
PR_IMPLEMENT(PRUint32)
PR_FormatTime(char *buf, int buflen, const char *fmt, const PRExplodedTime *tm)
PR_FormatTime(char *buf, int buflen, const char *fmt,
const PRExplodedTime *time)
{
size_t rv;
struct tm a;
struct tm *ap;
if (tm) {
if (time) {
ap = &a;
a.tm_sec = tm->tm_sec;
a.tm_min = tm->tm_min;
a.tm_hour = tm->tm_hour;
a.tm_mday = tm->tm_mday;
a.tm_mon = tm->tm_month;
a.tm_wday = tm->tm_wday;
a.tm_year = tm->tm_year - 1900;
a.tm_yday = tm->tm_yday;
a.tm_isdst = tm->tm_params.tp_dst_offset ? 1 : 0;
a.tm_sec = time->tm_sec;
a.tm_min = time->tm_min;
a.tm_hour = time->tm_hour;
a.tm_mday = time->tm_mday;
a.tm_mon = time->tm_month;
a.tm_wday = time->tm_wday;
a.tm_year = time->tm_year - 1900;
a.tm_yday = time->tm_yday;
a.tm_isdst = time->tm_params.tp_dst_offset ? 1 : 0;
/*
* On some platforms, for example SunOS 4, struct tm has two
@ -1699,8 +1700,8 @@ PR_FormatTime(char *buf, int buflen, const char *fmt, const PRExplodedTime *tm)
|| defined(NETBSD) || defined(OPENBSD) || defined(FREEBSD) \
|| defined(DARWIN) || defined(SYMBIAN) || defined(ANDROID)
a.tm_zone = NULL;
a.tm_gmtoff = tm->tm_params.tp_gmt_offset +
tm->tm_params.tp_dst_offset;
a.tm_gmtoff = time->tm_params.tp_gmt_offset +
time->tm_params.tp_dst_offset;
#endif
} else {
ap = NULL;

View File

@ -322,13 +322,21 @@ PR_IMPLEMENT(PRCondVar*) PR_NewCondVar(PRLock *lock)
PR_ASSERT(lock != NULL);
if (cv != NULL)
{
int rv = _PT_PTHREAD_COND_INIT(cv->cv, _pt_cvar_attr);
int rv = _PT_PTHREAD_COND_INIT(cv->cv, _pt_cvar_attr);
PR_ASSERT(0 == rv);
cv->lock = lock;
cv->notify_pending = 0;
if (0 == rv)
{
cv->lock = lock;
cv->notify_pending = 0;
#if defined(DEBUG)
pt_debug.cvars_created += 1;
pt_debug.cvars_created += 1;
#endif
}
else
{
PR_DELETE(cv);
cv = NULL;
}
}
return cv;
} /* PR_NewCondVar */
@ -337,10 +345,13 @@ PR_IMPLEMENT(void) PR_DestroyCondVar(PRCondVar *cvar)
{
if (0 > PR_ATOMIC_DECREMENT(&cvar->notify_pending))
{
PRIntn rv = pthread_cond_destroy(&cvar->cv); PR_ASSERT(0 == rv);
PRIntn rv = pthread_cond_destroy(&cvar->cv);
#if defined(DEBUG)
PR_ASSERT(0 == rv);
memset(cvar, 0xaf, sizeof(PRCondVar));
pt_debug.cvars_destroyed += 1;
#else
(void)rv;
#endif
PR_Free(cvar);
}
@ -1181,9 +1192,17 @@ PR_IMPLEMENT(PRCondVar*) PRP_NewNakedCondVar(void)
if (cv != NULL)
{
int rv;
rv = _PT_PTHREAD_COND_INIT(cv->cv, _pt_cvar_attr);
rv = _PT_PTHREAD_COND_INIT(cv->cv, _pt_cvar_attr);
PR_ASSERT(0 == rv);
cv->lock = _PR_NAKED_CV_LOCK;
if (0 == rv)
{
cv->lock = _PR_NAKED_CV_LOCK;
}
else
{
PR_DELETE(cv);
cv = NULL;
}
}
return cv;
} /* PRP_NewNakedCondVar */

View File

@ -680,7 +680,7 @@ PR_IMPLEMENT(PRThreadPriority) PR_GetThreadPriority(const PRThread *thred)
PR_IMPLEMENT(void) PR_SetThreadPriority(PRThread *thred, PRThreadPriority newPri)
{
PRIntn rv = -1;
PRIntn rv;
PR_ASSERT(NULL != thred);
@ -736,6 +736,8 @@ PR_IMPLEMENT(void) PR_SetThreadPriority(PRThread *thred, PRThreadPriority newPri
errno));
}
}
#else
(void)rv; /* rv is unused */
#endif
thred->priority = newPri;

View File

@ -111,6 +111,7 @@ CSRCS = \
prftest.c \
prftest1.c \
prftest2.c \
prfz.c \
primblok.c \
priotest.c \
provider.c \

View File

@ -227,6 +227,9 @@ prftest1.c
prftest2.c
Obsolete. Subsumed in prftest.c
prfz.c
Tests printf handling of (s)size_t formats
priotest.c
Limited use. Tests NSPR thread dispatching priority.

View File

@ -9,6 +9,7 @@
**
*/
#include "prenv.h"
#include "prmem.h"
#include "plgetopt.h"
#include <stdio.h>
@ -112,6 +113,83 @@ int main(int argc, char **argv)
if (verbose) printf("env: PR_GetEnv() worked after setting it. Found: %s\n", value );
}
/* ---------------------------------------------------------------------- */
/* check that PR_DuplicateEnvironment() agrees with PR_GetEnv() */
{
#if defined(XP_UNIX) && (!defined(DARWIN) || defined(HAVE_CRT_EXTERNS_H))
static const PRBool expect_failure = PR_FALSE;
#else
static const PRBool expect_failure = PR_TRUE;
#endif
char **i, **dupenv = PR_DuplicateEnvironment();
if ( NULL == dupenv ) {
if (expect_failure) {
if (verbose) printf("env: PR_DuplicateEnvironment failed, "
"as expected on this platform.\n");
} else {
if (debug) printf("env: PR_DuplicateEnvironment() failed.\n");
failedAlready = PR_TRUE;
}
} else {
unsigned found = 0;
if (expect_failure) {
if (debug) printf("env: PR_DuplicateEnvironment() succeeded, "
"but failure is expected on this platform.\n");
failedAlready = PR_TRUE;
} else {
if (verbose) printf("env: PR_DuplicateEnvironment() succeeded.\n");
}
for (i = dupenv; *i; i++) {
char *equals = strchr(*i, '=');
if ( equals == NULL ) {
if (debug) printf("env: PR_DuplicateEnvironment() returned a string"
" with no '=': %s\n", *i);
failedAlready = PR_TRUE;
} else {
/* We own this string, so we can temporarily alter it */
/* *i is the null-terminated name; equals + 1 is the value */
*equals = '\0';
if ( strcmp(*i, ENVNAME) == 0) {
found++;
if (verbose) printf("env: PR_DuplicateEnvironment() found " ENVNAME
" (%u so far).\n", found);
}
/* Multiple values for the same name can't happen, according to POSIX. */
value = PR_GetEnv(*i);
if ( value == NULL ) {
if (debug) printf("env: PR_DuplicateEnvironment() returned a name"
" which PR_GetEnv() failed to find: %s\n", *i);
failedAlready = PR_TRUE;
} else if ( strcmp(equals + 1, value) != 0) {
if (debug) printf("env: PR_DuplicateEnvironment() returned the wrong"
" value for %s: expected %s; found %s\n",
*i, value, equals + 1);
failedAlready = PR_TRUE;
} else {
if (verbose) printf("env: PR_DuplicateEnvironment() agreed with"
" PR_GetEnv() about %s\n", *i);
}
}
PR_Free(*i);
}
PR_Free(dupenv);
if (found != 1) {
if (debug) printf("env: PR_DuplicateEnvironment() found %u entries for " ENVNAME
" (expected 1)\n", found);
failedAlready = PR_TRUE;
} else {
if (verbose) printf("env: PR_DuplicateEnvironment() found 1 entry for " ENVNAME "\n");
}
}
}
/* ---------------------------------------------------------------------- */
/* un-set the variable, using RAW name... should not work */
envBuf = NewBuffer( ENVBUFSIZE );

76
nsprpub/pr/tests/prfz.c Normal file
View File

@ -0,0 +1,76 @@
/* 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/. */
/*
* This is a simple test of the PR_fprintf() function for size_t formats.
*/
#include "prprf.h"
#include <sys/types.h>
#include <limits.h>
#include <string.h>
int
main(int argc, char **argv)
{
char buffer[128];
size_t unsigned_small = 266;
ssize_t signed_small_p = 943;
ssize_t signed_small_n = -1;
size_t unsigned_max = SIZE_MAX;
size_t unsigned_min = 0;
ssize_t signed_max = SSIZE_MAX;
printf("Test: unsigned small '%%zu' : ");
PR_snprintf(buffer, sizeof(buffer), "%zu", unsigned_small);
if (strncmp(buffer, "266", sizeof(buffer)) != 0) {
printf("Failed, got '%s'\n", buffer);
return -1;
}
printf("OK\n");
printf("Test: signed small positive '%%zd' : ");
PR_snprintf(buffer, sizeof(buffer), "%zd", signed_small_p);
if (strncmp(buffer, "943", sizeof(buffer)) != 0) {
printf("Failed, got '%s'\n", buffer);
return -1;
}
printf("OK\n");
printf("Test: signed small negative '%%zd' : ");
PR_snprintf(buffer, sizeof(buffer), "%zd", signed_small_n);
if (strncmp(buffer, "-1", sizeof(buffer)) != 0) {
printf("Failed, got '%s'\n", buffer);
return -1;
}
printf("OK\n");
printf("Test: 0 '%%zu' : ");
PR_snprintf(buffer, sizeof(buffer), "%zu", unsigned_min);
if (strncmp(buffer, "0", sizeof(buffer)) != 0) {
printf("Failed, got '%s'\n", buffer);
return -1;
}
printf("OK\n");
printf("Test: SIZE_MAX '%%zx' : ");
PR_snprintf(buffer, sizeof(buffer), "%zx", unsigned_max);
if (strspn(buffer, "f") != sizeof(size_t) * 2) {
printf("Failed, got '%s'\n", buffer);
return -1;
}
printf("OK\n");
printf("Test: SSIZE_MAX '%%zx' : ");
PR_snprintf(buffer, sizeof(buffer), "%zx", signed_max);
if (*buffer != '7' ||
strspn(buffer + 1, "f") != sizeof(ssize_t) * 2 - 1) {
printf("Failed, got '%s'\n", buffer);
return -1;
}
printf("OK\n");
return 0;
}

View File

@ -310,6 +310,7 @@ $prog = shift; # Program to test
"poll_to",
"pollable",
"prftest",
"prfz",
"primblok",
"provider",
"prpollml",

View File

@ -140,6 +140,7 @@ poll_nm
poll_to
pollable
prftest
prfz
primblok
provider
prpollml

View File

@ -23,7 +23,7 @@
* This release (4.10.7) is backward compatible with the
* 4.0.x, 4.1.x, 4.2.x, 4.3.x, 4.4.x, 4.5.x, 4.6.x, 4.7.x,
* 4.8.x, 4.9.x, 4.10, 4.10.1, 4.10.2, 4.10.3, 4.10.4,
* 4.10.5, 4.10.6 and 4.10.7 releases.
* 4.10.5, 4.10.6, 4.10.7 and 4.10.8 releases.
* It, of course, is compatible with itself.
*/
static char *compatible_version[] = {
@ -39,7 +39,7 @@ static char *compatible_version[] = {
"4.9", "4.9.1", "4.9.2", "4.9.3", "4.9.4", "4.9.5",
"4.9.6",
"4.10", "4.10.1", "4.10.2", "4.10.3", "4.10.4",
"4.10.5", "4.10.6", "4.10.7",
"4.10.5", "4.10.6", "4.10.7", "4.10.8",
PR_VERSION
};
@ -55,7 +55,7 @@ static char *incompatible_version[] = {
"3.0", "3.0.1",
"3.1", "3.1.1", "3.1.2", "3.1.3",
"3.5", "3.5.1",
"4.10.9",
"4.10.10",
"4.11", "4.11.1",
"10.0", "11.1", "12.14.20"
};