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) ...@@ -481,7 +481,7 @@ vcc_resolve_includes(struct vcc *tl)
continue; continue;
t1 = VTAILQ_NEXT(t, list); t1 = VTAILQ_NEXT(t, list);
assert(t1 != NULL); /* There's always an EOI */ AN(t1); /* There's always an EOI */
if (t1->tok != CSTR) { if (t1->tok != CSTR) {
VSB_printf(tl->sb, VSB_printf(tl->sb,
"include not followed by string constant.\n"); "include not followed by string constant.\n");
...@@ -489,7 +489,7 @@ vcc_resolve_includes(struct vcc *tl) ...@@ -489,7 +489,7 @@ vcc_resolve_includes(struct vcc *tl)
return; return;
} }
t2 = VTAILQ_NEXT(t1, list); t2 = VTAILQ_NEXT(t1, list);
assert(t2 != NULL); /* There's always an EOI */ AN(t2); /* There's always an EOI */
if (t2->tok != ';') { if (t2->tok != ';') {
VSB_printf(tl->sb, VSB_printf(tl->sb,
......
...@@ -70,6 +70,7 @@ struct symbol; ...@@ -70,6 +70,7 @@ struct symbol;
struct source { struct source {
VTAILQ_ENTRY(source) list; VTAILQ_ENTRY(source) list;
float syntax;
char *name; char *name;
const char *b; const char *b;
const char *e; const char *e;
......
...@@ -279,13 +279,20 @@ vcc_ParseVcl(struct vcc *tl) ...@@ -279,13 +279,20 @@ vcc_ParseVcl(struct vcc *tl)
assert(vcc_IdIs(tl->t, "vcl")); assert(vcc_IdIs(tl->t, "vcl"));
vcc_NextToken(tl); vcc_NextToken(tl);
tok = tl->t; tok = tl->t;
tl->syntax = vcc_DoubleVal(tl); tok->src->syntax = vcc_DoubleVal(tl);
ERRCHK(tl); ERRCHK(tl);
if (tl->syntax != 4.0) { if (tl->t->e - tok->b > 4) {
// see TODO above VSB_printf(tl->sb,
VSB_printf(tl->sb, "VCL version %.1f not supported.\n", "Don't play silly buggers with VCL version numbers\n");
tl->syntax); vcc_ErrWhere2(tl, tok, tl->t);
vcc_ErrWhere(tl, tok); 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); ERRCHK(tl);
} }
ExpectErr(tl, ';'); ExpectErr(tl, ';');
...@@ -322,18 +329,27 @@ void ...@@ -322,18 +329,27 @@ void
vcc_Parse(struct vcc *tl) vcc_Parse(struct vcc *tl)
{ {
struct toplev *tp; struct toplev *tp;
struct token *tok;
if (tl->t->tok != ID || !vcc_IdIs(tl->t, "vcl")) { if (tl->t->tok != ID || !vcc_IdIs(tl->t, "vcl")) {
VSB_printf(tl->sb, VSB_printf(tl->sb,
"VCL version declaration missing\n" "VCL version declaration missing\n"
"Update your VCL to Version 4 syntax, and add\n" "Update your VCL to Version 4 syntax, and add\n"
"\tvcl 4.0;\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); vcc_ErrWhere(tl, tl->t);
ERRCHK(tl); ERRCHK(tl);
} }
tok = tl->t;
vcc_ParseVcl(tl); 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); ERRCHK(tl);
while (tl->t->tok != EOI) { while (tl->t->tok != EOI) {
ERRCHK(tl); 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