[master] 35db7bb Use a regexp iterator (nice concept!) to separate the arguments and add support for argument qualifiers in {...}

Poul-Henning Kamp phk at varnish-cache.org
Mon Jan 31 21:23:15 CET 2011


commit 35db7bbb8d24a0779db99b88591216f3e3cc494c
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Jan 31 20:22:42 2011 +0000

    Use a regexp iterator (nice concept!) to separate the arguments
    and add support for argument qualifiers in {...}

diff --git a/lib/libvmod_std/vmod.py b/lib/libvmod_std/vmod.py
index d750c99..f751e82 100755
--- a/lib/libvmod_std/vmod.py
+++ b/lib/libvmod_std/vmod.py
@@ -185,16 +185,13 @@ while True:
 
 	args = list()
 
-	while True:
-		l = partition(l, ",")
-		t = l[0].strip()
-		if t not in ctypes:
+	for i in re.finditer("([A-Z_]+)\s*({[^}]+})?(,|$)", l):
+		at = i.group(1)
+		tq = i.group(2)
+		if at not in ctypes:
 			raise Exception(
-			    "Argument type '%s' not a valid type" % t)
-		args.append(t)
-		l = l[2]
-		if l == "":
-			break
+			    "Argument type '%s' not a valid type" % at)
+		args.append(at)
 
 	do_func(fname, rt_type, args)
 



More information about the varnish-commit mailing list