[4.1] 3ba970e Teach vmodtool.py's tokenizer quotes
Martin Blix Grydeland
martin at varnish-software.com
Fri Sep 4 15:54:51 CEST 2015
commit 3ba970ecf269fc10dd1e210db27870284147dcad
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date: Wed Jul 29 14:38:50 2015 +0200
Teach vmodtool.py's tokenizer quotes
diff --git a/bin/varnishtest/tests/m00019.vtc b/bin/varnishtest/tests/m00019.vtc
index f7b2386..89ad9b0 100644
--- a/bin/varnishtest/tests/m00019.vtc
+++ b/bin/varnishtest/tests/m00019.vtc
@@ -22,12 +22,12 @@ client c1 {
txreq
rxresp
expect resp.bodylen == "6"
- expect resp.http.foo1 == "1 2 3"
- expect resp.http.foo2 == "1 2 3"
- expect resp.http.foo3 == "1 2 3"
- expect resp.http.foo4 == "1 2 3"
- expect resp.http.foo5 == "1 2 3"
- expect resp.http.foo6 == "1 2 3"
+ expect resp.http.foo1 == "1 2 3 ,"
+ expect resp.http.foo2 == "1 2 3 ,"
+ expect resp.http.foo3 == "1 2 3 ,"
+ expect resp.http.foo4 == "1 2 3 ,"
+ expect resp.http.foo5 == "1 2 3 ,"
+ expect resp.http.foo6 == "1 2 3 ,"
} -run
delay .1
diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py
index ce27df2..4db94a3 100755
--- a/lib/libvcc/vmodtool.py
+++ b/lib/libvcc/vmodtool.py
@@ -739,6 +739,22 @@ class FileSection(object):
return
l = re.sub("[ \t]*#.*$", "", l)
l = re.sub("[ \t]*\n", "", l)
+
+ if re.match("['\"]", l):
+ m = re.match("(['\"]).*?(\\1)", l)
+ if not m:
+ raise FormatError("Unbalanced quote",
+ "Unbalanced quote on line %d" % ln)
+ self.tl.append(Token(ln, 0, l[:m.end()]))
+ self.l.insert(0, (ln, l[m.end():]))
+ return
+
+ m = re.search("['\"]", l)
+ if m:
+ rest = l[m.start():]
+ self.l.insert(0, (ln, rest))
+ l = l[:m.start()]
+
l = re.sub("([(){},=])", r' \1 ', l)
if l == "":
return
diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc
index 3a60814..8b32e92 100644
--- a/lib/libvmod_debug/vmod.vcc
+++ b/lib/libvmod_debug/vmod.vcc
@@ -94,7 +94,8 @@ $Function VOID rot52(HTTP hdr)
Encrypt the HTTP header with quad-ROT13 encryption,
(this is approx 33% better than triple-DES).
-$Function STRING argtest(STRING one, REAL two=2, STRING three="3")
+$Function STRING argtest(STRING one, REAL two=2, STRING three="3",
+ STRING comma=",")
$Function INT vre_limit()
diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c
index ce2e22b..4d86baa 100644
--- a/lib/libvmod_debug/vmod_debug.c
+++ b/lib/libvmod_debug/vmod_debug.c
@@ -177,11 +177,12 @@ vmod_rot52(VRT_CTX, VCL_HTTP hp)
}
VCL_STRING
-vmod_argtest(VRT_CTX, VCL_STRING one, VCL_REAL two, VCL_STRING three)
+vmod_argtest(VRT_CTX, VCL_STRING one, VCL_REAL two, VCL_STRING three,
+ VCL_STRING comma)
{
char buf[100];
- bprintf(buf, "%s %g %s", one, two, three);
+ bprintf(buf, "%s %g %s %s", one, two, three, comma);
return WS_Copy(ctx->ws, buf, -1);
}
More information about the varnish-commit
mailing list