Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-re2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-re2
Commits
47ac7eca
Commit
47ac7eca
authored
Oct 22, 2017
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the set.which() method.
parent
2cc6a0a9
Pipeline
#347
skipped
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
1 deletion
+37
-1
README.rst
README.rst
+9
-0
set_retrieve.vtc
src/tests/set_retrieve.vtc
+18
-1
vmod_re2.c
src/vmod_re2.c
+8
-0
vmod_re2.vcc
src/vmod_re2.vcc
+2
-0
No files found.
README.rst
View file @
47ac7eca
...
...
@@ -975,6 +975,15 @@ Example::
+ " patterns from the set");
}
.. _func_set.which:
set.which
---------
::
INT set.which(ENUM {FIRST,LAST} select=0)
.. _func_set.string:
set.string
...
...
src/tests/set_retrieve.vtc
View file @
47ac7eca
# looks like -*- vcl -*-
varnishtest "set .string() and .backend() methods"
varnishtest "set .
which(), .
string() and .backend() methods"
varnish v1 -vcl {
import ${vmod_re2};
...
...
@@ -25,22 +25,29 @@ varnish v1 -vcl {
set resp.http.s-str-1 = s.string(1);
set resp.http.s-str-2 = s.string(2);
set resp.http.s-before-match = s.string();
set resp.http.s-which-b4-match = s.which();
set resp.http.s-foo-match = s.match("foo");
set resp.http.s-foo-n = s.nmatches();
set resp.http.s-foo-which = s.which();
set resp.http.s-foo-str = s.string();
set resp.http.s-bar-match = s.match("bar");
set resp.http.s-bar-n = s.nmatches();
set resp.http.s-bar-which = s.which();
set resp.http.s-bar-str = s.string();
set resp.http.s-bar-str-0 = s.string(0);
set resp.http.s-bar-str-1 = s.string(-1);
set resp.http.s-fail-match = s.match("fail");
set resp.http.s-fail-n = s.nmatches();
set resp.http.s-fail-which = s.which();
set resp.http.s-fail-str = s.string();
set resp.http.s-many-match = s.match("foobar");
set resp.http.s-many-n = s.nmatches();
set resp.http.s-many-str = s.string();
set resp.http.s-many-first = s.string(select=FIRST);
set resp.http.s-many-last = s.string(select=LAST);
set resp.http.s-which-many = s.which();
set resp.http.s-which-first = s.which(select=FIRST);
set resp.http.s-which-last = s.which(select=LAST);
set resp.http.s-outofrange = s.string(3);
set resp.http.n-str-1 = n.string(1);
...
...
@@ -60,22 +67,29 @@ client c1 {
expect resp.http.s-str-1 == "baz"
expect resp.http.s-str-2 == "quux"
expect resp.http.s-before-match == ""
expect resp.http.s-which-b4-match == "0"
expect resp.http.s-foo-match == "true"
expect resp.http.s-foo-n == 1
expect resp.http.s-foo-which == 1
expect resp.http.s-foo-str == "baz"
expect resp.http.s-bar-match == "true"
expect resp.http.s-bar-n == 1
expect resp.http.s-bar-which == 2
expect resp.http.s-bar-str == "quux"
expect resp.http.s-bar-str-0 == resp.http.s-bar-str
expect resp.http.s-bar-str-1 == resp.http.s-bar-str
expect resp.http.s-fail-match == "false"
expect resp.http.s-fail-n == 0
expect resp.http.s-fail-which == 0
expect resp.http.s-fail-str == ""
expect resp.http.s-many-match == "true"
expect resp.http.s-many-n == 2
expect resp.http.s-many-str == ""
expect resp.http.s-many-first == "baz"
expect resp.http.s-many-last == "quux"
expect resp.http.s-which-many == 0
expect resp.http.s-which-first == 1
expect resp.http.s-which-last == 2
expect resp.http.s-outofrange == ""
expect resp.http.n-str-1 == ""
expect resp.http.n-str-2 == ""
...
...
@@ -89,8 +103,11 @@ logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" {
expect 0 * Begin req
expect * = VCL_Error "^vmod re2 error: s.string.. called without prior match$"
expect * = VCL_Error "^vmod re2 error: s.which.. called without prior match$"
expect * = VCL_Error "^vmod re2 error: s.which.0.: previous match was unsuccessful$"
expect * = VCL_Error "^vmod re2 error: s.string.0.: previous match was unsuccessful$"
expect * = VCL_Error "^vmod re2 error: s.string.0.: 2 successful matches$"
expect * = VCL_Error "^vmod re2 error: s.which.0.: 2 successful matches$"
expect * = VCL_Error "^vmod re2 error: s.string.3.: set has 2 patterns$"
expect * = VCL_Error "^vmod re2 error: n.string.1.: No strings were set for n$"
expect * = VCL_Error "^vmod re2 error: n.string.2.: No strings were set for n$"
...
...
src/vmod_re2.c
View file @
47ac7eca
...
...
@@ -860,6 +860,14 @@ get_match_idx(VRT_CTX, struct vmod_re2_set *set, VCL_INT n, VCL_ENUM selects,
return
task
->
matches
[
idx
];
}
VCL_INT
vmod_set_which
(
VRT_CTX
,
struct
vmod_re2_set
*
set
,
VCL_ENUM
selects
)
{
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
set
,
VMOD_RE2_SET_MAGIC
);
return
get_match_idx
(
ctx
,
set
,
0
,
selects
,
"which"
)
+
1
;
}
VCL_STRING
vmod_set_string
(
VRT_CTX
,
struct
vmod_re2_set
*
set
,
VCL_INT
n
,
VCL_ENUM
selects
)
{
...
...
src/vmod_re2.vcc
View file @
47ac7eca
...
...
@@ -850,6 +850,8 @@ Example::
+ " patterns from the set");
}
$Method INT .which(ENUM {FIRST, LAST} select=0)
$Method STRING .string(INT n=0, ENUM {FIRST, LAST} select=0)
Returns the string associated with the `nth` pattern added to the set,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment