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
dd95dca9
Commit
dd95dca9
authored
Mar 07, 2019
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use VRT_fail() for failures in vcl_init, as now required by Varnish.
parent
e5466e98
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
27 deletions
+24
-27
re2.c
src/re2.c
+1
-10
set.c
src/set.c
+13
-13
vmod_re2.c
src/vmod_re2.c
+4
-4
vmod_re2.h
src/vmod_re2.h
+6
-0
No files found.
src/re2.c
View file @
dd95dca9
...
...
@@ -28,25 +28,16 @@
#include "vmod_re2.h"
/* XXX: replace this with VRT_fail() */
void
errmsg
(
VRT_CTX
,
const
char
*
fmt
,
...)
{
va_list
args
;
AZ
(
ctx
->
method
&
VCL_MET_TASK_H
);
va_start
(
args
,
fmt
);
if
(
ctx
->
vsl
)
VSLbv
(
ctx
->
vsl
,
SLT_VCL_Error
,
fmt
,
args
);
else
VSLv
(
SLT_VCL_Error
,
0
,
fmt
,
args
);
va_end
(
args
);
if
(
ctx
->
method
==
VCL_MET_INIT
)
{
AN
(
ctx
->
msg
);
va_start
(
args
,
fmt
);
VSB_vprintf
(
ctx
->
msg
,
fmt
,
args
);
VSB_putc
(
ctx
->
msg
,
'\n'
);
va_end
(
args
);
VRT_handling
(
ctx
,
VCL_RET_FAIL
);
}
}
src/set.c
View file @
dd95dca9
...
...
@@ -136,7 +136,7 @@ vmod_set__init(VRT_CTX, struct vmod_re2_set **setp, const char *vcl_name,
dot_nl
,
case_sensitive
,
perl_classes
,
word_boundary
,
one_line
))
!=
NULL
)
{
V
ERR
(
ctx
,
"new %s = re2.set(): %s"
,
vcl_name
,
err
);
V
FAIL
(
ctx
,
"new %s = re2.set(): %s"
,
vcl_name
,
err
);
return
;
}
...
...
@@ -216,12 +216,12 @@ vmod_set_add(VRT_CTX, struct vmod_re2_set *set, VCL_STRING pattern,
}
if
(
set
->
compiled
)
{
V
ERR
(
ctx
,
ERR_PREFIX
"%s has already been compiled"
,
V
FAIL
(
ctx
,
ERR_PREFIX
"%s has already been compiled"
,
set
->
vcl_name
,
pattern
,
set
->
vcl_name
);
return
;
}
if
((
err
=
vre2set_add
(
set
->
set
,
pattern
,
&
n
))
!=
NULL
)
{
V
ERR
(
ctx
,
ERR_PREFIX
"Cannot compile '%.40s': %s"
,
V
FAIL
(
ctx
,
ERR_PREFIX
"Cannot compile '%.40s': %s"
,
set
->
vcl_name
,
pattern
,
pattern
,
err
);
return
;
}
...
...
@@ -230,7 +230,7 @@ vmod_set_add(VRT_CTX, struct vmod_re2_set *set, VCL_STRING pattern,
if
((
set
->
string
=
realloc
(
set
->
string
,
(
n
+
1
)
*
(
sizeof
(
char
*
))))
==
NULL
)
{
V
ERR
NOMEM
(
ctx
,
ERR_PREFIX
"adding string %s"
,
V
FAIL
NOMEM
(
ctx
,
ERR_PREFIX
"adding string %s"
,
set
->
vcl_name
,
pattern
,
string
);
return
;
}
...
...
@@ -242,7 +242,7 @@ vmod_set_add(VRT_CTX, struct vmod_re2_set *set, VCL_STRING pattern,
if
((
set
->
backend
=
realloc
(
set
->
backend
,
(
n
+
1
)
*
(
sizeof
(
VCL_BACKEND
))))
==
NULL
)
{
V
ERR
NOMEM
(
ctx
,
ERR_PREFIX
"adding backend %s"
,
V
FAIL
NOMEM
(
ctx
,
ERR_PREFIX
"adding backend %s"
,
set
->
vcl_name
,
pattern
,
VRT_BACKEND_string
(
backend
));
return
;
...
...
@@ -304,17 +304,17 @@ vmod_set_compile(VRT_CTX, struct vmod_re2_set *set)
return
;
}
if
(
set
->
npatterns
==
0
)
{
V
ERR
(
ctx
,
ERR_PREFIX
"no patterns were added"
,
set
->
vcl_name
);
V
FAIL
(
ctx
,
ERR_PREFIX
"no patterns were added"
,
set
->
vcl_name
);
return
;
}
if
(
set
->
compiled
)
{
V
ERR
(
ctx
,
ERR_PREFIX
"%s has already been compiled"
,
V
FAIL
(
ctx
,
ERR_PREFIX
"%s has already been compiled"
,
set
->
vcl_name
,
set
->
vcl_name
);
return
;
}
if
((
err
=
vre2set_compile
(
set
->
set
))
!=
NULL
)
{
V
ERR
(
ctx
,
ERR_PREFIX
"failed, possibly insufficient memory"
,
V
FAIL
(
ctx
,
ERR_PREFIX
"failed, possibly insufficient memory"
,
set
->
vcl_name
);
return
;
}
...
...
src/vmod_re2.c
View file @
dd95dca9
...
...
@@ -257,14 +257,14 @@ vmod_regex__init(const struct vrt_ctx *ctx, struct vmod_re2_regex **rep,
longest_match
,
max_mem
,
literal
,
never_nl
,
dot_nl
,
never_capture
,
case_sensitive
,
perl_classes
,
word_boundary
,
one_line
))
!=
NULL
)
{
V
ERR
(
ctx
,
"Cannot compile '%.40s' in %s constructor: %s"
,
V
FAIL
(
ctx
,
"Cannot compile '%.40s' in %s constructor: %s"
,
pattern
,
vcl_name
,
err
);
return
;
}
if
(
!
never_capture
)
{
if
((
err
=
vre2_ngroups
(
re
->
vre2
,
&
re
->
ngroups
))
!=
NULL
)
{
V
ERR
(
ctx
,
"Cannot obtain number of capturing groups in
"
"
%s constructor: %s"
,
vcl_name
,
err
);
V
FAIL
(
ctx
,
"Cannot obtain number of capturing groups
"
"in
%s constructor: %s"
,
vcl_name
,
err
);
return
;
}
assert
(
re
->
ngroups
>=
0
);
...
...
src/vmod_re2.h
View file @
dd95dca9
...
...
@@ -50,6 +50,12 @@
#define VERRNOMEM(ctx, fmt, ...) \
VERR((ctx), fmt ", out of space", __VA_ARGS__)
#define VFAIL(ctx, fmt, ...) \
VRT_fail((ctx), "vmod re2 error: " fmt, __VA_ARGS__)
#define VFAILNOMEM(ctx, fmt, ...) \
VFAIL((ctx), fmt ", out of space", __VA_ARGS__)
struct
vmod_re2_regex
{
unsigned
magic
;
#define VMOD_RE2_REGEX_MAGIC 0x5c3f6f24
...
...
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