Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-pcre2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
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-pcre2
Commits
d9c78b70
Commit
d9c78b70
authored
Feb 16, 2017
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get rid of some of the repetitive code for retrieving pcre2 error messages
(could probably get rid of more)
parent
9efdb805
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
14 deletions
+16
-14
vmod_pcre2.c
src/vmod_pcre2.c
+16
-14
No files found.
src/vmod_pcre2.c
View file @
d9c78b70
...
...
@@ -104,6 +104,16 @@ WS_Front(struct ws * const ws)
return
ws
->
f
;
}
static
inline
int
get_pcre2_errmsg
(
struct
ws
*
const
restrict
ws
,
int
errcode
,
char
*
restrict
*
const
restrict
buf
)
{
unsigned
bytes
=
WS_Reserve
(
ws
,
0
);
*
buf
=
WS_Front
(
ws
);
return
pcre2_get_error_message
(
errcode
,
(
PCRE2_UCHAR
*
)
*
buf
,
(
PCRE2_SIZE
)
bytes
);
}
/* Event function */
int
__match_proto__
(
vmod_event_f
)
...
...
@@ -291,11 +301,9 @@ vmod_regex__init(VRT_CTX, struct vmod_pcre2_regex **regexp,
code
=
pcre2_compile
((
PCRE2_SPTR
)
pattern
,
PCRE2_ZERO_TERMINATED
,
options
,
&
err_code
,
&
err_offset
,
ccontext
);
if
(
code
==
NULL
)
{
char
*
buf
=
WS_Front
(
ctx
->
ws
)
;
char
*
buf
;
uintptr_t
snap
=
WS_Snapshot
(
ctx
->
ws
);
unsigned
bytes
=
WS_Reserve
(
ctx
->
ws
,
0
);
ret
=
pcre2_get_error_message
(
err_code
,
(
PCRE2_UCHAR
*
)
buf
,
(
PCRE2_SIZE
)
bytes
);
ret
=
get_pcre2_errmsg
(
ctx
->
ws
,
err_code
,
&
buf
);
if
(
ret
==
PCRE2_ERROR_BADDATA
)
{
WS_ReleaseP
(
ctx
->
ws
,
buf
);
VERR
(
ctx
,
"Cannot compile '%s' in %s constructor "
...
...
@@ -323,12 +331,9 @@ vmod_regex__init(VRT_CTX, struct vmod_pcre2_regex **regexp,
options
|=
PCRE2_JIT_COMPLETE
;
ret
=
pcre2_jit_compile
(
code
,
options
);
if
(
ret
!=
0
)
{
/* XXX DRY */
char
*
buf
=
WS_Front
(
ctx
->
ws
);
char
*
buf
;
uintptr_t
snap
=
WS_Snapshot
(
ctx
->
ws
);
unsigned
bytes
=
WS_Reserve
(
ctx
->
ws
,
0
);
ret
=
pcre2_get_error_message
(
ret
,
(
PCRE2_UCHAR
*
)
buf
,
(
PCRE2_SIZE
)
bytes
);
ret
=
get_pcre2_errmsg
(
ctx
->
ws
,
ret
,
&
buf
);
if
(
ret
==
PCRE2_ERROR_BADDATA
)
{
WS_ReleaseP
(
ctx
->
ws
,
buf
);
VERR
(
ctx
,
"Cannot jit-compile '%s' in %s "
...
...
@@ -515,12 +520,9 @@ vmod_regex_match(VRT_CTX, struct vmod_pcre2_regex *regex,
if
(
ret
>=
0
)
return
1
;
/* XXX DRY */
char
*
buf
=
WS_Front
(
ctx
->
ws
);
char
*
buf
;
uintptr_t
snap
=
WS_Snapshot
(
ctx
->
ws
);
unsigned
bytes
=
WS_Reserve
(
ctx
->
ws
,
0
);
ret
=
pcre2_get_error_message
(
ret
,
(
PCRE2_UCHAR
*
)
buf
,
(
PCRE2_SIZE
)
bytes
);
ret
=
get_pcre2_errmsg
(
ctx
->
ws
,
ret
,
&
buf
);
if
(
ret
==
PCRE2_ERROR_BADDATA
)
{
WS_ReleaseP
(
ctx
->
ws
,
buf
);
VERR
(
ctx
,
"in %s.match() (unknown error code)"
,
...
...
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