]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Refactored regex options handling
authorFrancesco Chemolli <kinkie@squid-cache.org>
Wed, 28 Jul 2010 20:16:31 +0000 (22:16 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Wed, 28 Jul 2010 20:16:31 +0000 (22:16 +0200)
compat/GnuRegex.c
compat/GnuRegex.h
configure.in

index 88421057d3e63925b627ec8601e4ae64de69c21d..e55d98b9570c792702d37c1bdbebee7684014e5e 100644 (file)
@@ -4398,7 +4398,7 @@ regex_t *preg;
     preg->translate = NULL;
 }
 #endif /* USE_GNUREGEX */
-\f
+
 /*
  * Local variables:
  * make-backup-files: t
index d57a0c9c499dfbdeae9d59cc9f5dbbb5da7b8b11..65631bc503a3691dd681967cf5265b54ad3cf821 100644 (file)
@@ -410,7 +410,7 @@ extern "C" {
 
 #endif /* USE_GNUREGEX */
 #endif /* SQUID_REGEXP_LIBRARY_H */
-\f
+
 /*
  * Local variables:
  * make-backup-files: t
index 8740b9401025a1c59a14922af0d65817e67f2723..7234f95a3cc2ecc4f8927db70f14ce83a9b16d65 100644 (file)
@@ -130,8 +130,6 @@ SQUID_CC_GUESS_VARIANT
 SQUID_CC_GUESS_OPTIONS
 
 
-REGEXLIB=''    # -lregex
-# LIBREGEX=''  # libregex.a
 
 dnl find out the exe extension for this platform.
 dnl If it is not empty, use it for CGI as well.
@@ -2477,7 +2475,6 @@ else
    esac
   fi
 
-AC_CHECK_LIB(regex, regexec, [REGEXLIB="-lregex"])
 case "$host_os" in
 mingw|mingw32)
        AC_MSG_NOTICE([Use MSVCRT for math functions.])
@@ -2976,41 +2973,50 @@ if test "$enable_linux_netfilter" = "yes" && test "$with_libcap" != "yes" ; then
     # AC_DEFINEd later
 fi
 
+AC_CHECK_LIB(regex, regexec, [REGEXLIB="-lregex"],[REGEXLIB=''])
 AC_ARG_ENABLE(gnuregex,
   AS_HELP_STRING([--enable-gnuregex],
                  [Compile GNUregex.  Unless you have reason to use 
                  this option, you should not enable it.
                  This library file is usually only required on Windows and 
                  very old Unix boxes which do not have their own regex 
-                 library built in.]),
-[USE_GNUREGEX=$enableval])
-if test -z "$USE_GNUREGEX" ; then
+                 library built in.]), [
+SQUID_YESNO([$enableval],[unrecognized argument to --enable-gnuregex: $enableval])
+])
+if test "${enable_gnuregex:=auto}" = "auto" ; then
     case "$host" in
     *-sun-solaris2.[[0-4]])
-         USE_GNUREGEX="yes"
+         enable_gnuregex="yes"
          ;;
     *-next-nextstep*)
-         USE_GNUREGEX="yes"
+         enable_gnuregex="yes"
          ;;
     esac
 fi
 AC_MSG_CHECKING(if GNUregex needs to be compiled)
-if test -z "$USE_GNUREGEX"; then
-if test "$ac_cv_func_regcomp" = "no" || test "$USE_GNUREGEX" = "yes" ; then
-       USE_GNUREGEX="yes"
-else
-       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
-#include <regex.h>]], [[regex_t t; regcomp(&t,"",0);]])],[USE_GNUREGEX="no"],[USE_GNUREGEX="yes"])
+# gnuregex is autodetect, and we could not find the regexp calls
+if test "$enable_gnuregex" = "auto" -a "$ac_cv_func_regcomp" = "no"; then
+  enable_gnuregex="yes"
+fi
+# try detecting if it is needed
+if test "$enable_gnuregex" = "auto" ; then
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <sys/types.h>
+#include <regex.h> ]], [[
+regex_t t; regcomp(&t,"",0);]])],
+  [enable_gnuregex="no"],[enable_gnuregex="yes"])
 fi
+AC_MSG_RESULT($enable_gnuregex)
+if test "$enable_gnuregex" = "yes"; then
+  # for some reason (force-enable, test..) gnuregex was found as needed. Override any system lib
+  REGEXLIB=""
 fi
-AC_MSG_RESULT($USE_GNUREGEX)
-if test "$USE_GNUREGEX" = "yes"; then
-       # override system regex with ours. Not good. But what was asked for.
-       REGEXLIB=""
-       AC_DEFINE(USE_GNUREGEX,1,[Define if we should use GNU regex])
+#if no reason was found to enable gnuregex, disable it
+if test "$enable_gnuregex" = "auto" ; then
+  enable_gnuregex=no
 fi
+SQUID_DEFINE_BOOL(USE_GNUREGEX,$enable_gnuregex,[Define if we should use GNU regex])
 AC_SUBST(REGEXLIB)
-#AC_SUBST(LIBREGEX)
 
 dnl Not cached since people are likely to tune this
 AC_MSG_CHECKING(Default FD_SETSIZE value)