Commit 92ef0fa9 authored by Geoff Simmons's avatar Geoff Simmons

Add the EXACT selector.

parent 99818aae
......@@ -161,7 +161,7 @@ INT xset.which(ENUM select)
::
INT xset.which(
ENUM {UNIQUE, FIRST, LAST, SHORTEST, LONGEST} select=UNIQUE
ENUM {UNIQUE, EXACT, FIRST, LAST, SHORTEST, LONGEST} select=UNIQUE
)
Returns ...
......
......@@ -278,6 +278,10 @@ pt_search(const struct pt_y * const restrict y,
match->min = y->idx;
if (y->idx > match->max)
match->max = y->idx;
if (*c == '\0') {
match->exact = y->idx;
return (0);
}
}
if (i < y->len)
......@@ -306,6 +310,7 @@ PT_Prefixes(const struct pt_y * const restrict root,
match->n = 0;
match->min = UINT_MAX;
match->max = 0;
match->exact = UINT_MAX;
return (pt_search(root, strings, (unsigned char *)subject, match));
}
......
......@@ -40,6 +40,7 @@ struct match_data {
unsigned *indices;
unsigned limit;
unsigned n;
unsigned exact;
unsigned min;
unsigned max;
};
......
This diff is collapsed.
......@@ -387,6 +387,8 @@ select(VRT_CTX, const struct match_data * const restrict match,
}
return match->indices[0];
}
if (selects == vmod_enum_EXACT)
return match->exact;
if (selects == vmod_enum_FIRST)
return match->min;
if (selects == vmod_enum_LAST)
......
......@@ -94,7 +94,8 @@ Example::
# ...
}
$Method INT .which(ENUM {UNIQUE, FIRST, LAST, SHORTEST, LONGEST} select=UNIQUE)
$Method INT .which(ENUM {UNIQUE, EXACT, FIRST, LAST, SHORTEST, LONGEST}
select=UNIQUE)
Returns ...
......
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