Commit 9a841378 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add code to cater for other vcl syntax numbers than 4.0, we will

soon need them.
parent b2eaca02
varnishtest "VCL syntax numbers"
varnish v1 -vcl {backend b1 { .host = "127.0.0.1:8080"; }} -start
varnish v1 -syntax 3.9 -errvcl "VCL version 3.9 not supported." {
backend b1 { .host = "127.0.0.1:8080"; }
}
varnish v1 -syntax 4.0 -errvcl "silly buggers" {
vcl 4.01;
backend b1 { .host = "127.0.0.1:8080"; }
}
varnish v1 -syntax 4.0 -errvcl "9.9 higher than the top level version" {
vcl 9.9;
backend b1 { .host = "127.0.0.1:8080"; }
}
......@@ -481,7 +481,7 @@ vcc_resolve_includes(struct vcc *tl)
continue;
t1 = VTAILQ_NEXT(t, list);
assert(t1 != NULL); /* There's always an EOI */
AN(t1); /* There's always an EOI */
if (t1->tok != CSTR) {
VSB_printf(tl->sb,
"include not followed by string constant.\n");
......@@ -489,7 +489,7 @@ vcc_resolve_includes(struct vcc *tl)
return;
}
t2 = VTAILQ_NEXT(t1, list);
assert(t2 != NULL); /* There's always an EOI */
AN(t2); /* There's always an EOI */
if (t2->tok != ';') {
VSB_printf(tl->sb,
......
......@@ -70,6 +70,7 @@ struct symbol;
struct source {
VTAILQ_ENTRY(source) list;
float syntax;
char *name;
const char *b;
const char *e;
......
......@@ -279,13 +279,20 @@ vcc_ParseVcl(struct vcc *tl)
assert(vcc_IdIs(tl->t, "vcl"));
vcc_NextToken(tl);
tok = tl->t;
tl->syntax = vcc_DoubleVal(tl);
tok->src->syntax = vcc_DoubleVal(tl);
ERRCHK(tl);
if (tl->syntax != 4.0) {
// see TODO above
VSB_printf(tl->sb, "VCL version %.1f not supported.\n",
tl->syntax);
vcc_ErrWhere(tl, tok);
if (tl->t->e - tok->b > 4) {
VSB_printf(tl->sb,
"Don't play silly buggers with VCL version numbers\n");
vcc_ErrWhere2(tl, tok, tl->t);
ERRCHK(tl);
}
if (tl->syntax != 0.0 && tok->src->syntax > tl->syntax) {
VSB_printf(tl->sb,
"VCL version %.1f higher than"
" the top level version %.1f\n",
tok->src->syntax, tl->syntax);
vcc_ErrWhere2(tl, tok, tl->t);
ERRCHK(tl);
}
ExpectErr(tl, ';');
......@@ -322,18 +329,27 @@ void
vcc_Parse(struct vcc *tl)
{
struct toplev *tp;
struct token *tok;
if (tl->t->tok != ID || !vcc_IdIs(tl->t, "vcl")) {
VSB_printf(tl->sb,
"VCL version declaration missing\n"
"Update your VCL to Version 4 syntax, and add\n"
"\tvcl 4.0;\n"
"on the first line the VCL files.\n"
"on the first line of the VCL files.\n"
);
vcc_ErrWhere(tl, tl->t);
ERRCHK(tl);
}
tok = tl->t;
vcc_ParseVcl(tl);
if (tok->src->syntax != 4.0) {
VSB_printf(tl->sb, "VCL version %.1f not supported.\n",
tok->src->syntax);
vcc_ErrWhere2(tl, tok, tl->t);
ERRCHK(tl);
}
tl->syntax = tl->t->src->syntax;
ERRCHK(tl);
while (tl->t->tok != EOI) {
ERRCHK(tl);
......
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