r3718 - in branches/2.0/varnish-cache: bin/varnishtest/tests lib/libvcl
tfheen at projects.linpro.no
tfheen at projects.linpro.no
Tue Feb 10 15:25:50 CET 2009
Author: tfheen
Date: 2009-02-10 15:25:49 +0100 (Tue, 10 Feb 2009)
New Revision: 3718
Added:
branches/2.0/varnish-cache/bin/varnishtest/tests/b00028.vtc
Modified:
branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c
branches/2.0/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
branches/2.0/varnish-cache/lib/libvcl/vcc_parse.c
branches/2.0/varnish-cache/lib/libvcl/vcc_token_defs.h
Log:
Merge r3534: Add "no match" operator !~ to VCL regexps
Copied: branches/2.0/varnish-cache/bin/varnishtest/tests/b00028.vtc (from rev 3534, trunk/varnish-cache/bin/varnishtest/tests/b00028.vtc)
===================================================================
--- branches/2.0/varnish-cache/bin/varnishtest/tests/b00028.vtc (rev 0)
+++ branches/2.0/varnish-cache/bin/varnishtest/tests/b00028.vtc 2009-02-10 14:25:49 UTC (rev 3718)
@@ -0,0 +1,28 @@
+# $Id$
+
+test "regexp match and no-match"
+
+server s1 {
+ rxreq
+ txresp -hdr "Foo: bar" -hdr "Bar: foo" -body "1111\n"
+} -start
+
+varnish v1 -vcl+backend {
+
+ sub vcl_fetch {
+ if (obj.http.foo ~ "bar") {
+ set obj.http.foo1 = "1";
+ }
+ if (obj.http.bar !~ "bar") {
+ set obj.http.bar1 = "1";
+ }
+ }
+
+} -start
+
+client c1 {
+ txreq
+ rxresp
+ expect resp.http.foo1 == "1"
+ expect resp.http.bar1 == "1"
+} -run
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:20:29 UTC (rev 3717)
+++ branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c 2009-02-10 14:25:49 UTC (rev 3718)
@@ -22,6 +22,7 @@
switch (p[0]) {
case '!':
+ M2('~', T_NOMATCH);
M2('=', T_NEQ);
M1();
case '%':
@@ -146,6 +147,7 @@
[T_LEQ] = "<=",
[T_MUL] = "*=",
[T_NEQ] = "!=",
+ [T_NOMATCH] = "!~",
[T_SHL] = "<<",
[T_SHR] = ">>",
[VAR] = "VAR",
Modified: branches/2.0/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
===================================================================
--- branches/2.0/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl 2009-02-10 14:20:29 UTC (rev 3717)
+++ branches/2.0/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl 2009-02-10 14:25:49 UTC (rev 3718)
@@ -88,6 +88,7 @@
{"-=" DECR}
{"*=" MUL}
{"/=" DIV}
+ {"!~" NOMATCH}
}
# Single char tokens
Modified: branches/2.0/varnish-cache/lib/libvcl/vcc_parse.c
===================================================================
--- branches/2.0/varnish-cache/lib/libvcl/vcc_parse.c 2009-02-10 14:20:29 UTC (rev 3717)
+++ branches/2.0/varnish-cache/lib/libvcl/vcc_parse.c 2009-02-10 14:25:49 UTC (rev 3718)
@@ -248,12 +248,15 @@
switch (tl->t->tok) {
case '~':
+ case T_NOMATCH:
+ Fb(tl, 1, "%sVRT_re_match(",
+ tl->t->tok == '~' ? "" : "!");
vcc_NextToken(tl);
ExpectErr(tl, CSTR);
p = vcc_regexp(tl, 0);
ERRCHK(tl);
vcc_NextToken(tl);
- Fb(tl, 1, "VRT_re_match(%s, %s)\n", vp->rname, p);
+ Fb(tl, 1, "%s, %s)\n", vp->rname, p);
break;
case T_EQ:
case T_NEQ:
Modified: branches/2.0/varnish-cache/lib/libvcl/vcc_token_defs.h
===================================================================
--- branches/2.0/varnish-cache/lib/libvcl/vcc_token_defs.h 2009-02-10 14:20:29 UTC (rev 3717)
+++ branches/2.0/varnish-cache/lib/libvcl/vcc_token_defs.h 2009-02-10 14:25:49 UTC (rev 3718)
@@ -26,9 +26,10 @@
#define T_DECR 144
#define T_MUL 145
#define T_DIV 146
-#define ID 147
-#define VAR 148
-#define CNUM 149
-#define CSTR 150
-#define EOI 151
-#define CSRC 152
+#define T_NOMATCH 147
+#define ID 148
+#define VAR 149
+#define CNUM 150
+#define CSTR 151
+#define EOI 152
+#define CSRC 153
More information about the varnish-commit
mailing list