Commit bc5dd0e2 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

vcc: Extract CSTR concatenation in its own function

This plugs a leak spotted by Coverity Scan. It might be useful in other
places anyway, so it might as well be decoupled from constant regexp
parsing.
parent 0c96fc65
......@@ -48,32 +48,39 @@
/*--------------------------------------------------------------------*/
void
vcc_regexp(struct vcc *tl, struct vsb *vgc_name)
static void
vcc_cstrcat(struct vcc *tl, struct vsb *vsb)
{
struct vsb *pattern;
char buf[BUFSIZ];
vre_t *t;
int error, erroroffset;
struct token *t1;
struct inifin *ifp;
pattern = VSB_new_auto();
AN(pattern);
assert(tl->t->tok == CSTR);
VSB_cat(pattern, tl->t->dec);
VSB_cat(vsb, tl->t->dec);
t1 = vcc_PeekToken(tl);
AN(t1);
while (t1->tok == '+') {
vcc_NextToken(tl);
SkipToken(tl, '+');
ExpectErr(tl, CSTR);
VSB_cat(pattern, tl->t->dec);
VSB_cat(vsb, tl->t->dec);
t1 = vcc_PeekToken(tl);
AN(t1);
}
}
void
vcc_regexp(struct vcc *tl, struct vsb *vgc_name)
{
struct vsb *pattern;
char buf[BUFSIZ];
vre_t *t;
int error, erroroffset;
struct inifin *ifp;
pattern = VSB_new_auto();
AN(pattern);
vcc_cstrcat(tl, pattern);
AZ(VSB_finish(pattern));
t = VRE_compile(VSB_data(pattern), 0, &error, &erroroffset, 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment