Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
1fa6b742
Commit
1fa6b742
authored
May 08, 2018
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use a vsb to return vcc_regexp's result
to avoid micro-managing memory Follow up
cf20e04e
parent
e66c5eb5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
19 deletions
+23
-19
vcc_compile.h
lib/libvcc/vcc_compile.h
+1
-1
vcc_expr.c
lib/libvcc/vcc_expr.c
+15
-10
vcc_utils.c
lib/libvcc/vcc_utils.c
+7
-8
No files found.
lib/libvcc/vcc_compile.h
View file @
1fa6b742
...
...
@@ -322,7 +322,7 @@ void vcc_Parse_Init(struct vcc *);
sym_act_f
vcc_Act_If
;
/* vcc_utils.c */
const
char
*
vcc_regexp
(
struct
vcc
*
tl
);
void
vcc_regexp
(
struct
vcc
*
tl
,
struct
vsb
*
vgc_name
);
void
Resolve_Sockaddr
(
struct
vcc
*
tl
,
const
char
*
host
,
const
char
*
defport
,
const
char
**
ipv4
,
const
char
**
ipv4_ascii
,
const
char
**
ipv6
,
const
char
**
ipv6_ascii
,
const
char
**
p_ascii
,
int
maxips
,
...
...
lib/libvcc/vcc_expr.c
View file @
1fa6b742
...
...
@@ -288,8 +288,8 @@ vcc_Eval_Regsub(struct vcc *tl, struct expr **e, struct token *t,
{
struct
expr
*
e2
;
int
all
=
sym
->
eval_priv
==
NULL
?
0
:
1
;
const
char
*
p
;
char
buf
[
128
];
struct
vsb
vsb
;
(
void
)
t
;
(
void
)
fmt
;
...
...
@@ -298,10 +298,13 @@ vcc_Eval_Regsub(struct vcc *tl, struct expr **e, struct token *t,
ERRCHK
(
tl
);
SkipToken
(
tl
,
','
);
ExpectErr
(
tl
,
CSTR
);
p
=
vcc_regexp
(
tl
);
bprintf
(
buf
,
"VRT_regsub(ctx, %d,
\v
+
\n\v
1,
\n
%s"
,
all
,
p
);
free
(
TRUST_ME
(
p
));
*
e
=
vcc_expr_edit
(
tl
,
STRING
,
buf
,
e2
,
NULL
);
AN
(
VSB_new
(
&
vsb
,
buf
,
sizeof
buf
,
VSB_FIXEDLEN
));
VSB_printf
(
&
vsb
,
"VRT_regsub(ctx, %d,
\v
+
\n\v
1,
\n
"
,
all
);
vcc_regexp
(
tl
,
&
vsb
);
ERRCHK
(
tl
);
AZ
(
VSB_finish
(
&
vsb
));
*
e
=
vcc_expr_edit
(
tl
,
STRING
,
VSB_data
(
&
vsb
),
e2
,
NULL
);
SkipToken
(
tl
,
','
);
vcc_expr0
(
tl
,
&
e2
,
STRING
);
ERRCHK
(
tl
);
...
...
@@ -983,16 +986,18 @@ static void v_matchproto_(cmp_f)
cmp_regexp
(
struct
vcc
*
tl
,
struct
expr
**
e
,
const
struct
cmps
*
cp
)
{
char
buf
[
128
];
const
char
*
re
;
struct
vsb
vsb
;
*
e
=
vcc_expr_edit
(
tl
,
STRING
,
"
\v
S"
,
*
e
,
NULL
);
vcc_NextToken
(
tl
);
ExpectErr
(
tl
,
CSTR
);
re
=
vcc_regexp
(
tl
);
AN
(
VSB_new
(
&
vsb
,
buf
,
sizeof
buf
,
VSB_FIXEDLEN
));
VSB_printf
(
&
vsb
,
"%sVRT_re_match(ctx,
\v
1, "
,
cp
->
emit
);
vcc_regexp
(
tl
,
&
vsb
);
ERRCHK
(
tl
);
bprintf
(
buf
,
"%sVRT_re_match(ctx,
\v
1, %s)"
,
cp
->
emit
,
re
);
free
(
TRUST_ME
(
re
));
*
e
=
vcc_expr_edit
(
tl
,
BOOL
,
buf
,
*
e
,
NULL
);
VSB_cat
(
&
vsb
,
")"
);
AZ
(
VSB_finish
(
&
vsb
));
*
e
=
vcc_expr_edit
(
tl
,
BOOL
,
VSB_data
(
&
vsb
)
,
*
e
,
NULL
);
}
static
void
v_matchproto_
(
cmp_f
)
...
...
lib/libvcc/vcc_utils.c
View file @
1fa6b742
...
...
@@ -47,10 +47,10 @@
/*--------------------------------------------------------------------*/
const
char
*
vcc_regexp
(
struct
vcc
*
tl
)
void
vcc_regexp
(
struct
vcc
*
tl
,
struct
vsb
*
vgc_name
)
{
char
buf
[
BUFSIZ
]
,
*
p
;
char
buf
[
BUFSIZ
];
vre_t
*
t
;
const
char
*
error
;
int
erroroffset
;
...
...
@@ -58,18 +58,18 @@ vcc_regexp(struct vcc *tl)
Expect
(
tl
,
CSTR
);
if
(
tl
->
err
)
return
(
NULL
)
;
return
;
t
=
VRE_compile
(
tl
->
t
->
dec
,
0
,
&
error
,
&
erroroffset
);
if
(
t
==
NULL
)
{
VSB_printf
(
tl
->
sb
,
"Regexp compilation error:
\n\n
%s
\n\n
"
,
error
);
vcc_ErrWhere
(
tl
,
tl
->
t
);
return
(
NULL
)
;
return
;
}
VRE_free
(
&
t
);
bprintf
(
buf
,
"VGC_re_%u"
,
tl
->
unique
++
);
p
=
TlAlloc
(
tl
,
strlen
(
buf
)
+
1
);
strcpy
(
p
,
buf
);
if
(
vgc_name
)
VSB_cat
(
vgc_name
,
buf
);
Fh
(
tl
,
0
,
"static void *%s;
\n
"
,
buf
);
ifp
=
New_IniFin
(
tl
);
...
...
@@ -78,7 +78,6 @@ vcc_regexp(struct vcc *tl)
VSB_printf
(
ifp
->
ini
,
");"
);
VSB_printf
(
ifp
->
fin
,
"
\t\t
VRT_re_fini(%s);"
,
buf
);
vcc_NextToken
(
tl
);
return
(
p
);
}
/*
...
...
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