Commit af7001b1 authored by Geoff Simmons's avatar Geoff Simmons

Use the return value from RE2::Set:Add to get the index of a set match.

parent 87c01d5e
Pipeline #341 skipped
......@@ -623,13 +623,12 @@ vmod_set_add(VRT_CTX, struct vmod_re2_set *set, VCL_STRING pattern,
set->vcl_name, pattern, set->vcl_name);
return;
}
if ((err = vre2set_add(set->set, pattern)) != NULL) {
if ((err = vre2set_add(set->set, pattern, &n)) != NULL) {
VERR(ctx, ERR_PREFIX "Cannot compile '%.40s': %s",
set->vcl_name, pattern, pattern, err);
return;
}
n = set->npatterns;
if (string != NULL) {
if ((set->string = realloc(set->string,
(n + 1) * (sizeof(char *))))
......
......@@ -124,11 +124,11 @@ vre2set_init(vre2set **setp, anchor_e anchor, unsigned utf8,
}
const char *
vre2set_add(vre2set *set, const char * const pattern)
vre2set_add(vre2set *set, const char * const pattern, int * const idx)
{
try {
string err;
if (set->add(pattern, &err) == -1)
if ((*idx = set->add(pattern, &err)) < 0)
throw runtime_error(err);
return NULL;
}
......
......@@ -69,7 +69,8 @@ extern "C" {
unsigned case_sensitive, unsigned perl_classes,
unsigned word_boundary, unsigned one_line);
const char *vre2set_fini(vre2set **vre2);
const char *vre2set_add(vre2set *set, const char *pattern);
const char *vre2set_add(vre2set *set, const char *pattern,
int * const idx);
const char *vre2set_compile(vre2set *set);
const char *vre2set_match(vre2set *set, const char *subject,
int * const match, void *buf,
......
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