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
f0ad3c0d
Commit
f0ad3c0d
authored
May 15, 2019
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Un-special-case the 'default' more.
parent
d33b89e8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
66 deletions
+77
-66
vcc_expr.c
lib/libvcc/vcc_expr.c
+76
-60
vcc_parse.c
lib/libvcc/vcc_parse.c
+0
-1
vcc_symb.c
lib/libvcc/vcc_symb.c
+1
-5
No files found.
lib/libvcc/vcc_expr.c
View file @
f0ad3c0d
...
...
@@ -302,55 +302,6 @@ vcc_expr_tostring(struct vcc *tl, struct expr **e, vcc_type_t fmt)
}
}
/*--------------------------------------------------------------------
*/
static
void
v_matchproto_
(
sym_expr_t
)
vcc_Eval_Regsub
(
struct
vcc
*
tl
,
struct
expr
**
e
,
struct
token
*
t
,
struct
symbol
*
sym
,
vcc_type_t
fmt
)
{
struct
expr
*
e2
;
int
all
=
sym
->
eval_priv
==
NULL
?
0
:
1
;
char
buf
[
128
];
struct
vsb
vsb
;
(
void
)
t
;
(
void
)
fmt
;
SkipToken
(
tl
,
'('
);
vcc_expr0
(
tl
,
&
e2
,
STRING
);
ERRCHK
(
tl
);
SkipToken
(
tl
,
','
);
ExpectErr
(
tl
,
CSTR
);
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
);
*
e
=
vcc_expr_edit
(
tl
,
STRINGS
,
"
\v
1,
\n\v
2)
\v
-"
,
*
e
,
e2
);
(
*
e
)
->
nstr
=
1
;
SkipToken
(
tl
,
')'
);
}
/*--------------------------------------------------------------------
*/
static
void
v_matchproto_
(
sym_expr_t
)
vcc_Eval_BoolConst
(
struct
vcc
*
tl
,
struct
expr
**
e
,
struct
token
*
t
,
struct
symbol
*
sym
,
vcc_type_t
fmt
)
{
(
void
)
t
;
(
void
)
tl
;
(
void
)
fmt
;
*
e
=
vcc_mk_expr
(
BOOL
,
"(0==%d)"
,
sym
->
eval_priv
==
NULL
?
1
:
0
);
(
*
e
)
->
constant
=
EXPR_CONST
;
}
/*--------------------------------------------------------------------
*/
...
...
@@ -734,17 +685,6 @@ vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt)
}
switch
(
tl
->
t
->
tok
)
{
case
ID
:
if
(
vcc_IdIs
(
tl
->
t
,
"default"
)
&&
fmt
==
PROBE
)
{
vcc_NextToken
(
tl
);
*
e
=
vcc_mk_expr
(
PROBE
,
"%s"
,
vcc_default_probe
(
tl
));
return
;
}
if
(
vcc_IdIs
(
tl
->
t
,
"default"
)
&&
fmt
==
BACKEND
)
{
vcc_NextToken
(
tl
);
*
e
=
vcc_mk_expr
(
BACKEND
,
"*(VCL_conf.default_director)"
);
return
;
}
t
=
tl
->
t
;
sym
=
VCC_SymbolGet
(
tl
,
SYM_NONE
,
"Symbol not found"
,
XREF_REF
);
...
...
@@ -1399,6 +1339,77 @@ vcc_Act_Call(struct vcc *tl, struct token *t, struct symbol *sym)
}
vcc_delete_expr
(
e
);
}
/*--------------------------------------------------------------------
*/
static
void
v_matchproto_
(
sym_expr_t
)
vcc_Eval_Regsub
(
struct
vcc
*
tl
,
struct
expr
**
e
,
struct
token
*
t
,
struct
symbol
*
sym
,
vcc_type_t
fmt
)
{
struct
expr
*
e2
;
int
all
=
sym
->
eval_priv
==
NULL
?
0
:
1
;
char
buf
[
128
];
struct
vsb
vsb
;
(
void
)
t
;
(
void
)
fmt
;
SkipToken
(
tl
,
'('
);
vcc_expr0
(
tl
,
&
e2
,
STRING
);
ERRCHK
(
tl
);
SkipToken
(
tl
,
','
);
ExpectErr
(
tl
,
CSTR
);
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
);
*
e
=
vcc_expr_edit
(
tl
,
STRINGS
,
"
\v
1,
\n\v
2)
\v
-"
,
*
e
,
e2
);
(
*
e
)
->
nstr
=
1
;
SkipToken
(
tl
,
')'
);
}
/*--------------------------------------------------------------------
*/
static
void
v_matchproto_
(
sym_expr_t
)
vcc_Eval_BoolConst
(
struct
vcc
*
tl
,
struct
expr
**
e
,
struct
token
*
t
,
struct
symbol
*
sym
,
vcc_type_t
fmt
)
{
(
void
)
t
;
(
void
)
tl
;
(
void
)
fmt
;
*
e
=
vcc_mk_expr
(
BOOL
,
"(0==%d)"
,
sym
->
eval_priv
==
NULL
?
1
:
0
);
(
*
e
)
->
constant
=
EXPR_CONST
;
}
/*--------------------------------------------------------------------
*/
static
void
v_matchproto_
(
sym_expr_t
)
vcc_Eval_Default
(
struct
vcc
*
tl
,
struct
expr
**
e
,
struct
token
*
t
,
struct
symbol
*
sym
,
vcc_type_t
fmt
)
{
(
void
)
e
;
(
void
)
fmt
;
(
void
)
sym
;
(
void
)
t
;
if
(
fmt
==
PROBE
)
*
e
=
vcc_mk_expr
(
PROBE
,
"%s"
,
vcc_default_probe
(
tl
));
else
if
(
fmt
==
BACKEND
)
*
e
=
vcc_mk_expr
(
BACKEND
,
"*(VCL_conf.default_director)"
);
else
{
VSB_printf
(
tl
->
sb
,
"Symbol 'default' is a reserved word.
\n
"
);
vcc_ErrWhere
(
tl
,
t
);
}
}
/*--------------------------------------------------------------------
*/
...
...
@@ -1431,4 +1442,9 @@ vcc_Expr_Init(struct vcc *tl)
sym
->
type
=
BOOL
;
sym
->
eval
=
vcc_Eval_BoolConst
;
sym
->
eval_priv
=
NULL
;
sym
=
VCC_MkSym
(
tl
,
"default"
,
SYM_FUNC
,
VCL_LOW
,
VCL_HIGH
);
AN
(
sym
);
sym
->
type
=
BACKEND
;
// ... can also (sometimes) deliver PROBE
sym
->
eval
=
vcc_Eval_Default
;
}
lib/libvcc/vcc_parse.c
View file @
f0ad3c0d
...
...
@@ -357,7 +357,6 @@ static struct toplev {
{
"probe"
,
vcc_ParseProbe
,
VCL_41
,
VCL_HIGH
},
{
"import"
,
vcc_ParseImport
,
VCL_41
,
VCL_HIGH
},
{
"vcl"
,
vcc_ParseVcl
,
VCL_41
,
VCL_HIGH
},
{
"default"
,
NULL
,
VCL_40
,
VCL_HIGH
},
{
NULL
,
NULL
}
};
...
...
lib/libvcc/vcc_symb.c
View file @
f0ad3c0d
...
...
@@ -240,11 +240,7 @@ VCC_SymbolGet(struct vcc *tl, vcc_kind_t kind, const char *e, const char *x)
if
(
kind
!=
SYM_NONE
&&
kind
!=
sym
->
kind
)
{
VSB_printf
(
tl
->
sb
,
"Symbol "
);
vcc_ErrToken
(
tl
,
tl
->
t
);
if
(
sym
->
kind
==
SYM_NONE
)
VSB_printf
(
tl
->
sb
,
" is a reserved word."
);
else
VSB_printf
(
tl
->
sb
,
" has wrong type (%s): "
,
sym
->
kind
->
name
);
VSB_printf
(
tl
->
sb
,
" has wrong type (%s): "
,
sym
->
kind
->
name
);
VSB_cat
(
tl
->
sb
,
"
\n
At: "
);
vcc_ErrWhere
(
tl
,
tl
->
t
);
if
(
sym
->
def_b
!=
NULL
)
{
...
...
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