Commit 2d9b49ff authored by Geoff Simmons's avatar Geoff Simmons

configure checks if RE2 allows a NULL pointer for the vector in

Set::Match(); this makes the VMOD compatible with RE2 since at
least version 2015-05-01.
parent d96f1c49
...@@ -81,6 +81,33 @@ AC_PATH_PROG([VARNISHD], [varnishd], [], ...@@ -81,6 +81,33 @@ AC_PATH_PROG([VARNISHD], [varnishd], [],
PKG_CHECK_MODULES([RE2], [re2]) PKG_CHECK_MODULES([RE2], [re2])
# RE2 versions up to 2016-03-01 require a pointer to vector<int> in
# Set::Match(), to identify the regex that was matched. Since commit
# df7a2dc in re2, the pointer may be NULL, if we just want to know
# whether there was a match. This check tests for that feature.
# Note: the test may cause a core dump if it fails.
AC_LANG(C++)
SAVE_CXXFLAGS="$CXXFLAGS"
SAVE_LDFLAGS="$LDFLAGS"
CXXFLAGS+=" -std=c++11"
LDFLAGS+=" -lre2"
AC_RUN_IFELSE(
[AC_LANG_SOURCE([[
#include "re2/set.h"
main() {
re2::RE2::Set s(re2::RE2::DefaultOptions, re2::RE2::UNANCHORED);
s.Add("", NULL);
s.Compile();
s.Match("", NULL);
}
]])],
[AC_DEFINE([HAVE_SET_MATCH_NULL_VECTOR], [1],
[Define to 1 if RE2 Set::Match() permits a NULL vector])]
)
CXXFLAGS="$SAVE_CXXFLAGS"
LDFLAGS="$SAVE_LDFLAGS"
AC_LANG(C)
# --enable-stack-protector # --enable-stack-protector
AC_ARG_ENABLE(stack-protector, AC_ARG_ENABLE(stack-protector,
AS_HELP_STRING([--enable-stack-protector],[enable stack protector (default is YES)]), AS_HELP_STRING([--enable-stack-protector],[enable stack protector (default is YES)]),
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
* *
*/ */
#include "config.h"
#include "vre2set.h" #include "vre2set.h"
#define CATCHALL \ #define CATCHALL \
...@@ -70,7 +71,12 @@ vre2set::compile() const ...@@ -70,7 +71,12 @@ vre2set::compile() const
inline bool inline bool
vre2set::match(const char* subject) const vre2set::match(const char* subject) const
{ {
#ifdef HAVE_SET_MATCH_NULL_VECTOR
return set_->Match(subject, NULL); return set_->Match(subject, NULL);
#else
vector<int> v;
return set_->Match(subject, &v);
#endif
} }
const char * const char *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment