[master] b6f7816 Add '<=' and '>=' operators
Martin Blix Grydeland
martin at varnish-cache.org
Tue Oct 1 14:48:18 CEST 2013
commit b6f7816acc4363ac1874c194ef9b23507619c40a
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date: Thu Sep 19 17:10:30 2013 +0200
Add '<=' and '>=' operators
diff --git a/bin/varnishtest/tests/l00001.vtc b/bin/varnishtest/tests/l00001.vtc
index 2d9e83f..36609ad 100644
--- a/bin/varnishtest/tests/l00001.vtc
+++ b/bin/varnishtest/tests/l00001.vtc
@@ -85,3 +85,31 @@ logexpect l1 -d 1 -g vxid -q "RespStatus > 199." {
expect * = ReqEnd
expect * = End
} -run
+
+# Test '<=' operator on integers
+logexpect l1 -d 1 -g vxid -q "RespStatus <= 200" {
+ expect * * Begin req
+ expect * = ReqEnd
+ expect * = End
+} -run
+
+# Test '<=' operator on floats
+logexpect l1 -d 1 -g vxid -q "RespStatus <= 200." {
+ expect * * Begin req
+ expect * = ReqEnd
+ expect * = End
+} -run
+
+# Test '>=' operator on integers
+logexpect l1 -d 1 -g vxid -q "RespStatus >= 200" {
+ expect * * Begin req
+ expect * = ReqEnd
+ expect * = End
+} -run
+
+# Test '>=' operator on floats
+logexpect l1 -d 1 -g vxid -q "RespStatus >= 200." {
+ expect * * Begin req
+ expect * = ReqEnd
+ expect * = End
+} -run
diff --git a/lib/libvarnishapi/vsl_query.c b/lib/libvarnishapi/vsl_query.c
index 062be7e..12fcd28 100644
--- a/lib/libvarnishapi/vsl_query.c
+++ b/lib/libvarnishapi/vsl_query.c
@@ -153,6 +153,32 @@ vslq_test_rec(const struct vex *vex, const struct VSLC_ptr *rec)
default:
WRONG("Wrong value type");
}
+ case T_LEQ: /* <= */
+ switch (val->type) {
+ case VEX_INT:
+ if (recint <= val->val_int)
+ return (1);
+ return (0);
+ case VEX_FLOAT:
+ if (recfloat <= val->val_float)
+ return (1);
+ return (0);
+ default:
+ WRONG("Wrong value type");
+ }
+ case T_GEQ: /* >= */
+ switch (val->type) {
+ case VEX_INT:
+ if (recint >= val->val_int)
+ return (1);
+ return (0);
+ case VEX_FLOAT:
+ if (recfloat >= val->val_float)
+ return (1);
+ return (0);
+ default:
+ WRONG("Wrong value type");
+ }
case T_SEQ: /* eq */
assert(val->type == VEX_STRING);
if (reclen == val->val_stringlen + 1 &&
More information about the varnish-commit
mailing list