From: Bruno Haible Date: Sat, 9 Sep 2017 12:18:56 +0000 (+0200) Subject: gnulib-tool.py: follow gnulib-tool changes, part 13 X-Git-Tag: v1.0~5927 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=2f0f4bea3c62b9c3c39cd3ec762564c8dc0c86da;p=gnulib.git gnulib-tool.py: follow gnulib-tool changes, part 13 Follow gnulib-tool change 2015-06-01 Pádraig Brady gnulib-tool: concatenate lib_SOURCES to a single line --- 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']