[PATCH 2/2] docs: restrict the set of characters for info keys

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When parsing the top level comment of a file, apibuild.py used
to split on any ':' character of a line regarding the first part
as a key for a setting, e.g. "Summary". The second part would then
be assigned as the value for that key.

This means you could not use a ':' character inside those comments
without ill effects.

Now, a key must consist solely of alphanumeric characters, '_' or '.'.

Signed-off-by: Claudio Bley <cbley@xxxxxxxxxx>
---
 docs/apibuild.py |   18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/docs/apibuild.py b/docs/apibuild.py
index 63b21e1..e6a45ec 100755
--- a/docs/apibuild.py
+++ b/docs/apibuild.py
@@ -10,6 +10,7 @@
 import os, sys
 import string
 import glob
+import re
 
 quiet=True
 warnings=0
@@ -655,20 +656,17 @@ class CParser:
         item = None
         for line in lines:
             line = line.lstrip().lstrip('*').lstrip()
-            try:
-                (it, line) = string.split(line, ":", 1)
-                item = it
-                line = line.lstrip()
+
+            m = re.match('([_.a-zA-Z0-9]+):(.*)', line)
+            if m:
+                item = m.group(1)
+                line = m.group(2).lstrip()
+
+            if item:
                 if res.has_key(item):
                     res[item] = res[item] + " " + line
                 else:
                     res[item] = line
-            except:
-                if item != None:
-                    if res.has_key(item):
-                        res[item] = res[item] + " " + line
-                    else:
-                        res[item] = line
         self.index.info = res
 
     def strip_lead_star(self, line):
-- 
1.7.9.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]