]> granicus.if.org Git - php/commitdiff
Improve regex library selection. It lets user specify whether they want
authorSascha Schumann <sas@php.net>
Sat, 13 Nov 1999 16:51:33 +0000 (16:51 +0000)
committerSascha Schumann <sas@php.net>
Sat, 13 Nov 1999 16:51:33 +0000 (16:51 +0000)
system, apache, or php's regex library by using the --with-regex option.
"php" is the default; if you use --with-apache in combination with
Apache 1.3.x, the default is "apache".

15 files changed:
Makefile.am
acinclude.m4
configure.in
ext/ereg/ereg.c
ext/ereg/php_regex.h
ext/ereg/regex/regex_extra.h [new file with mode: 0644]
ext/ereg/regex/utils.h
ext/standard/config.m4
ext/standard/reg.c
main/php.h
main/php_regex.h
regex/regex_extra.h [new file with mode: 0644]
regex/utils.h
sapi/apache/config.m4
sapi/apache/libphp4.module.in

index 0c93b2beb4c684d7eb0a9b73d94a40c1dc4b5993..d57126e23641c74574a75562635e137161a04315 100644 (file)
@@ -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)
 
index 2364ee0416be306083e977331c36b606f2bbaa5c..489cf3001dd3cd40b13d32d6c1a5c0a5312c6778 100644 (file)
@@ -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)
 ])
index 56ebd3f6259a8c27557cd9333b061e364c9d3bca..78651a51d87ff19962be10522226c04395b65733 100644 (file)
@@ -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"
index 7f50ce317028bae1cd30c944701fa7e78850398b..bd40cb2191e34cdbe1ad699a5c9cc940d90648a1 100644 (file)
@@ -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) 
index 46618379af14f26301bc7811b56276f9a3dbd92b..91cbd994c41ddf195820699239b014c7ba3d5e1f 100644 (file)
@@ -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 (file)
index 0000000..b839ddc
--- /dev/null
@@ -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
index 1a997ac8fc166de4ce162938b67c10464982a489..cd4a96025f24a124ce97350c17a877942a510050 100644 (file)
@@ -1,4 +1,7 @@
 /* utility definitions */
+
+#include "regex_extra.h"
+
 #ifdef _POSIX2_RE_DUP_MAX
 #define        DUPMAX  _POSIX2_RE_DUP_MAX
 #else
index ce9a4682ef347548b2c67c0c09132e18279298bf..c6e9c578aec3bf227ae9222a3eb629579373e411 100644 (file)
@@ -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)
index 7f50ce317028bae1cd30c944701fa7e78850398b..bd40cb2191e34cdbe1ad699a5c9cc940d90648a1 100644 (file)
@@ -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) 
index a778c5dff674ebff14e587e3e25881f8c5a501a8..b0dd5cb7b4f9c578c622f970ea83ddc4767626ea 100644 (file)
@@ -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"
index 46618379af14f26301bc7811b56276f9a3dbd92b..91cbd994c41ddf195820699239b014c7ba3d5e1f 100644 (file)
@@ -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 (file)
index 0000000..b839ddc
--- /dev/null
@@ -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
index 1a997ac8fc166de4ce162938b67c10464982a489..cd4a96025f24a124ce97350c17a877942a510050 100644 (file)
@@ -1,4 +1,7 @@
 /* utility definitions */
+
+#include "regex_extra.h"
+
 #ifdef _POSIX2_RE_DUP_MAX
 #define        DUPMAX  _POSIX2_RE_DUP_MAX
 #else
index 1641fa6decdc9adccdf2d494632b1a5009234561..9aed624498b27c238e7687abeeaf70b23f3f0c05 100644 (file)
@@ -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
index 687c1c46ac1c7d0ccaa15f1d4b7916a436731eae..8ecf83ebaa042d675876a2d56d06522d765afd87 100644 (file)
@@ -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@"