2022-08-07 Bruno Haible <bruno@clisp.org>
+ gnulib-tool.py: Make regex uses more straightforward.
+ * pygnulib/GLModuleSystem.py: Don't use flag re.S on regular expressions
+ that are meant to match a single line only, and remove the use of the
+ "minimal matching" *? construct whose only purpose was to neutralize the
+ re.S flag.
+ * pygnulib/GLEmiter.py: Likewise.
+ * pygnulib/GLImport.py: Likewise.
+ * pygnulib/GLTestDir.py: Likewise.
+
gnulib-tool.py: Make regex uses more straightforward.
* pygnulib/GLEmiter.py: Don't use flag re.S on regular expressions on
regular expressions with no '.'.
if line.strip() ]
snippet = '%s\n' % '\n'.join(lines)
transformer = fileassistant.transformers.get('aux', '')
- pattern = re.compile('(^.*?$)', re.S | re.M)
+ pattern = re.compile('^(.*)$', re.M)
snippet = pattern.sub('%s\\1' % indentation, snippet)
if transformer:
args = ['sed', '-e', transformer]
emit += 'changequote([, ])dnl\n'
emit += 'AC_SUBST([LTALLOCA])'
if replace_auxdir:
- regex = 'AC_CONFIG_FILES\\(\\[(.*?)\\:build-aux/(.*?)\\]\\)'
+ regex = 'AC_CONFIG_FILES\\(\\[(.*)\\:build-aux/(.*)\\]\\)'
repl = 'AC_CONFIG_FILES([\\1:%s/\\2])' % auxdir
- pattern = re.compile(regex, re.S | re.M)
+ pattern = re.compile(regex, re.M)
emit = pattern.sub(repl, emit)
lines = [ line
for line in emit.split('\n')
amsnippet1 = amsnippet1.replace('lib_LIBRARIES', 'lib%_LIBRARIES')
amsnippet1 = amsnippet1.replace('lib_LTLIBRARIES', 'lib%_LTLIBRARIES')
if LD_flags:
- pattern = re.compile('lib_LDFLAGS[\t ]*\\+=(.*?)$', re.S | re.M)
+ pattern = re.compile('lib_LDFLAGS[\t ]*\\+=(.*)$', re.M)
amsnippet1 = pattern.sub('', amsnippet1)
- pattern = re.compile('lib_([A-Z][A-Z](?:.*?))', re.S | re.M)
+ pattern = re.compile('lib_([A-Z][A-Z](?:.*))', re.M)
amsnippet1 = pattern.sub('%s_%s_\\1' % (libname, libext),
amsnippet1)
amsnippet1 = amsnippet1.replace('$(GNULIB_', '$(' + module_indicator_prefix + '_GNULIB_')
# Get unconditional snippet, edit it and save to amsnippet2.
amsnippet2 = module.getAutomakeSnippet_Unconditional()
- pattern = re.compile('lib_([A-Z][A-Z](?:.*?))', re.S | re.M)
+ pattern = re.compile('lib_([A-Z][A-Z](?:.*))', re.M)
amsnippet2 = pattern.sub('%s_%s_\\1' % (libname, libext),
amsnippet2)
amsnippet2 = amsnippet2.replace('$(GNULIB_',
insnippets = False
inmakefile = False
regex = '^[a-zA-Z0-9_]*_%sLIBRARIES *\\+{0,1}= *%s.%s' % (perhapsLT, libname, libext)
- pattern = re.compile(regex, re.S | re.M)
+ pattern = re.compile(regex, re.M)
insnippets = bool(pattern.findall(allsnippets))
# Then test if $sourcebase/Makefile.am (if it exists) specifies it.
path = joinpath(sourcebase, 'Makefile.am')
snippet = snippet.replace('lib_LIBRARIES', 'lib%_LIBRARIES')
snippet = snippet.replace('lib_LTLIBRARIES', 'lib%_LTLIBRARIES')
if LD_flags:
- pattern = re.compile('lib_LDFLAGS[\t ]*\\+=(.*?)$', re.S | re.M)
+ pattern = re.compile('lib_LDFLAGS[\t ]*\\+=(.*)$', re.M)
snippet = pattern.sub('', snippet)
- pattern = re.compile('lib_([A-Z][A-Z](?:.*?))', re.S | re.M)
+ pattern = re.compile('lib_([A-Z][A-Z](?:.*))', re.M)
snippet = pattern.sub('libtests_a_\\1', snippet)
snippet = snippet.replace('$(GNULIB_', '$(' + module_indicator_prefix + '_GNULIB_')
snippet = snippet.replace('lib%_LIBRARIES', 'lib_LIBRARIES')
self.config.setAutoconfFile(path)
with codecs.open(path, 'rb', 'UTF-8') as file:
data = file.read()
- pattern = re.compile(r'^AC_CONFIG_AUX_DIR\((.*?)\)$', re.S | re.M)
+ pattern = re.compile(r'^AC_CONFIG_AUX_DIR\((.*)\)$', re.M)
match = pattern.findall(data)
if match:
result = cleaner(match)[0]
self.config.setAuxDir(self.cache['auxdir'])
# Guess autoconf version.
- pattern = re.compile(r'.*AC_PREREQ\((.*?)\)', re.S | re.M)
+ pattern = re.compile(r'.*AC_PREREQ\((.*)\)', re.M)
versions = cleaner(pattern.findall(data))
if versions:
version = sorted(set([ float(version)
# TODO: unconditional automake snippet for nontests modules
snippet = self.getAutomakeSnippet_Conditional()
snippet = constants.combine_lines(snippet)
- pattern = re.compile('^lib_SOURCES[\t ]*\\+=[\t ]*(.*?)$', re.S | re.M)
+ pattern = re.compile('^lib_SOURCES[\t ]*\\+=[\t ]*(.*)$', re.M)
mentioned_files = pattern.findall(snippet)
if mentioned_files != list():
mentioned_files = mentioned_files[-1].split(' ')
parts += [line]
result = ''.join(parts)
result = result.strip()
- pattern = re.compile('^(["<].*?[>"])', re.S | re.M)
+ pattern = re.compile('^(["<].*[>"])', re.M)
result = pattern.sub('#include \\1', result)
self.cache['include'] = result
return self.cache['include']
raise TypeError('each module must be a GLModule instance')
snippet = module.getAutomakeSnippet()
snippet = constants.remove_backslash_newline(snippet)
- pattern = re.compile('^lib_SOURCES[\t ]*\\+=[\t ]*(.*?)$', re.S | re.M)
+ pattern = re.compile('^lib_SOURCES[\t ]*\\+=[\t ]*(.*)$', re.M)
files = pattern.findall(snippet)
if files: # if source files were found
files = files[-1].split(' ')
notice = module.getNotice()
if notice:
print('Notice from module %s:' % str(module))
- pattern = re.compile('^(.*?)$', re.S | re.M)
+ pattern = re.compile('^(.*)$', re.M)
notice = pattern.sub(' \\1', notice)
print(notice)
else: # if not single_configure
notice = module.getNotice()
if notice:
print('Notice from module %s:' % str(module))
- pattern = re.compile('^(.*?)$', re.S | re.M)
+ pattern = re.compile('^(.*)$', re.M)
notice = pattern.sub(' \\1', notice)
print(notice)
for line in snippet.split('\n')
if line.strip() ]
snippet = '\n'.join(lines)
- pattern = re.compile('AC_REQUIRE\\(\\[([^()].*?)\\]\\)', re.S | re.M)
+ pattern = re.compile('AC_REQUIRE\\(\\[([^()].*)\\]\\)', re.M)
snippet = pattern.sub('\\1', snippet)
snippet = snippet.strip()
snippets += [snippet]
for line in snippet.split('\n')
if line.strip() ]
snippet = '\n'.join(lines)
- pattern = re.compile('AC_REQUIRE\\(\\[([^()].*?)\\]\\)', re.S | re.M)
+ pattern = re.compile('AC_REQUIRE\\(\\[([^()].*)\\]\\)', re.M)
snippet = pattern.sub('\\1', snippet)
snippet = snippet.strip()
snippets += [snippet]
# Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
regex_find = list()
- pattern = re.compile('^CLEANFILES[\t ]*\\+=(.*?)$', re.S | re.M)
+ pattern = re.compile('^CLEANFILES[\t ]*\\+=(.*)$', re.M)
regex_find += pattern.findall(snippet)
- pattern = re.compile('^MOSTLYCLEANFILES[\t ]*\\+=(.*?)$', re.S | re.M)
+ pattern = re.compile('^MOSTLYCLEANFILES[\t ]*\\+=(.*)$', re.M)
regex_find += pattern.findall(snippet)
regex_find = [ line.strip()
for line in regex_find
# Extract the value of "BUILT_SOURCES += ...". Remove variable references
# such $(FOO_H) because they don't refer to distributed files.
regex_find = list()
- pattern = re.compile('^BUILT_SOURCES[\t ]*\\+=(.*?)$', re.S | re.M)
+ pattern = re.compile('^BUILT_SOURCES[\t ]*\\+=(.*)$', re.M)
regex_find += pattern.findall(snippet)
regex_find = [ line.strip()
for line in regex_find
# Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
regex_find = list()
- pattern = re.compile('^CLEANFILES[\t ]*\\+=(.*?)$', re.S | re.M)
+ pattern = re.compile('^CLEANFILES[\t ]*\\+=(.*)$', re.M)
regex_find += pattern.findall(snippet)
- pattern = re.compile('^MOSTLYCLEANFILES[\t ]*\\+=(.*?)$', re.S | re.M)
+ pattern = re.compile('^MOSTLYCLEANFILES[\t ]*\\+=(.*)$', re.M)
regex_find += pattern.findall(snippet)
regex_find = [ line.strip()
for line in regex_find
# such $(FOO_H) because they don't refer to distributed files.
regex_find = list()
tests_built_sources = list()
- pattern = re.compile('^BUILT_SOURCES[\t ]*\\+=(.*?)$', re.S | re.M)
+ pattern = re.compile('^BUILT_SOURCES[\t ]*\\+=(.*)$', re.M)
regex_find += pattern.findall(snippet)
regex_find = [ line.strip()
for line in regex_find