summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2017-09-09 14:18:56 +0200
committerBruno Haible <bruno@clisp.org>2017-09-09 17:27:55 +0200
commit2f0f4bea3c62b9c3c39cd3ec762564c8dc0c86da (patch)
tree441127e38b4771fb8043fc7e4a2d34579331328e
parentb880b7c93bb4d402333c8ebce971a7d6257cdef3 (diff)
downloadgnulib-2f0f4bea3c62b9c3c39cd3ec762564c8dc0c86da.tar.gz
gnulib-tool.py: follow gnulib-tool changes, part 13
Follow gnulib-tool change 2015-06-01 Pádraig Brady <P@draigBrady.com> gnulib-tool: concatenate lib_SOURCES to a single line
-rw-r--r--pygnulib/GLEmiter.py3
-rw-r--r--pygnulib/constants.py25
2 files changed, 28 insertions, 0 deletions
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index fde51a7dc7..5446504c4f 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -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()
diff --git a/pygnulib/constants.py b/pygnulib/constants.py
index 596d1481bb..2dc64e6b67 100644
--- a/pygnulib/constants.py
+++ b/pygnulib/constants.py
@@ -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']