summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-rw-r--r--acinclude.m418
-rw-r--r--configure.in2
-rw-r--r--ext/ereg/ereg.c2
-rw-r--r--ext/ereg/php_regex.h4
-rw-r--r--ext/ereg/regex/regex_extra.h14
-rw-r--r--ext/ereg/regex/utils.h3
-rw-r--r--ext/standard/config.m422
-rw-r--r--ext/standard/reg.c2
-rw-r--r--main/php.h4
-rw-r--r--main/php_regex.h4
-rw-r--r--regex/regex_extra.h14
-rw-r--r--regex/utils.h3
-rw-r--r--sapi/apache/config.m422
-rw-r--r--sapi/apache/libphp4.module.in2
15 files changed, 89 insertions, 29 deletions
diff --git a/Makefile.am b/Makefile.am
index 0c93b2beb4..d57126e236 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
AUTOMAKE_OPTIONS = foreign
ZEND_DIR = $(srcdir)/libzend
-SUBDIRS = libzend ext sapi $(TSRM_DIR) regex
+SUBDIRS = libzend ext sapi $(TSRM_DIR) $(REGEX_DIR)
BUILDLDFLAGS = $(EXTRA_LDFLAGS) $(LDFLAGS)
diff --git a/acinclude.m4 b/acinclude.m4
index 2364ee0416..489cf3001d 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -146,21 +146,23 @@ AC_DEFUN(AC_CHECK_CC_OPTION,[
fi
])
-AC_DEFUN(PHP_HSREGEX,[
+AC_DEFUN(PHP_REGEX,[
-test -z "$HSREGEX" && HSREGEX="$WANT_HSREGEX"
-AC_MSG_CHECKING(whether to use bundled regex library)
-AC_MSG_RESULT($HSREGEX)
-
-if test "$HSREGEX" = "yes"; then
+if test "$REGEX_TYPE" = "php"; then
REGEX_LIB=regex/libregex.la
+ REGEX_DIR=regex
AC_DEFINE(HSREGEX)
AC_DEFINE(REGEX,1)
-else
- REGEX_LIB=
+elif test "$REGEX_TYPE" = "system"; then
AC_DEFINE(REGEX,0)
+elif test "$REGEX_TYPE" = "apache"; then
+ AC_DEFINE(REGEX,2)
fi
+AC_MSG_CHECKING(which regex library to use)
+AC_MSG_RESULT($REGEX_TYPE)
+
+AC_SUBST(REGEX_DIR)
AC_SUBST(REGEX_LIB)
AC_SUBST(HSREGEX)
])
diff --git a/configure.in b/configure.in
index 56ebd3f625..78651a51d8 100644
--- a/configure.in
+++ b/configure.in
@@ -629,7 +629,7 @@ if test "$enable_debug" != "yes"; then
AM_SET_LIBTOOL_VARIABLE([--silent])
fi
-PHP_HSREGEX
+PHP_REGEX
dnl If we are using gcc and the user has not specified CFLAGS, add -O2.
test -n "$auto_cflags" && test -n "$GCC" && CFLAGS="$CFLAGS -O2"
diff --git a/ext/ereg/ereg.c b/ext/ereg/ereg.c
index 7f50ce3170..bd40cb2191 100644
--- a/ext/ereg/ereg.c
+++ b/ext/ereg/ereg.c
@@ -92,7 +92,9 @@ static int _free_reg_cache(reg_cache *rc)
return 1;
}
+#undef regfree
#define regfree(a);
+#undef regcomp
#define regcomp(a,b,c) _php_regcomp(a,b,c)
static void php_reg_init_globals(php_reg_globals *reg_globals)
diff --git a/ext/ereg/php_regex.h b/ext/ereg/php_regex.h
index 46618379af..91cbd994c4 100644
--- a/ext/ereg/php_regex.h
+++ b/ext/ereg/php_regex.h
@@ -1,7 +1,7 @@
#ifndef _PHP_REGEX_H
#define _PHP_REGEX_H
-#if REGEX
+#if REGEX == 1
#include "regex/regex.h"
#ifndef _REGEX_H
#define _REGEX_H 1 /* this should stop Apache from loading the system version of regex.h */
@@ -18,7 +18,7 @@
#ifndef _H_REGEX
#define _H_REGEX 1 /* This one is for AIX */
#endif
-#else
+#elif REGEX == 0
#include <regex.h>
#endif
diff --git a/ext/ereg/regex/regex_extra.h b/ext/ereg/regex/regex_extra.h
new file mode 100644
index 0000000000..b839ddc2ad
--- /dev/null
+++ b/ext/ereg/regex/regex_extra.h
@@ -0,0 +1,14 @@
+
+#undef regexec
+#undef regerror
+#undef regfree
+#undef regcomp
+
+#if (defined(REGEX) && REGEX == 1) || (!defined(REGEX))
+
+#define regexec php_regexec
+#define regerror php_regerror
+#define regfree php_regfree
+#define regcomp php_regcomp
+
+#endif
diff --git a/ext/ereg/regex/utils.h b/ext/ereg/regex/utils.h
index 1a997ac8fc..cd4a96025f 100644
--- a/ext/ereg/regex/utils.h
+++ b/ext/ereg/regex/utils.h
@@ -1,4 +1,7 @@
/* utility definitions */
+
+#include "regex_extra.h"
+
#ifdef _POSIX2_RE_DUP_MAX
#define DUPMAX _POSIX2_RE_DUP_MAX
#else
diff --git a/ext/standard/config.m4 b/ext/standard/config.m4
index ce9a4682ef..c6e9c578ae 100644
--- a/ext/standard/config.m4
+++ b/ext/standard/config.m4
@@ -123,18 +123,24 @@ AC_CHECK_FUNCS(getwd)
divert(3)
-AC_ARG_WITH(system-regex,
-[ --with-system-regex Do not use the bundled regex library],
+AC_ARG_WITH(regex,
+[ --with-regex=TYPE regex library type: system, apache, php],
[
- if test "$withval" = "no"; then
- WANT_HSREGEX=yes
- else
- WANT_HSREGEX=no
- fi
+ REGEX_TYPE=$withval
],[
- WANT_HSREGEX=yes
+ REGEX_TYPE=php
])
+AC_ARG_WITH(system-regex,
+[ --with-system-regex (deprecated) Use system regex library],
+[
+ if test "$withval" = "yes"; then
+ REGEX_TYPE=system
+ else
+ REGEX_TYPE=php
+ fi
+])
+
AC_CRYPT_CAP
PHP_EXTENSION(standard)
diff --git a/ext/standard/reg.c b/ext/standard/reg.c
index 7f50ce3170..bd40cb2191 100644
--- a/ext/standard/reg.c
+++ b/ext/standard/reg.c
@@ -92,7 +92,9 @@ static int _free_reg_cache(reg_cache *rc)
return 1;
}
+#undef regfree
#define regfree(a);
+#undef regcomp
#define regcomp(a,b,c) _php_regcomp(a,b,c)
static void php_reg_init_globals(php_reg_globals *reg_globals)
diff --git a/main/php.h b/main/php.h
index a778c5dff6..b0dd5cb7b4 100644
--- a/main/php.h
+++ b/main/php.h
@@ -203,6 +203,10 @@ extern char *strerror(int);
#define UNBLOCK_INTERRUPTIONS unblock_alarms
#endif
+#if REGEX == 1 || REGEX == 0
+#include "regex/regex_extra.h"
+#endif
+
#if HAVE_PWD_H
# if WIN32||WINNT
#include "win32/pwd.h"
diff --git a/main/php_regex.h b/main/php_regex.h
index 46618379af..91cbd994c4 100644
--- a/main/php_regex.h
+++ b/main/php_regex.h
@@ -1,7 +1,7 @@
#ifndef _PHP_REGEX_H
#define _PHP_REGEX_H
-#if REGEX
+#if REGEX == 1
#include "regex/regex.h"
#ifndef _REGEX_H
#define _REGEX_H 1 /* this should stop Apache from loading the system version of regex.h */
@@ -18,7 +18,7 @@
#ifndef _H_REGEX
#define _H_REGEX 1 /* This one is for AIX */
#endif
-#else
+#elif REGEX == 0
#include <regex.h>
#endif
diff --git a/regex/regex_extra.h b/regex/regex_extra.h
new file mode 100644
index 0000000000..b839ddc2ad
--- /dev/null
+++ b/regex/regex_extra.h
@@ -0,0 +1,14 @@
+
+#undef regexec
+#undef regerror
+#undef regfree
+#undef regcomp
+
+#if (defined(REGEX) && REGEX == 1) || (!defined(REGEX))
+
+#define regexec php_regexec
+#define regerror php_regerror
+#define regfree php_regfree
+#define regcomp php_regcomp
+
+#endif
diff --git a/regex/utils.h b/regex/utils.h
index 1a997ac8fc..cd4a96025f 100644
--- a/regex/utils.h
+++ b/regex/utils.h
@@ -1,4 +1,7 @@
/* utility definitions */
+
+#include "regex_extra.h"
+
#ifdef _POSIX2_RE_DUP_MAX
#define DUPMAX _POSIX2_RE_DUP_MAX
#else
diff --git a/sapi/apache/config.m4 b/sapi/apache/config.m4
index 1641fa6dec..9aed624498 100644
--- a/sapi/apache/config.m4
+++ b/sapi/apache/config.m4
@@ -16,11 +16,6 @@ AC_ARG_WITH(apxs,
XML_INCLUDE="$APXS_INCLUDEDIR/xml"
fi
AC_ADD_INCLUDE($APXS_INCLUDEDIR)
- if test -n "`$APXS -q CFLAGS | grep USE_HSREGEX`"; then
- HSREGEX=yes
- else
- HSREGEX=no
- fi
PHP_EXTENSION(apache)
PHP_SAPI=apache
APACHE_INSTALL="$APXS -i -a -n php4 $SAPI_SHARED"
@@ -64,6 +59,7 @@ AC_ARG_WITH(apache,
fi
# For Apache 1.3.x
elif test -f $withval/src/main/httpd.h; then
+ APACHE_HAS_REGEX=1
APACHE_INCLUDE="-I$withval/src/main -I$withval/src/os/unix -I$withval/src/ap"
APACHE_TARGET=$withval/src/modules/php4
if test ! -d $APACHE_TARGET; then
@@ -90,6 +86,7 @@ AC_ARG_WITH(apache,
fi
# Also for Apache 1.3.x
elif test -f $withval/src/include/httpd.h; then
+ APACHE_HAS_REGEX=1
APACHE_INCLUDE="-I$withval/src/include -I$withval/src/os/unix"
APACHE_TARGET=$withval/src/modules/php4
if test -d $withval/src/lib/expat-lite ; then
@@ -177,8 +174,21 @@ AC_ARG_WITH(mod_charset,
AC_MSG_RESULT(no)
])
+if test "$with_regex" = "apache" && test -z "$APACHE_HAS_REGEX"; then
+ with_regex=php
+fi
+
+if test -z "$with_regex" && test -n "$APACHE_HAS_REGEX"; then
+ with_regex=apache
+fi
+
if test -n "$APACHE_MODULE"; then
- HSREGEX=no
+ if test "$with_regex" = "apache"; then
+ APACHE_WANT_HSREGEX=yes
+ else
+ APACHE_WANT_HSREGEX=no
+ fi
+ AC_SUBST(APACHE_WANT_HSREGEX)
PHP_EXTENSION(apache)
PHP_OUTPUT(sapi/apache/libphp4.module)
PHP_BUILD_STATIC
diff --git a/sapi/apache/libphp4.module.in b/sapi/apache/libphp4.module.in
index 687c1c46ac..8ecf83ebaa 100644
--- a/sapi/apache/libphp4.module.in
+++ b/sapi/apache/libphp4.module.in
@@ -1,6 +1,6 @@
Name: php4_module
ConfigStart
- RULE_WANTHSREGEX=@HSREGEX@
+ RULE_WANTHSREGEX=@APACHE_WANT_HSREGEX@
LIBS="@NATIVE_RPATHS@ @PHP_LIBS@ @EXTRA_LIBS@ @LIBS@ $LIBS"
RULE_HIDE=yes
CFLAGS="$CFLAGS -I@abs_srcdir@ -I@abs_srcdir@/libzend -I@abs_builddir@/libzend -I@abs_builddir@"