[master] ac4740f20 Allow a string argument to return(fail("Because!"));
Poul-Henning Kamp
phk at FreeBSD.org
Wed Aug 22 07:48:10 UTC 2018
commit ac4740f20d865e31676334e8372e9231c32bba86
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Aug 22 07:46:39 2018 +0000
Allow a string argument to return(fail("Because!"));
Fixes #2694
diff --git a/bin/varnishtest/tests/v00040.vtc b/bin/varnishtest/tests/v00040.vtc
index 408169ffe..573da73b6 100644
--- a/bin/varnishtest/tests/v00040.vtc
+++ b/bin/varnishtest/tests/v00040.vtc
@@ -14,9 +14,15 @@ client c1 {
varnish v1 -errvcl {VCL "vcl2" Failed initialization} {
sub vcl_init {
- return (fail);
+ return(fail("Do Not Press This Button Again"));
}
+ backend b1 { .host = "${s1_addr}"; }
+}
+varnish v1 -errvcl {Do Not Press} {
+ sub vcl_init {
+ return(fail("Do Not Press This Button Again"));
+ }
backend b1 { .host = "${s1_addr}"; }
}
diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c
index 8e61f271e..ded906870 100644
--- a/lib/libvcc/vcc_action.c
+++ b/lib/libvcc/vcc_action.c
@@ -217,6 +217,22 @@ vcc_act_return_pass(struct vcc *tl)
}
/*--------------------------------------------------------------------*/
+static void
+vcc_act_return_fail(struct vcc *tl)
+{
+ ExpectErr(tl, '(');
+ vcc_NextToken(tl);
+ Fb(tl, 1, "VRT_fail(ctx,\n");
+ tl->indent += INDENT;
+ vcc_Expr(tl, STRING);
+ tl->indent -= INDENT;
+ ERRCHK(tl);
+ SkipToken(tl, ')');
+ Fb(tl, 1, ");\n");
+}
+
+/*--------------------------------------------------------------------*/
+
static void
vcc_act_return_synth(struct vcc *tl)
{
@@ -321,6 +337,8 @@ vcc_act_return(struct vcc *tl, struct token *t, struct symbol *sym)
vcc_act_return_vcl(tl);
else if (hand == VCL_RET_PASS)
vcc_act_return_pass(tl);
+ else if (hand == VCL_RET_FAIL)
+ vcc_act_return_fail(tl);
else {
VSB_printf(tl->sb, "Arguments not allowed.\n");
vcc_ErrWhere(tl, tl->t);
More information about the varnish-commit
mailing list