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
1a22c944
Commit
1a22c944
authored
Dec 11, 2019
by
Dridi Boukelmoune
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Kill some redundancy and regroup VSB operations
parent
d6a0f6f0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
10 deletions
+26
-10
vcc_vmod.c
lib/libvcc/vcc_vmod.c
+26
-10
No files found.
lib/libvcc/vcc_vmod.c
View file @
1a22c944
...
...
@@ -185,12 +185,28 @@ vcc_VmodSanity(struct vcc *tl, void *hdl, struct token *mod, char *fnp)
return
(
vmd
);
}
static
vcc_kind_t
vcc_vmod_kind
(
const
char
*
type
)
{
#define VMOD_KIND(str, kind) \
do { \
if (!strcmp(str, type)) \
return (kind); \
} while (0)
VMOD_KIND
(
"$OBJ"
,
SYM_OBJECT
);
VMOD_KIND
(
"$FUNC"
,
SYM_FUNC
);
#undef VMOD_KIND
return
(
SYM_NONE
);
}
static
void
vcc_VmodSymbols
(
struct
vcc
*
tl
,
struct
symbol
*
msym
)
{
const
struct
vjsn
*
vj
;
const
struct
vjsn_val
*
vv
,
*
vv1
,
*
vv2
;
struct
symbol
*
fsym
;
vcc_kind_t
kind
;
struct
vsb
*
buf
;
assert
(
msym
->
kind
==
SYM_VMOD
);
...
...
@@ -200,26 +216,26 @@ vcc_VmodSymbols(struct vcc *tl, struct symbol *msym)
AN
(
buf
);
VTAILQ_FOREACH
(
vv
,
&
vj
->
value
->
children
,
list
)
{
VSB_clear
(
buf
);
assert
(
vv
->
type
==
VJSN_ARRAY
);
vv1
=
VTAILQ_FIRST
(
&
vv
->
children
);
assert
(
vv1
->
type
==
VJSN_STRING
);
vv2
=
VTAILQ_NEXT
(
vv1
,
list
);
assert
(
vv2
->
type
==
VJSN_STRING
);
kind
=
vcc_vmod_kind
(
vv1
->
value
);
if
(
kind
==
SYM_NONE
)
continue
;
VSB_clear
(
buf
);
VSB_printf
(
buf
,
"%s.%s"
,
msym
->
name
,
vv2
->
value
);
AZ
(
VSB_finish
(
buf
));
fsym
=
VCC_MkSym
(
tl
,
VSB_data
(
buf
),
kind
,
VCL_LOW
,
VCL_HIGH
);
AN
(
fsym
);
if
(
!
strcmp
(
vv1
->
value
,
"$FUNC"
))
{
fsym
=
VCC_MkSym
(
tl
,
VSB_data
(
buf
),
SYM_FUNC
,
VCL_LOW
,
VCL_HIGH
);
AN
(
fsym
);
if
(
kind
==
SYM_FUNC
)
{
func_sym
(
fsym
,
msym
->
vmod_name
,
VTAILQ_NEXT
(
vv2
,
list
));
}
else
if
(
!
strcmp
(
vv1
->
value
,
"$OBJ"
))
{
fsym
=
VCC_MkSym
(
tl
,
VSB_data
(
buf
),
SYM_OBJECT
,
VCL_LOW
,
VCL_HIGH
);
AN
(
fsym
);
}
else
{
assert
(
kind
==
SYM_OBJECT
);
fsym
->
eval_priv
=
vv2
;
fsym
->
vmod_name
=
msym
->
vmod_name
;
}
...
...
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