[master] bc13d83 vmodtool.py: support default value also for the last argument
Nils Goroll
nils.goroll at uplex.de
Mon Jun 13 13:09:07 CEST 2016
commit bc13d834374f6eef88912a62d189c1f8a507c423
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Thu Jun 9 17:06:22 2016 +0200
vmodtool.py: support default value also for the last argument
closes #1976
diff --git a/bin/varnishtest/tests/m00019.vtc b/bin/varnishtest/tests/m00019.vtc
index b640a44..98ea822 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 , 4"
+ expect resp.http.foo2 == "1 2 3 , 4"
+ expect resp.http.foo3 == "1 2 3 , 4"
+ expect resp.http.foo4 == "1 2 3 , 4"
+ expect resp.http.foo5 == "1 2 3 , 4"
+ expect resp.http.foo6 == "1 2 3 , 4"
} -run
delay .1
@@ -48,10 +48,10 @@ varnish v1 -errvcl {Argument 'one' missing} {
}
}
-varnish v1 -errvcl {Unknown argument 'four'} {
+varnish v1 -errvcl {Unknown argument 'five'} {
import debug;
backend b1 {.host = "127.0.0.1";}
sub vcl_deliver {
- set resp.http.foo5 = debug.argtest("1", two=2.0, four="3");
+ set resp.http.foo5 = debug.argtest("1", two=2.0, five="3");
}
}
diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py
index d4b31ae..e321b9b 100755
--- a/lib/libvcc/vmodtool.py
+++ b/lib/libvcc/vmodtool.py
@@ -235,7 +235,9 @@ def arg(txt):
i = s.find('=')
j = s.find(',')
- if j >= 0 and j < i:
+ if j < 0:
+ j = len(s)
+ if j < i:
i = -1
if i < 0:
i = s.find(',')
@@ -255,11 +257,14 @@ def arg(txt):
s = s[m.end():]
else:
i = s.find(',')
+ if i < 0:
+ i = len(s)
a.defval = s[:i]
s = s[i:]
return a,s
+# XXX cant have ( or ) in an argument default value
class prototype(object):
def __init__(self, st, retval=True, prefix=""):
l = st.line[1]
diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc
index 1a74349..c0ae7d7 100644
--- a/lib/libvmod_debug/vmod.vcc
+++ b/lib/libvmod_debug/vmod.vcc
@@ -95,7 +95,7 @@ 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",
- STRING comma=",")
+ STRING comma=",", INT four=4)
$Function INT vre_limit()
diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c
index 5ca628c..d58856a 100644
--- a/lib/libvmod_debug/vmod_debug.c
+++ b/lib/libvmod_debug/vmod_debug.c
@@ -186,11 +186,11 @@ vmod_rot52(VRT_CTX, VCL_HTTP hp)
VCL_STRING
vmod_argtest(VRT_CTX, VCL_STRING one, VCL_REAL two, VCL_STRING three,
- VCL_STRING comma)
+ VCL_STRING comma, VCL_INT four)
{
char buf[100];
- bprintf(buf, "%s %g %s %s", one, two, three, comma);
+ bprintf(buf, "%s %g %s %s %ld", one, two, three, comma, four);
return (WS_Copy(ctx->ws, buf, -1));
}
More information about the varnish-commit
mailing list