]> granicus.if.org Git - python/commitdiff
Patch #409504: Fix regex problems, consider \-continuation lines in Makefile
authorMartin v. Löwis <martin@v.loewis.de>
Wed, 21 Mar 2001 06:58:25 +0000 (06:58 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Wed, 21 Mar 2001 06:58:25 +0000 (06:58 +0000)
and Setup.

Tools/freeze/makeconfig.py
Tools/freeze/parsesetup.py

index 11c97d8bd0527aac80d2df82f29b574df3f1d397..687f27177bac74ed289a7caa5c282338a51d9b1f 100644 (file)
@@ -12,7 +12,7 @@ def makeconfig(infp, outfp, modules, with_ifdef=0):
                line = infp.readline()
                if not line: break
                outfp.write(line)
-               if m1 and m1.search(line) >= 0:
+               if m1 and m1.search(line):
                        m1 = None
                        for mod in modules:
                                if mod in never:
@@ -22,7 +22,7 @@ def makeconfig(infp, outfp, modules, with_ifdef=0):
                                outfp.write('extern void init%s();\n' % mod)
                                if with_ifdef:
                                        outfp.write("#endif\n")
-               elif m2 and m2.search(line) >= 0:
+               elif m2 and m2.search(line):
                        m2 = None
                        for mod in modules:
                                if mod in never:
index 7f90075e8b42a43e904eef0c370c2aa51ad172bf..7a6b72ef770598f570b7ea1a4232147a504788bd 100644 (file)
@@ -13,11 +13,17 @@ makevardef = re.compile('^([a-zA-Z0-9_]+)[ \t]*=(.*)')
 def getmakevars(filename):
        variables = {}
        fp = open(filename)
+       pendingline = ""
        try:
                while 1:
                        line = fp.readline()
+                       if pendingline:
+                               line = pendingline + line
+                               pendingline = ""
                        if not line:
                                break
+                       if line.endswith('\\\n'):
+                               pendingline = line[:-2]
                        matchobj = makevardef.match(line)
                        if not matchobj:
                                continue
@@ -44,15 +50,22 @@ def getsetupinfo(filename):
        modules = {}
        variables = {}
        fp = open(filename)
+       pendingline = ""
        try:
                while 1:
                        line = fp.readline()
+                       if pendingline:
+                               line = pendingline + line
+                               pendingline = ""
                        if not line:
                                break
                        # Strip comments
                        i = string.find(line, '#')
                        if i >= 0:
                                line = line[:i]
+                       if line.endswith('\\\n'):
+                               pendingline = line[:-2]
+                               continue
                        matchobj = setupvardef.match(line)
                        if matchobj:
                                (name, value) = matchobj.group(1, 2)