]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
gnulib-tool.py: Remove redundant backslashes from regexps.
authorCollin Funk <collin.funk1@gmail.com>
Thu, 11 Apr 2024 18:27:34 +0000 (11:27 -0700)
committerBruno Haible <bruno@clisp.org>
Thu, 11 Apr 2024 18:48:28 +0000 (20:48 +0200)
* pygnulib/GLTestDir.py (GLTestDir.execute): Don't backslash ']' when it
is outside of a set.
* pygnulib/GLImport.py (GLImport.__init__): Don't use a backslash when
']' is at the start of a '[...]' set. Don't backslash special characters
in a '[...]' set since they have their meaning dropped.
* pygnulib/main.py (main): Likewise.

ChangeLog
pygnulib/GLImport.py
pygnulib/GLTestDir.py
pygnulib/main.py

index 553533499b850a64284462e02919aedf01203bca..f416f5c8f1c20492036aa6040f1bab99651a4f89 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-04-11  Collin Funk  <collin.funk1@gmail.com>
+
+       gnulib-tool.py: Remove redundant backslashes from regexps.
+       * pygnulib/GLTestDir.py (GLTestDir.execute): Don't backslash ']' when it
+       is outside of a set.
+       * pygnulib/GLImport.py (GLImport.__init__): Don't use a backslash when
+       ']' is at the start of a '[...]' set. Don't backslash special characters
+       in a '[...]' set since they have their meaning dropped.
+       * pygnulib/main.py (main): Likewise.
+
 2024-04-11  Collin Funk  <collin.funk1@gmail.com>
 
        gnulib-tool.py: Simplify regular expressions.
index 46beb7e2a6deb9b944a528b61563ef73951fd995..b200c7b250f75acf51d20bf0b4a491f73ffa9053 100644 (file)
@@ -93,7 +93,7 @@ class GLImport:
         self.cache.setAuxDir('.')
         with codecs.open(self.config.getAutoconfFile(), 'rb', 'UTF-8') as file:
             data = file.read()
-        pattern = re.compile(r'^AC_CONFIG_AUX_DIR\([\[ ]*([^\]"\$`\\\)]+).*?$', re.MULTILINE)
+        pattern = re.compile(r'^AC_CONFIG_AUX_DIR\([\[ ]*([^]"$`\\)]+).*?$', re.MULTILINE)
         match = pattern.search(data)
         if match:
             self.cache.setAuxDir(match.group(1))
@@ -261,7 +261,7 @@ class GLImport:
             if self.config['destdir']:
                 with open(self.config['configure_ac'], encoding='utf-8') as file:
                     data = file.read()
-                pattern = re.compile(r'^.*AM_INIT_AUTOMAKE\([\[ ]*([^\]\)]*).*$', re.MULTILINE)
+                pattern = re.compile(r'^.*AM_INIT_AUTOMAKE\([\[ ]*([^])]*).*$', re.MULTILINE)
                 configure_ac_automake_options = pattern.findall(data)
                 if configure_ac_automake_options:
                     automake_options = { x
index f6ab4f9d2e86bff3d984fc0a9006fb18a75715c6..5fd4197e521b2362dd659c92f91d2e0428cd6e6d 100644 (file)
@@ -463,7 +463,7 @@ class GLTestDir:
                                   for line in snippet.split('\n')
                                   if line.strip() ]
                         snippet = lines_to_multiline(lines)
-                        pattern = re.compile(r'AC_REQUIRE\(\[([^()]*)\]\)', re.M)
+                        pattern = re.compile(r'AC_REQUIRE\(\[([^()]*)]\)', re.M)
                         snippet = pattern.sub(r'\1', snippet)
                         snippet = snippet.strip()
                         snippets.append(snippet)
@@ -577,7 +577,7 @@ class GLTestDir:
                           for line in snippet.split('\n')
                           if line.strip() ]
                 snippet = lines_to_multiline(lines)
-                pattern = re.compile(r'AC_REQUIRE\(\[([^()]*)\]\)', re.M)
+                pattern = re.compile(r'AC_REQUIRE\(\[([^()]*)]\)', re.M)
                 snippet = pattern.sub(r'\1', snippet)
                 snippet = snippet.strip()
                 snippets.append(snippet)
index f8d082705dad7d96eaca6ea133c51887717f71de..5fec0ccc4a6f319108d9d0f1268d46dc79d5bc7e 100644 (file)
@@ -927,7 +927,7 @@ def main() -> None:
             configure_ac_data = file.read()
 
         guessed_m4dirs = []
-        pattern = re.compile(r'^.*AC_CONFIG_MACRO_DIRS?\([\[ ]*([^\]"\$`\\\)]*).*$', re.MULTILINE)
+        pattern = re.compile(r'^.*AC_CONFIG_MACRO_DIRS?\([\[ ]*([^]"$`\\)]*).*$', re.MULTILINE)
         match = pattern.findall(configure_ac_data)
         # Append the match to guessed_m4dirs.
         if match:
@@ -1015,7 +1015,7 @@ def main() -> None:
                     # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
                     filepath = joinpath(destdir, 'aclocal.m4')
                     if isfile(filepath):
-                        pattern = re.compile(r'm4_include\(\[(.*?)\]\)')
+                        pattern = re.compile(r'm4_include\(\[(.*?)]\)')
                         with codecs.open(filepath, 'rb', 'UTF-8') as file:
                             m4dirs = pattern.findall(file.read())
                         m4dirs = [ os.path.dirname(m4dir)