Unverified Commit 0ee2f4ae authored by Nils Goroll's avatar Nils Goroll

Use the VCL_REGEX type

parent 6a7486c2
......@@ -2,7 +2,7 @@ varnishtest "regex constructor errors"
varnish v1 -vcl { backend b { .host = "${bad_ip}"; } } -start
varnish v1 -errvcl {vmod re: error compiling regex} {
varnish v1 -errvcl {Regexp compilation error} {
import re from "${vmod_topbuild}/src/.libs/libvmod_re.so";
backend b { .host = "${bad_ip}"; }
......
......@@ -48,7 +48,7 @@
struct vmod_re_regex {
unsigned magic;
#define VMOD_RE_REGEX_MAGIC 0x955706ee
vre_t *vre;
VCL_REGEX vre;
struct vre_limits vre_limits;
};
......@@ -94,10 +94,9 @@ re_compile(const char *pattern, unsigned options, char *errbuf,
VCL_VOID
vmod_regex__init(VRT_CTX, struct vmod_re_regex **rep, const char *vcl_name,
VCL_STRING pattern, VCL_INT limit, VCL_INT limit_recursion)
VCL_REGEX vre, VCL_INT limit, VCL_INT limit_recursion)
{
struct vmod_re_regex *re;
vre_t *vre;
char errbuf[VRE_ERROR_LEN];
int erroffset;
const char *error;
......@@ -106,7 +105,7 @@ vmod_regex__init(VRT_CTX, struct vmod_re_regex **rep, const char *vcl_name,
AN(rep);
AZ(*rep);
AN(vcl_name);
AN(pattern);
AN(vre);
if (limit < 1) {
VRT_fail(ctx, "vmod re: invalid limit %ld in %s constructor",
......@@ -120,14 +119,6 @@ vmod_regex__init(VRT_CTX, struct vmod_re_regex **rep, const char *vcl_name,
return;
}
vre = re_compile(pattern, 0, errbuf, sizeof errbuf, &erroffset);
if (vre == NULL) {
VRT_fail(ctx, "vmod re: error compiling regex \"%s\" in %s "
"constructor: %s (at offset %d)", pattern, vcl_name,
errbuf, erroffset);
return;
}
ALLOC_OBJ(re, VMOD_RE_REGEX_MAGIC);
AN(re);
re->vre = vre;
......@@ -146,8 +137,6 @@ vmod_regex__fini(struct vmod_re_regex **rep)
re = *rep;
*rep = NULL;
CHECK_OBJ_NOTNULL(re, VMOD_RE_REGEX_MAGIC);
if (re->vre != NULL)
VRE_free(&re->vre);
FREE_OBJ(re);
}
......
......@@ -109,7 +109,7 @@ since it re-uses the compiled expression obtained at VCL
initialization. So if you are matching against a fixed pattern that
never changes during the lifetime of VCL, use ``match``.
$Object regex(STRING, INT limit=1000, INT limit_recursion=1000)
$Object regex(REGEX, INT limit=1000, INT limit_recursion=1000)
Description
Create a regex object with the given regular expression. The
......
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