Commit 4f64f9db authored by Geoff Simmons's avatar Geoff Simmons

remove the build dependency on pcre

parent eaa2d571
...@@ -29,41 +29,10 @@ if test "x$RST2MAN" = "xno"; then ...@@ -29,41 +29,10 @@ if test "x$RST2MAN" = "xno"; then
fi fi
AM_CONDITIONAL(HAVE_RST2MAN, [test "x$RST2MAN" != "xno"]) AM_CONDITIONAL(HAVE_RST2MAN, [test "x$RST2MAN" != "xno"])
# Check for pkg-config
PKG_PROG_PKG_CONFIG
# Checks for header files. # Checks for header files.
AC_HEADER_STDC AC_HEADER_STDC
AC_CHECK_HEADERS([stdlib.h]) AC_CHECK_HEADERS([stdlib.h])
AC_CHECK_HEADERS([pthread.h]) AC_CHECK_HEADERS([pthread.h])
if test -n $PKG_CONFIG; then
PKG_CHECK_MODULES([PCRE], [libpcre])
else
AC_CHECK_PROG(PCRE_CONFIG, pcre-config, pcre-config)
AC_ARG_WITH(pcre-config,
AS_HELP_STRING([--with-pcre-config=PATH],
[Location of PCRE pcre-config (auto)]),
[pcre_config="$withval"],
[pcre_config=""])
if test "x$pcre_config" != "x" ; then
AC_MSG_CHECKING(for $pcre_config)
if test -f $pcre_config ; then
PCRE_CONFIG=$pcre_config
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no - searching PATH)
fi
fi
if test "x$PCRE_CONFIG" = "x"; then
AC_CHECK_PROGS(PCRE_CONFIG, pcre-config)
fi
PCRE_CFLAGS=`$PCRE_CONFIG --cflags`
PCRE_LIBS=`$PCRE_CONFIG --libs`
fi
AC_SUBST(PCRE_CFLAGS)
AC_SUBST(PCRE_LIBS)
# Check for python # Check for python
AC_CHECK_PROGS(PYTHON, [python3 python3.1 python3.2 python2.7 python2.6 python2.5 python2 python], [AC_MSG_ERROR([Python is needed to build this vmod, please install python.])]) AC_CHECK_PROGS(PYTHON, [python3 python3.1 python3.2 python2.7 python2.6 python2.5 python2 python], [AC_MSG_ERROR([Python is needed to build this vmod, please install python.])])
......
AM_CPPFLAGS = @VMOD_INCLUDES@ @PCRE_CFLAGS@ AM_CPPFLAGS = @VMOD_INCLUDES@
vmoddir = @VMOD_DIR@ vmoddir = @VMOD_DIR@
vmod_LTLIBRARIES = libvmod_re.la vmod_LTLIBRARIES = libvmod_re.la
libvmod_re_la_LDFLAGS = -module -export-dynamic -avoid-version libvmod_re_la_LDFLAGS = -module -export-dynamic -avoid-version
libvmod_re_la_LIBADD = @PCRE_LIBS@
libvmod_re_la_SOURCES = \ libvmod_re_la_SOURCES = \
vcc_if.c \ vcc_if.c \
vcc_if.h \ vcc_if.h \
......
...@@ -32,8 +32,6 @@ ...@@ -32,8 +32,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <pthread.h> #include <pthread.h>
#include "pcre.h"
#include "vre.h" #include "vre.h"
#include "vrt.h" #include "vrt.h"
#include "cache/cache.h" #include "cache/cache.h"
...@@ -204,7 +202,7 @@ vmod_regex_backref(const struct vrt_ctx *ctx, struct vmod_re_regex *re, ...@@ -204,7 +202,7 @@ vmod_regex_backref(const struct vrt_ctx *ctx, struct vmod_re_regex *re,
ov_t *ov; ov_t *ov;
char *substr; char *substr;
unsigned l; unsigned l;
int s; size_t len;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(re, VMOD_RE_REGEX_MAGIC); CHECK_OBJ_NOTNULL(re, VMOD_RE_REGEX_MAGIC);
...@@ -238,18 +236,21 @@ vmod_regex_backref(const struct vrt_ctx *ctx, struct vmod_re_regex *re, ...@@ -238,18 +236,21 @@ vmod_regex_backref(const struct vrt_ctx *ctx, struct vmod_re_regex *re,
l = WS_Reserve(ctx->ws, 0); l = WS_Reserve(ctx->ws, 0);
substr = ctx->ws->f; substr = ctx->ws->f;
s = pcre_copy_substring(ov->subject, ov->ovector, ov->count, refnum, /* cf. pcre_copy_substring */
substr, l); refnum <<= 1;
if (s < 0) { assert(refnum + 1 < MAX_OV_USED);
len = ov->ovector[refnum+1] - ov->ovector[refnum];
if (len + 1 > l) {
VSLb(ctx->vsl, SLT_VCL_Error, VSLb(ctx->vsl, SLT_VCL_Error,
"vmod re: backref returned %d", s); "vmod re: insufficient workspace");
WS_Release(ctx->ws, 0); WS_Release(ctx->ws, 0);
return fallback; return fallback;
} }
if (s + 1 > l) assert(len <= strlen(ov->subject + ov->ovector[refnum]) + 1);
VSLb(ctx->vsl, SLT_VCL_Error, "vmod re: insufficient workspace," memcpy(substr, ov->subject + ov->ovector[refnum], len);
" backref string truncated"); substr[len] = '\0';
WS_Release(ctx->ws, s + 1);
WS_Release(ctx->ws, len + 1);
return substr; return substr;
} }
......
...@@ -139,14 +139,6 @@ VMOD on a system where an instance of Varnish 4 is installed, and the ...@@ -139,14 +139,6 @@ VMOD on a system where an instance of Varnish 4 is installed, and the
auto-tools will attempt to locate the Varnish instance, and then pull auto-tools will attempt to locate the Varnish instance, and then pull
in libraries and other support files from there. in libraries and other support files from there.
This VMOD also requires a development version of the PCRE library for
the build (commonly in a package called ``pcre-devel`` in most Unix
distributions). The auto-tools attempt to use ``pcre-config`` to
determine compiler and linker options for PCRE.
Since the PCRE runtime library is already required for Varnish, the
VMOD adds no additional requirements for the runtime.
Quick start Quick start
----------- -----------
...@@ -174,11 +166,6 @@ before running ``configure``: ...@@ -174,11 +166,6 @@ before running ``configure``:
* export ACLOCAL_PATH=$PREFIX/share/aclocal * export ACLOCAL_PATH=$PREFIX/share/aclocal
* export PATH=$PREFIX/bin:$PREFIX/sbin:$PATH * export PATH=$PREFIX/bin:$PREFIX/sbin:$PATH
If ``pcre-config`` is not on your ``PATH``, call ``configure`` with
the option ``--with-pcre-config=/path/to/pcre-config``. Alternatively,
you can specify compiler and linker options for pcre by setting the
environment variables ``PCRE_CFLAGS`` and ``PCRE_LIBS``, respectively.
``configure`` must locate the ``varnishtest`` and ``varnishd`` ``configure`` must locate the ``varnishtest`` and ``varnishd``
binaries so that ``make check`` can be run. Usually it should be able binaries so that ``make check`` can be run. Usually it should be able
to find them, but if necessary you can set the variables to find them, but if necessary you can set the variables
......
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