Changeset: 35cb25913514 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=35cb25913514
Modified Files:
        testing/exportutils.py
        testing/listexports.py.in
Branch: Oct2014
Log Message:

Moved more code to exportutils.py.


diffs (75 lines):

diff --git a/testing/exportutils.py b/testing/exportutils.py
--- a/testing/exportutils.py
+++ b/testing/exportutils.py
@@ -10,6 +10,13 @@ defre = re.compile(r'^[ \t]*#[ \t]*defin
 # line starting with a "#"
 cldef = re.compile(r'^[ \t]*#', re.MULTILINE)
 
+# white space
+spcre = re.compile(r'\s+')
+
+# some regexps helping to normalize a declaration
+strre = re.compile(r'([^ *])\*')
+comre = re.compile(r',\s*')
+
 # do something a bit like the C preprocessor
 #
 # we expand function-like macros and remove all ## sequences from the
@@ -72,3 +79,17 @@ def preprocess(data):
             if not cldef.match(line):
                 ndata.append(line)
     return '\n'.join(ndata)
+
+def normalize(decl):
+    decl = spcre.sub(' ', decl) \
+                .replace(' ;', ';') \
+                .replace(' (', '(') \
+                .replace('( ', '(') \
+                .replace(' )', ')') \
+                .replace(') ', ')') \
+                .replace('* ', '*') \
+                .replace(' ,', ',') \
+                .replace(')__attribute__', ') __attribute__')
+    decl = strre.sub(r'\1 *', decl)
+    decl = comre.sub(', ', decl)
+    return decl
diff --git a/testing/listexports.py.in b/testing/listexports.py.in
--- a/testing/listexports.py.in
+++ b/testing/listexports.py.in
@@ -47,16 +47,9 @@ cmtre = re.compile(r'/\*.*?\*/|//[^\n]*'
 # in "export"
 expre = re.compile(r'\b[a-zA-Z_0-9]+export\s+(?P<decl>[^;]*;)', re.MULTILINE)
 
-# white space
-spcre = re.compile(r'\s+')
-
 # the function or variable name
 nmere = re.compile(r'\b(?P<name>[a-zA-Z_][a-zA-Z_0-9]*)\s*[[(;]')
 
-# some regexps helping to normalize the output
-strre = re.compile(r'([^ *])\*')
-comre = re.compile(r',\s*')
-
 def extract(f):
     decls = []
     data = open(f).read()
@@ -73,18 +66,7 @@ def extract(f):
     res = expre.search(data)
     while res is not None:
         pos = res.end(0)
-        decl = res.group('decl')
-        decl = spcre.sub(' ', decl) \
-            .replace(' ;', ';') \
-            .replace(' (', '(') \
-            .replace('( ', '(') \
-            .replace(' )', ')') \
-            .replace(') ', ')') \
-            .replace('* ', '*') \
-            .replace(' ,', ',') \
-            .replace(')__attribute__', ') __attribute__')
-        decl = strre.sub(r'\1 *', decl)
-        decl = comre.sub(', ', decl)
+        decl = exportutils.normalize(res.group('decl'))
         res = nmere.search(decl)
         if res is not None:
             decls.append((res.group('name'), decl))
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to