r3725 - in branches/2.0/varnish-cache: bin/varnishtest/tests lib/libvcl

tfheen at projects.linpro.no tfheen at projects.linpro.no
Tue Feb 10 16:01:28 CET 2009


Author: tfheen
Date: 2009-02-10 16:01:28 +0100 (Tue, 10 Feb 2009)
New Revision: 3725

Modified:
   branches/2.0/varnish-cache/bin/varnishtest/tests/c00022.vtc
   branches/2.0/varnish-cache/lib/libvcl/vcc_action.c
   branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c
Log:
Merge r3543: Test that we know the purge variable when it is compiled in.



Modified: branches/2.0/varnish-cache/bin/varnishtest/tests/c00022.vtc
===================================================================
--- branches/2.0/varnish-cache/bin/varnishtest/tests/c00022.vtc	2009-02-10 14:58:17 UTC (rev 3724)
+++ branches/2.0/varnish-cache/bin/varnishtest/tests/c00022.vtc	2009-02-10 15:01:28 UTC (rev 3725)
@@ -33,6 +33,26 @@
 	}
 } -start
 
+# Trigger syntax check 
+varnish v1 -badvcl {
+	backend foo {
+		.host = "127.0.0.1";
+	}
+	sub vcl_recv {
+		purge (req.foo == req.url);
+	}
+}
+
+# Trigger syntax check 
+varnish v1 -badvcl {
+	backend foo {
+		.host = "127.0.0.1";
+	}
+	sub vcl_recv {
+		purge (req.http. == req.url);
+	}
+}
+
 # Fetch into cache
 client c1 {
 	txreq -url "/foo"

Modified: branches/2.0/varnish-cache/lib/libvcl/vcc_action.c
===================================================================
--- branches/2.0/varnish-cache/lib/libvcl/vcc_action.c	2009-02-10 14:58:17 UTC (rev 3724)
+++ branches/2.0/varnish-cache/lib/libvcl/vcc_action.c	2009-02-10 15:01:28 UTC (rev 3725)
@@ -32,6 +32,7 @@
 #include "config.h"
 
 #include <stdio.h>
+#include <string.h>
 
 #include "vsb.h"
 
@@ -347,13 +348,23 @@
 
 /*--------------------------------------------------------------------*/
 
+static const struct purge_var {
+	const char	*name;
+	unsigned	flag;
+} purge_var[] = {
+#define PVAR(a, b, c)   { a, b },
+#include "purge_vars.h"
+#undef PVAR     
+        { 0, 0 }
+};
+
 static void
 parse_purge(struct tokenlist *tl)
 {
+	const struct purge_var *pv;
 
 	vcc_NextToken(tl);
 
-
 	Expect(tl, '(');
 	vcc_NextToken(tl);
 
@@ -362,6 +373,25 @@
 		tl->indent += INDENT;
 		while (1) {
 			ExpectErr(tl, VAR);
+
+			/* Check valididity of purge variable */
+			for (pv = purge_var; pv->name != NULL; pv++) {
+				if (!strncmp(pv->name, tl->t->b,
+				    strlen(pv->name)))
+					break;
+			}
+			if (pv->name == NULL) {
+				vsb_printf(tl->sb, "Unknown purge variable.");
+				vcc_ErrWhere(tl, tl->t);
+				return;
+			}
+			if (pv->flag &&
+			    tl->t->b + strlen(pv->name) >= tl->t->e) {
+				vsb_printf(tl->sb, "Missing header name.");
+				vcc_ErrWhere(tl, tl->t);
+				return;
+			}
+
 			Fb(tl, 1, "  \"%.*s\",\n", PF(tl->t));
 			vcc_NextToken(tl);
 			switch(tl->t->tok) {

Modified: branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c	2009-02-10 14:58:17 UTC (rev 3724)
+++ branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c	2009-02-10 15:01:28 UTC (rev 3725)
@@ -235,8 +235,8 @@
 	vsb_cat(sb, " * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWI");
 	vsb_cat(sb, "SE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFT");
 	vsb_cat(sb, "WARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n");
-	vsb_cat(sb, " * SUCH DAMAGE.\n *\n * $Id: vrt.h 3723 2009-02-10 14:");
-	vsb_cat(sb, "50:53Z tfheen $\n *\n * Runtime support for compiled V");
+	vsb_cat(sb, " * SUCH DAMAGE.\n *\n * $Id: vrt.h 3724 2009-02-10 14:");
+	vsb_cat(sb, "58:17Z tfheen $\n *\n * Runtime support for compiled V");
 	vsb_cat(sb, "CL programs.\n *\n * XXX: When this file is changed, l");
 	vsb_cat(sb, "ib/libvcl/vcc_gen_fixed_token.tcl\n");
 	vsb_cat(sb, " * XXX: *MUST* be rerun.\n */\n");



More information about the varnish-commit mailing list