[master] c9f721b Don't treat sub none specially

Federico G. Schwindt fgsch at lodoss.net
Mon Sep 12 00:06:09 CEST 2016


commit c9f721bbbdd454b4ffbc3fa4c73b5ad3fd1e5e25
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date:   Sun Sep 11 20:30:09 2016 +0100

    Don't treat sub none specially

diff --git a/bin/varnishtest/tests/v00021.vtc b/bin/varnishtest/tests/v00021.vtc
index 86ce100..664a836 100644
--- a/bin/varnishtest/tests/v00021.vtc
+++ b/bin/varnishtest/tests/v00021.vtc
@@ -40,7 +40,6 @@ varnish v1 -errvcl "Function recurses on" {
 	sub vcl_recv { call foo; }
 }
 
-
 varnish v1 -errvcl {Unused acl foo, defined:} {
 	backend b { .host = "127.0.0.1"; }
 
@@ -54,6 +53,14 @@ varnish v1 -errvcl {Unused sub foo, defined:} {
 	sub foo {
 	}
 }
+
+varnish v1 -errvcl {Unused sub none, defined:} {
+	backend b { .host = "127.0.0.1"; }
+
+	sub none {
+	}
+}
+
 varnish v1 -errvcl {Invalid return "deliver"} {
 	backend b { .host = "127.0.0.1"; }
 
diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c
index 461ac56..32f245a 100644
--- a/lib/libvcc/vcc_compile.c
+++ b/lib/libvcc/vcc_compile.c
@@ -133,12 +133,12 @@ New_IniFin(struct vcc *tl)
 int
 IsMethod(const struct token *t)
 {
-	struct method *m;
+	int i;
 
 	assert(t->tok == ID);
-	for(m = method_tab; m->name != NULL; m++) {
-		if (vcc_IdIs(t, m->name))
-			return (m - method_tab);
+	for (i = 1; method_tab[i].name != NULL; i++) {
+		if (vcc_IdIs(t, method_tab[i].name))
+			return (i);
 	}
 	if ((t->b[0] == 'v'|| t->b[0] == 'V') &&
 	    (t->b[1] == 'c'|| t->b[1] == 'C') &&
diff --git a/lib/libvcc/vcc_parse.c b/lib/libvcc/vcc_parse.c
index c5caa62..64ac0d9 100644
--- a/lib/libvcc/vcc_parse.c
+++ b/lib/libvcc/vcc_parse.c
@@ -220,7 +220,7 @@ vcc_ParseFunction(struct vcc *tl)
 		    "VCL sub's named 'vcl*' are reserved names.\n");
 		vcc_ErrWhere(tl, tl->t);
 		VSB_printf(tl->sb, "Valid vcl_* methods are:\n");
-		for (i = 0; method_tab[i].name != NULL; i++)
+		for (i = 1; method_tab[i].name != NULL; i++)
 			VSB_printf(tl->sb, "\t%s\n", method_tab[i].name);
 		return;
 	} else if (m != -1) {



More information about the varnish-commit mailing list