Patchwork [4,of,5] check-config: handle multiline config

login
register
mail settings
Submitter timeless@mozdev.org
Date Dec. 8, 2015, 9:35 a.m.
Message ID <9a475b110be4f22aade4.1449567317@waste.org>
Download mbox | patch
Permalink /patch/11936/
State Accepted
Headers show

Comments

timeless@mozdev.org - Dec. 8, 2015, 9:35 a.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1449562906 0
#      Tue Dec 08 08:21:46 2015 +0000
# Node ID 9a475b110be4f22aade4b02019c70a31bcb4ef91
# Parent  7f2a4607333500cb5bb0d749ce6b1c9c161948bb
check-config: handle multiline config

Patch

diff --git a/contrib/check-config.py b/contrib/check-config.py
--- a/contrib/check-config.py
+++ b/contrib/check-config.py
@@ -13,14 +13,16 @@ 
 foundopts = {}
 documented = {}
 
-configre = (r"""ui\.config(|int|bool|list)\(['"](\S+)['"], ?"""
-            r"""['"](\S+)['"](,\s(?:default=)?(\S+?))?\)""")
+configre = (r"""ui\.config(|int|bool|list)\(['"](\S+)['"],\s*"""
+            r"""['"](\S+)['"](,\s+(?:default=)?(\S+?))?\)""")
+configpartialre = (r"""ui\.config""")
 
 def main(args):
     for f in args:
         sect = ''
         prevname = ''
         confsect = ''
+        carryover = ''
         for l in open(f):
 
             # check topic-like bits
@@ -67,7 +69,8 @@ 
                 documented[m.group(1)] = 1
 
             # look for code-like bits
-            m = re.search(configre, l)
+            line = carryover + l
+            m = re.search(configre, line, re.MULTILINE)
             if m:
                 ctype = m.group(1)
                 if not ctype:
@@ -83,6 +86,13 @@ 
                     print "conflict on %s: %r != %r" % (name, (ctype, default),
                                                         foundopts[name])
                 foundopts[name] = (ctype, default)
+                carryover = ''
+            else:
+                m = re.search(configpartialre, line)
+                if m:
+                    carryover = line
+                else:
+                    carryover = ''
 
     for name in sorted(foundopts):
         if name not in documented: