Switch to VCL_REGEX

parent 24911df3
......@@ -27,7 +27,7 @@ SYNOPSIS
# Set creation
new <obj> = selector.set([BOOL case_sensitive]
[, BOOL allow_overlaps])
VOID <obj>.add(STRING [, STRING string] [, STRING regex]
VOID <obj>.add(STRING [, STRING string] [, REGEX regex]
[, BACKEND backend] [, INT integer] [, BOOL bool]
[, SUB sub])
VOID <obj>.create_stats()
......@@ -464,15 +464,15 @@ Examples::
.. _xset.add():
VOID xset.add(STRING, [STRING string], [STRING regex], [BACKEND backend], [INT integer], [BOOL bool], [SUB sub])
----------------------------------------------------------------------------------------------------------------
VOID xset.add(STRING, [STRING string], [REGEX regex], [BACKEND backend], [INT integer], [BOOL bool], [SUB sub])
---------------------------------------------------------------------------------------------------------------
::
VOID xset.add(
STRING,
[STRING string],
[STRING regex],
[REGEX regex],
[BACKEND backend],
[INT integer],
[BOOL bool],
......
......@@ -214,13 +214,13 @@ vmod_set_integer(VRT_CTX, struct vmod_selector_set * set, VCL_INT n,
return (set->table[idx]->integer);
}
static vre_t *
VCL_REGEX
get_re(VRT_CTX, const struct vmod_selector_set * const restrict set,
VCL_INT n, VCL_STRING element, VCL_ENUM const restrict selects,
const char * const restrict method)
{
unsigned idx;
vre_t *re;
VCL_REGEX re;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(set, VMOD_SELECTOR_SET_MAGIC);
......@@ -240,7 +240,7 @@ VCL_BOOL
vmod_set_re_match(VRT_CTX, struct vmod_selector_set *set, VCL_STRING subject,
VCL_INT n, VCL_STRING element, VCL_ENUM selects)
{
vre_t *re;
VCL_REGEX re;
re = get_re(ctx, set, n, element, selects, "re_match");
if (re == NULL)
......@@ -253,7 +253,7 @@ vmod_set_sub(VRT_CTX, struct vmod_selector_set *set, VCL_STRING str,
VCL_STRING sub, VCL_BOOL all, VCL_INT n, VCL_STRING element,
VCL_ENUM selects)
{
vre_t *re;
VCL_REGEX re;
re = get_re(ctx, set, n, element, selects, "sub");
if (re == NULL)
......
......@@ -462,7 +462,7 @@ client c1 {
logexpect l1 -wait
varnish v1 -errvcl {vmod selector failure: s.add(): cannot compile regular expression '(':} {
varnish v1 -errvcl {Regexp compilation error:} {
import ${vmod_selector};
backend b None;
......
......@@ -431,8 +431,6 @@ vmod_set__fini(struct vmod_selector_set **setp)
CHECK_OBJ_NOTNULL(entry,
VMOD_SELECTOR_ENTRY_MAGIC);
free(entry->string);
if (entry->re != NULL)
VRE_free(&entry->re);
FREE_OBJ(entry);
break;
}
......@@ -453,9 +451,7 @@ vmod_set_add(VRT_CTX, struct vmod_selector_set *set,
{
struct entry *entry;
unsigned n;
vre_t *re = NULL;
const char *error;
int erroffset;
VCL_REGEX re = NULL;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(set, VMOD_SELECTOR_SET_MAGIC);
......@@ -494,16 +490,8 @@ vmod_set_add(VRT_CTX, struct vmod_selector_set *set,
*m = tolower(*m);
}
if (args->valid_regex) {
/* XXX expose VRE options */
re = VRE_compile(args->regex, 0, &error, &erroffset);
if (re == NULL) {
VFAIL(ctx, "%s.add(): cannot compile regular expression"
" '%s': %s at offset %d", set->vcl_name,
args->regex, error, erroffset);
return;
}
}
if (args->valid_regex)
re = args->regex;
if (!args->valid_string && re == NULL && !args->valid_backend
&& !args->valid_integer && !args->valid_bool && !args->valid_sub)
......
......@@ -59,7 +59,7 @@ struct entry {
char *string;
VCL_BACKEND backend;
VCL_SUB sub;
vre_t *re;
VCL_REGEX re;
VCL_INT integer;
};
......
......@@ -23,7 +23,7 @@ SYNOPSIS
# Set creation
new <obj> = selector.set([BOOL case_sensitive]
[, BOOL allow_overlaps])
VOID <obj>.add(STRING [, STRING string] [, STRING regex]
VOID <obj>.add(STRING [, STRING string] [, REGEX regex]
[, BACKEND backend] [, INT integer] [, BOOL bool]
[, SUB sub])
VOID <obj>.create_stats()
......@@ -448,7 +448,7 @@ Examples::
# ...
}
$Method VOID .add(STRING, [STRING string], [STRING regex], [BACKEND backend],
$Method VOID .add(STRING, [STRING string], [REGEX regex], [BACKEND backend],
[INT integer], [BOOL bool], [SUB sub])
Add the given string to the set. As indicated above, elements added to
......
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