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
e1bf48fc
Commit
e1bf48fc
authored
Jun 29, 2017
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move compile() back into the source, it might be inlined into the
match() and sub() functions (gcc does so at least).
parent
c6901806
Pipeline
#263
skipped
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
54 deletions
+49
-54
pcre2.c
src/pcre2.c
+0
-49
vmod_pcre2.c
src/vmod_pcre2.c
+49
-0
vmod_pcre2.h
src/vmod_pcre2.h
+0
-5
No files found.
src/pcre2.c
View file @
e1bf48fc
...
@@ -279,52 +279,3 @@ get_match_opts(VRT_CTX, struct vmod_priv *priv, MATCH_CTX_OPTS, MATCH_FLAGS,
...
@@ -279,52 +279,3 @@ get_match_opts(VRT_CTX, struct vmod_priv *priv, MATCH_CTX_OPTS, MATCH_FLAGS,
return
match_opts
;
return
match_opts
;
}
}
pcre2_code
*
compile
(
VRT_CTX
,
pcre2_compile_context
*
restrict
const
cctx
,
VCL_STRING
const
restrict
pattern
,
uint32_t
options
,
int
do_jit
,
const
char
*
const
restrict
context
,
const
char
*
const
restrict
caller
)
{
pcre2_code
*
code
;
int
err_code
=
0
;
PCRE2_SIZE
err_offset
;
/* XXX set the length via parameter */
code
=
pcre2_compile
((
PCRE2_SPTR
)
pattern
,
PCRE2_ZERO_TERMINATED
,
options
,
&
err_code
,
&
err_offset
,
cctx
);
if
(
code
==
NULL
)
{
char
*
msg
,
*
offset_msg
;
uintptr_t
snap
=
WS_Snapshot
(
ctx
->
ws
);
if
((
msg
=
WS_Printf
(
ctx
->
ws
,
"Cannot compile '%s' in %s%s"
,
pattern
,
context
,
caller
))
==
NULL
)
msg
=
""
;
if
((
offset_msg
=
WS_Printf
(
ctx
->
ws
,
" at offset %zu"
,
err_offset
))
==
NULL
)
offset_msg
=
""
;
report_pcre2_err
(
ctx
,
err_code
,
msg
,
offset_msg
);
WS_Reset
(
ctx
->
ws
,
snap
);
return
NULL
;
}
if
(
do_jit
)
{
int
ret
;
/* XXX check option compatibility; disable via param */
/* XXX set complete or soft/hard partial via param */
options
|=
PCRE2_JIT_COMPLETE
;
ret
=
pcre2_jit_compile
(
code
,
options
);
if
(
ret
!=
0
)
{
char
*
msg
;
uintptr_t
snap
=
WS_Snapshot
(
ctx
->
ws
);
if
((
msg
=
WS_Printf
(
ctx
->
ws
,
"Cannot jit-compile "
"'%s' in %s%s"
,
pattern
,
context
,
caller
))
==
NULL
)
msg
=
""
;
report_pcre2_err
(
ctx
,
ret
,
msg
,
""
);
WS_Reset
(
ctx
->
ws
,
snap
);
return
NULL
;
}
}
return
code
;
}
src/vmod_pcre2.c
View file @
e1bf48fc
...
@@ -144,6 +144,55 @@ get_task(VRT_CTX, struct vmod_priv *priv_task,
...
@@ -144,6 +144,55 @@ get_task(VRT_CTX, struct vmod_priv *priv_task,
return
match_task
;
return
match_task
;
}
}
static
inline
pcre2_code
*
compile
(
VRT_CTX
,
pcre2_compile_context
*
restrict
const
cctx
,
VCL_STRING
const
restrict
pattern
,
uint32_t
options
,
int
do_jit
,
const
char
*
const
restrict
context
,
const
char
*
const
restrict
caller
)
{
pcre2_code
*
code
;
int
err_code
=
0
;
PCRE2_SIZE
err_offset
;
/* XXX set the length via parameter */
code
=
pcre2_compile
((
PCRE2_SPTR
)
pattern
,
PCRE2_ZERO_TERMINATED
,
options
,
&
err_code
,
&
err_offset
,
cctx
);
if
(
code
==
NULL
)
{
char
*
msg
,
*
offset_msg
;
uintptr_t
snap
=
WS_Snapshot
(
ctx
->
ws
);
if
((
msg
=
WS_Printf
(
ctx
->
ws
,
"Cannot compile '%s' in %s%s"
,
pattern
,
context
,
caller
))
==
NULL
)
msg
=
""
;
if
((
offset_msg
=
WS_Printf
(
ctx
->
ws
,
" at offset %zu"
,
err_offset
))
==
NULL
)
offset_msg
=
""
;
report_pcre2_err
(
ctx
,
err_code
,
msg
,
offset_msg
);
WS_Reset
(
ctx
->
ws
,
snap
);
return
NULL
;
}
if
(
do_jit
)
{
int
ret
;
/* XXX check option compatibility; disable via param */
/* XXX set complete or soft/hard partial via param */
options
|=
PCRE2_JIT_COMPLETE
;
ret
=
pcre2_jit_compile
(
code
,
options
);
if
(
ret
!=
0
)
{
char
*
msg
;
uintptr_t
snap
=
WS_Snapshot
(
ctx
->
ws
);
if
((
msg
=
WS_Printf
(
ctx
->
ws
,
"Cannot jit-compile "
"'%s' in %s%s"
,
pattern
,
context
,
caller
))
==
NULL
)
msg
=
""
;
report_pcre2_err
(
ctx
,
ret
,
msg
,
""
);
WS_Reset
(
ctx
->
ws
,
snap
);
return
NULL
;
}
}
return
code
;
}
static
inline
VCL_BOOL
static
inline
VCL_BOOL
match
(
VRT_CTX
,
pcre2_code
*
restrict
const
code
,
match
(
VRT_CTX
,
pcre2_code
*
restrict
const
code
,
VCL_STRING
restrict
const
subject
,
VCL_INT
len
,
const
uint32_t
options
,
VCL_STRING
restrict
const
subject
,
VCL_INT
len
,
const
uint32_t
options
,
...
...
src/vmod_pcre2.h
View file @
e1bf48fc
...
@@ -161,11 +161,6 @@ struct match_call *get_match_opts(VRT_CTX, struct vmod_priv *priv,
...
@@ -161,11 +161,6 @@ struct match_call *get_match_opts(VRT_CTX, struct vmod_priv *priv,
MATCH_CTX_OPTS
,
MATCH_FLAGS
,
SUB_OPTS
,
MATCH_CTX_OPTS
,
MATCH_FLAGS
,
SUB_OPTS
,
const
char
*
context
,
const
char
*
caller
);
const
char
*
context
,
const
char
*
caller
);
pcre2_code
*
compile
(
VRT_CTX
,
pcre2_compile_context
*
restrict
const
cctx
,
VCL_STRING
const
restrict
pattern
,
uint32_t
options
,
int
do_jit
,
const
char
*
const
restrict
context
,
const
char
*
const
restrict
caller
);
static
inline
int
static
inline
int
check_uint32_range
(
VRT_CTX
,
long
long
limit
,
const
char
*
const
restrict
name
,
check_uint32_range
(
VRT_CTX
,
long
long
limit
,
const
char
*
const
restrict
name
,
const
char
*
const
restrict
context
,
const
char
*
const
restrict
context
,
...
...
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