[master] dec8a96 Add tag presence "operator"

Martin Blix Grydeland martin at varnish-cache.org
Tue Oct 1 14:48:19 CEST 2013


commit dec8a963b21a2374a601dd776d184a0f6a9580fb
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Wed Sep 25 15:43:47 2013 +0200

    Add tag presence "operator"

diff --git a/bin/varnishtest/tests/l00001.vtc b/bin/varnishtest/tests/l00001.vtc
index 7d22734..6dc2b7d 100644
--- a/bin/varnishtest/tests/l00001.vtc
+++ b/bin/varnishtest/tests/l00001.vtc
@@ -186,3 +186,10 @@ logexpect l1 -d 1 -g vxid -q "Resp*:x-test eq '123 321'" {
 	  expect * =	ReqEnd
 	  expect * =	End
 } -run
+
+# Test tag presence (no operator)
+logexpect l1 -d 1 -g vxid -q "RespStatus" {
+	  expect 0 *	Begin	req
+	  expect * =	ReqEnd
+	  expect * =	End
+} -run
diff --git a/lib/libvarnishapi/generate.py b/lib/libvarnishapi/generate.py
index b08e769..1ef6d93 100755
--- a/lib/libvarnishapi/generate.py
+++ b/lib/libvarnishapi/generate.py
@@ -68,6 +68,9 @@ tokens = {
         # These have handwritten recognizers
         "VAL":          None,
         "EOI":          None,
+
+	# Special
+	"T_TRUE":	None,
 }
 
 #######################################################################
diff --git a/lib/libvarnishapi/vsl_query.c b/lib/libvarnishapi/vsl_query.c
index 8a3a441..7098c4d 100644
--- a/lib/libvarnishapi/vsl_query.c
+++ b/lib/libvarnishapi/vsl_query.c
@@ -80,8 +80,6 @@ vslq_test_rec(const struct vex *vex, const struct VSLC_ptr *rec)
 
 	AN(vex);
 	AN(rec);
-	rhs = vex->rhs;
-	AN(rhs);
 
 	b = VSL_CDATA(rec->ptr);
 	e = b + VSL_LEN(rec->ptr) - 1;
@@ -116,6 +114,13 @@ vslq_test_rec(const struct vex *vex, const struct VSLC_ptr *rec)
 			return (0);
 	}
 
+	if (vex->tok == T_TRUE)
+		/* Always true */
+		return (1);
+
+	rhs = vex->rhs;
+	CHECK_OBJ_NOTNULL(rhs, VEX_RHS_MAGIC);
+
 	/* Prepare */
 	switch (vex->tok) {
 	case T_EQ:		/* == */
@@ -201,7 +206,6 @@ vslq_test(const struct vex *vex, struct VSL_transaction * const ptrans[])
 	CHECK_OBJ_NOTNULL(vex, VEX_MAGIC);
 	CHECK_OBJ_NOTNULL(vex->lhs, VEX_LHS_MAGIC);
 	AN(vex->lhs->tags);
-	CHECK_OBJ_NOTNULL(vex->rhs, VEX_RHS_MAGIC);
 
 	for (t = ptrans[0]; t != NULL; t = *++ptrans) {
 		AZ(VSL_ResetCursor(t->c));
diff --git a/lib/libvarnishapi/vxp_parse.c b/lib/libvarnishapi/vxp_parse.c
index 988fde4..c105bc7 100644
--- a/lib/libvarnishapi/vxp_parse.c
+++ b/lib/libvarnishapi/vxp_parse.c
@@ -241,6 +241,7 @@ vxp_expr_cmp(struct vxp *vxp, struct vex **pvex)
 	case T_AND:
 	case T_OR:
 	case ')':
+		(*pvex)->tok = T_TRUE;
 		return;
 
 	/* Valid operators */



More information about the varnish-commit mailing list