[master] b00cbb2 Allow user defined sub{}'s to return without specifing a handling.
Poul-Henning Kamp
phk at FreeBSD.org
Wed Feb 22 09:32:05 CET 2017
commit b00cbb23b67d98bc563f0bad9ea4c10c37bf5bf7
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Feb 22 08:30:59 2017 +0000
Allow user defined sub{}'s to return without specifing a handling.
diff --git a/bin/varnishtest/tests/v00034.vtc b/bin/varnishtest/tests/v00034.vtc
index b4d526f..4367444 100644
--- a/bin/varnishtest/tests/v00034.vtc
+++ b/bin/varnishtest/tests/v00034.vtc
@@ -24,3 +24,26 @@ varnish v1 -errvcl {Probe 'p1' redefined} {
probe p1 { }
backend s1 { .host = "127.0.0.1"; .probe = p1;}
}
+
+varnish v1 -errvcl {Expected '(' got ';'} {
+ backend s1 { .host = "127.0.0.1"; }
+ sub vcl_recv { return; }
+}
+
+varnish v1 -vcl+backend {
+
+ sub foobar {
+ set resp.http.foo = "foo";
+ return;
+ set resp.http.foo = "bar";
+ }
+ sub vcl_deliver {
+ call foobar;
+ }
+}
+
+client c1 {
+ txreq
+ rxresp
+ expect resp.http.foo == "foo"
+} -run
diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c
index fb8d97b..39cabe1 100644
--- a/lib/libvcc/vcc_action.c
+++ b/lib/libvcc/vcc_action.c
@@ -284,6 +284,11 @@ parse_return(struct vcc *tl)
const char *h;
vcc_NextToken(tl);
+ if (tl->t->tok == ';' && tl->fb == tl->fc) {
+ /* fb == fc means we're in a subroutine */
+ Fb(tl, 1, "return;\n");
+ return;
+ }
ExpectErr(tl, '(');
vcc_NextToken(tl);
ExpectErr(tl, ID);
More information about the varnish-commit
mailing list