]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool.py: follow gnulib-tool changes, part 13
authorBruno Haible <bruno@clisp.org>
Sat, 9 Sep 2017 12:18:56 +0000 (14:18 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 9 Sep 2017 15:27:55 +0000 (17:27 +0200)
Follow gnulib-tool change
2015-06-01  Pádraig Brady  <P@draigBrady.com>
gnulib-tool: concatenate lib_SOURCES to a single line

pygnulib/GLEmiter.py
pygnulib/constants.py

index fde51a7dc7a10785a793bd924d370dc769882810..5446504c4fefd9c3393915487122aa6dc51fe550 100644 (file)
@@ -721,6 +721,9 @@ AC_DEFUN([%V1%_LIBSOURCES], [
                         (libname, libext, perhapsLT)
                     amsnippet1 += '%s_%s_DEPENDENCIES += @%sALLOCA@\n' % \
                         (libname, libext, perhapsLT)
+                amsnippet1 = constants.combine_lines_matching(
+                                 compiler('%s_%s_SOURCES' % (libname, libext)),
+                                 amsnippet1)
 
                 # Get unconditional snippet, edit it and save to amsnippet2.
                 amsnippet2 = module.getAutomakeSnippet_Unconditional()
index 596d1481bb438ed0833f80cf39a474500b9b5d96..2dc64e6b67e948997bdf5f5115de184ffbed1db2 100644 (file)
@@ -449,5 +449,30 @@ def combine_lines(text):
     line to it, inserting a space between them.'''
     return text.replace('\\\n', ' ')
 
+def combine_lines_matching(pattern, text):
+    '''Given a multiline string text, join lines by spaces, when the first
+    such line matches a given RegexObject pattern.
+    When a line that matches the pattern ends in a backslash, remove the
+    backslash and join the next line to it, inserting a space between them.
+    When a line that is the result of such a join ends in a backslash,
+    proceed likewise.'''
+    outerpos = 0
+    match = pattern.search(text, outerpos)
+    while match:
+        (startpos, pos) = match.span()
+        # Look how far the continuation lines extend.
+        pos = text.find('\n',pos)
+        while pos > 0 and text[pos-1] == '\\':
+            pos = text.find('\n',pos+1)
+        if pos < 0:
+            pos = len(text)
+        # Perform a combine_lines throughout the continuation lines.
+        partdone = text[:startpos] + combine_lines(text[startpos:pos])
+        outerpos = len(partdone)
+        text = partdone + text[pos:]
+        # Next round.
+        match = pattern.search(text, outerpos)
+    return text
+
 
 __all__ += ['APP', 'DIRS', 'MODES', 'UTILS']