Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-selector
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-selector
Commits
64c68820
Unverified
Commit
64c68820
authored
Oct 27, 2021
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch to VCL_REGEX
parent
24911df3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
27 deletions
+15
-27
README.rst
README.rst
+4
-4
associate.c
src/associate.c
+4
-4
re_match.vtc
src/tests/re_match.vtc
+1
-1
vmod_selector.c
src/vmod_selector.c
+3
-15
vmod_selector.h
src/vmod_selector.h
+1
-1
vmod_selector.vcc
src/vmod_selector.vcc
+2
-2
No files found.
README.rst
View file @
64c68820
...
...
@@ -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],
...
...
src/associate.c
View file @
64c68820
...
...
@@ -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
)
...
...
src/tests/re_match.vtc
View file @
64c68820
...
...
@@ -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;
...
...
src/vmod_selector.c
View file @
64c68820
...
...
@@ -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
)
...
...
src/vmod_selector.h
View file @
64c68820
...
...
@@ -59,7 +59,7 @@ struct entry {
char
*
string
;
VCL_BACKEND
backend
;
VCL_SUB
sub
;
vre_t
*
re
;
VCL_REGEX
re
;
VCL_INT
integer
;
};
...
...
src/vmod_selector.vcc
View file @
64c68820
...
...
@@ -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
...
...
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