check-config: handle multiline config
authortimeless <timeless@mozdev.org>
Tue, 08 Dec 2015 08:21:46 +0000
changeset 27313 9d155accd8f1
parent 27312 f925d492113a
child 27314 a434f15dc0f4
check-config: handle multiline config
contrib/check-config.py
--- a/contrib/check-config.py	Tue Dec 08 08:36:00 2015 +0000
+++ b/contrib/check-config.py	Tue Dec 08 08:21:46 2015 +0000
@@ -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: