From 53f84f7cbafcb177406f8f7bcc890e626e72ca63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Mon, 12 Dec 2016 12:02:20 +0100 Subject: text-regex: add regex backend based on libtre While memory consumption should be improved, backward searches will still be slow, because they are implemented in terms of repeated forward searches. It needs to be investigated whether the underlying automaton can have its transitions reversed and essentially run backwards, as is the case in sam. --- configure | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'configure') diff --git a/configure b/configure index dc8f278..fe85ccf 100755 --- a/configure +++ b/configure @@ -25,6 +25,7 @@ Fine tuning of the installation directories: Optional features: --enable-lua build with Lua support [auto] --enable-lpeg build with support for statically linking to LPeg [auto] + --enable-tre build with TRE regex support [auto] --enable-selinux build with SELinux support [auto] --enable-acl build with POSIX ACL support [auto] @@ -115,6 +116,7 @@ MANDIR='$(PREFIX)/share/man' lua=auto lpeg=auto +tre=auto selinux=auto acl=auto @@ -133,6 +135,8 @@ case "$arg" in --disable-lua|--enable-lua=no) lua=no ;; --enable-lpeg|--enable-lpeg=yes) lpeg=yes ;; --disable-lpeg|--enable-lpeg=no) lpeg=no ;; +--enable-tre|--enable-tre=yes) tre=yes ;; +--disable-tre|--enable-tre=no) tre=no ;; --enable-selinux|--enable-selinux=yes) selinux=yes ;; --disable-selinux|--enable-selinux=no) selinux=no ;; --enable-acl|--enable-acl=yes) acl=yes ;; @@ -353,6 +357,50 @@ else fail "$0: cannot find libtermkey" fi +CONFIG_TRE=0 +REGEX_SRC=text-regex.c + +if test "$tre" != "no" ; then + + printf "checking for libtre... " + +cat > "$tmpc" < + +int main() { + regex_t preg; + tre_str_source *source = NULL; + regmatch_t pmatch[1]; + tre_regcomp(&preg, "\0", REG_EXTENDED); + tre_reguexec(&preg, source, 1, pmatch, 0); + tre_regfree(&preg); + return 0; +} +EOF + + if test "$have_pkgconfig" = "yes" ; then + CFLAGS_TRE=$(pkg-config --cflags tre 2>/dev/null) + LDFLAGS_TRE=$(pkg-config --libs tre 2>/dev/null) + fi + + if test -z "$LDFLAGS_TRE"; then + CFLAGS_TRE="" + LDFLAGS_TRE="-ltre" + fi + + if $CC $CFLAGS $CFLAGS_TRE "$tmpc" \ + $LDFLAGS $LDFLAGS_TRE -o "$tmpo" >/dev/null 2>&1; then + CONFIG_TRE=1 + REGEX_SRC=text-regex-tre.c + printf "%s\n" "yes" + else + printf "%s\n" "no" + CFLAGS_TRE="" + LDFLAGS_TRE="" + test "$tre" = "yes" && fail "$0: cannot find libtre" + fi +fi + CONFIG_LUA=0 # enabling builtin lpeg requires lua support @@ -537,6 +585,10 @@ CFLAGS_CURSES = $CFLAGS_CURSES LDFLAGS_CURSES = $LDFLAGS_CURSES CFLAGS_TERMKEY = $CFLAGS_TERMKEY LDFLAGS_TERMKEY = $LDFLAGS_TERMKEY +REGEX_SRC = $REGEX_SRC +CONFIG_TRE = $CONFIG_TRE +CFLAGS_TRE = $CFLAGS_TRE +LDFLAGS_TRE = $LDFLAGS_TRE CONFIG_LUA = $CONFIG_LUA CFLAGS_LUA = $CFLAGS_LUA LDFLAGS_LUA = $LDFLAGS_LUA -- cgit v1.2.3