cvs: /php4 strtok_r.c /php4 Makefile.am configure.in php_reentrancy.h reentrancy.c
| From: | Sascha Schumann | Date: | Fri, 26 Nov 1999 17:34:25 +0000 |
| Subject: | cvs: /php4 strtok_r.c /php4 Makefile.am configure.in php_reentrancy.h reentrancy.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-6940@lists.php.net to get a copy of this message | ||
sas Fri Nov 26 12:34:25 1999 EDT
Removed files:
/php4 strtok_r.c
Modified files:
/php4 Makefile.am configure.in php_reentrancy.h reentrancy.c
Log:
- move strtok_r into reentrancy.c
- add rand_r()
Index: php4/Makefile.am
diff -u php4/Makefile.am:1.14 php4/Makefile.am:1.15
--- php4/Makefile.am:1.14 Fri Nov 26 12:07:41 1999
+++ php4/Makefile.am Fri Nov 26 12:33:53 1999
@@ -11,7 +11,7 @@
configuration-parser.y configuration-scanner.l request_info.c \
safe_mode.c fopen-wrappers.c php3_realpath.c alloca.c \
php_ini.c SAPI.c rfc1867.c dlist.c php_content_types.c strlcpy.c \
- strlcat.c mergesort.c strtok_r.c reentrancy.c
+ strlcat.c mergesort.c reentrancy.c
libphp4_la_DEPENDENCIES = \
libzend/libzend.la \
Index: php4/configure.in
diff -u php4/configure.in:1.41 php4/configure.in:1.42
--- php4/configure.in:1.41 Fri Nov 26 12:07:41 1999
+++ php4/configure.in Fri Nov 26 12:33:53 1999
@@ -1,4 +1,4 @@
-dnl ## $Id: configure.in,v 1.41 1999/11/26 17:07:41 sas Exp $ -*- sh -*-
+dnl ## $Id: configure.in,v 1.42 1999/11/26 17:33:53 sas Exp $ -*- sh -*-
dnl ## Process this file with autoconf to produce a configure script.
divert(0)
@@ -312,6 +312,7 @@
mmap \
putenv \
random \
+rand_r \
regcomp \
rint \
setitimer \
@@ -330,6 +331,7 @@
strerror \
strftime \
strstr \
+strtok_r \
symlink \
tempnam \
tzset \
@@ -339,7 +341,7 @@
vsnprintf \
)
-AC_REPLACE_FUNCS(strlcat strlcpy strtok_r getopt)
+AC_REPLACE_FUNCS(strlcat strlcpy getopt)
AC_FUNC_UTIME_NULL
AC_FUNC_ALLOCA
dnl## OLDLIBS=$LIBS; LIBS=""
Index: php4/php_reentrancy.h
diff -u php4/php_reentrancy.h:1.2 php4/php_reentrancy.h:1.3
--- php4/php_reentrancy.h:1.2 Fri Nov 26 12:12:00 1999
+++ php4/php_reentrancy.h Fri Nov 26 12:33:53 1999
@@ -60,8 +60,21 @@
struct tm *gmtime_r(const time_t *const timep, struct tm *p_tm);
#endif
+#if !defined(HAVE_STRTOK_R)
+#define strtok_r php_strtok_r
+char *strtok_r(char *s, const char *delim, char **last);
+#endif
-#if defined(ZTS) && defined(PHP_NEED_REENTRANCY)
+#if !defined(HAVE_RAND_R)
+#define rand_r php_rand_r
+int rand_r(unsigned int *seed);
+#endif
+
+#if !defined(ZTS)
+#undef PHP_NEED_REENTRANCY
+#endif
+
+#if defined(PHP_NEED_REENTRANCY)
void reentrancy_startup(void);
void reentrancy_shutdown(void);
#else
Index: php4/reentrancy.c
diff -u php4/reentrancy.c:1.2 php4/reentrancy.c:1.3
--- php4/reentrancy.c:1.2 Fri Nov 26 12:12:00 1999
+++ php4/reentrancy.c Fri Nov 26 12:33:53 1999
@@ -28,7 +28,6 @@
NUMBER_OF_LOCKS
};
-
#if defined(ZTS)
#include <TSRM.h>
@@ -118,7 +117,7 @@
#endif
-#if defined(PHP_NEED_REENTRANCY) && defined(ZTS)
+#if defined(PHP_NEED_REENTRANCY)
void reentrancy_shutdown(void)
{
@@ -136,6 +135,176 @@
for (i = 0; i < NUMBER_OF_LOCKS; i++) {
tsrm_mutex_destroy(reentrant_locks[i]);
}
+}
+
+#endif
+
+#ifndef HAVE_RAND_R
+
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Posix rand_r function added May 1999 by Wes Peters <wes@softweyr.com>.
+ */
+
+#include <sys/types.h>
+#include <stdlib.h>
+
+static int
+do_rand(unsigned long *ctx)
+{
+ return ((*ctx = *ctx * 1103515245 + 12345) % ((u_long)RAND_MAX + 1));
+}
+
+
+int
+rand_r(unsigned int *ctx)
+{
+ u_long val = (u_long) *ctx;
+ *ctx = do_rand(&val);
+ return (int) *ctx;
+}
+
+#endif
+
+
+#ifndef HAVE_STRTOK_R
+
+/*
+ * Copyright (c) 1998 Softweyr LLC. All rights reserved.
+ *
+ * strtok_r, from Berkeley strtok
+ * Oct 13, 1998 by Wes Peters <wes@softweyr.com>
+ *
+ * Copyright (c) 1988, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notices, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notices, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ *
+ * This product includes software developed by Softweyr LLC, the
+ * University of California, Berkeley, and its contributors.
+ *
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY SOFTWEYR LLC, THE REGENTS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTWEYR LLC, THE
+ * REGENTS, OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stddef.h>
+#include <string.h>
+
+char *
+strtok_r(char *s, const char *delim, char **last)
+{
+ char *spanp;
+ int c, sc;
+ char *tok;
+
+ if (s == NULL && (s = *last) == NULL)
+ {
+ return NULL;
+ }
+
+ /*
+ * Skip (span) leading delimiters (s += strspn(s, delim), sort of).
+ */
+cont:
+ c = *s++;
+ for (spanp = (char *)delim; (sc = *spanp++) != 0; )
+ {
+ if (c == sc)
+ {
+ goto cont;
+ }
+ }
+
+ if (c == 0) /* no non-delimiter characters */
+ {
+ *last = NULL;
+ return NULL;
+ }
+ tok = s - 1;
+
+ /*
+ * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
+ * Note that delim must have one NUL; we stop if we see that, too.
+ */
+ for (;;)
+ {
+ c = *s++;
+ spanp = (char *)delim;
+ do
+ {
+ if ((sc = *spanp++) == c)
+ {
+ if (c == 0)
+ {
+ s = NULL;
+ }
+ else
+ {
+ char *w = s - 1;
+ *w = '\0';
+ }
+ *last = s;
+ return tok;
+ }
+ }
+ while (sc != 0);
+ }
+ /* NOTREACHED */
}
#endif