]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool.py: Fix crash when no ACLOCAL_AMFLAGS is found.
authorCollin Funk <collin.funk1@gmail.com>
Sun, 2 Jun 2024 08:06:32 +0000 (01:06 -0700)
committerCollin Funk <collin.funk1@gmail.com>
Sun, 2 Jun 2024 08:06:32 +0000 (01:06 -0700)
* pygnulib/main.py (main) [import]: Use a regular expression to match
the ACLOCAL_AMFLAGS Makefile.am variable. Properly handle the case where
none is found.

ChangeLog
pygnulib/main.py

index 67b0ea66ef356861417cbc14c85f40054385e4fe..3a982c49887629f42f27024dc4b75dcce860bf90 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-06-02  Collin Funk  <collin.funk1@gmail.com>
+
+       gnulib-tool.py: Fix crash when no ACLOCAL_AMFLAGS is found.
+       * pygnulib/main.py (main) [import]: Use a regular expression to match
+       the ACLOCAL_AMFLAGS Makefile.am variable. Properly handle the case where
+       none is found.
+
 2024-05-31  Bruno Haible  <bruno@clisp.org>
 
        windows-once: Improve comments.
index 68be0ba28f1c33629ba211f49c477a99ddcf4f74..616713585860bc3a4d273f226363db71101e8ad4 100644 (file)
@@ -987,9 +987,12 @@ def main(temp_directory: str) -> None:
                 if os.path.isfile(filepath):
                     with open(filepath, mode='r', newline='\n', encoding='utf-8') as file:
                         data = file.read()
-                    data = data.split('ACLOCAL_AMFLAGS')[1]
-                    data = data[data.find('=') + 1 : data.find('\n')]
-                    aclocal_amflags = data.split()
+                    pattern = re.compile(r'^ACLOCAL_AMFLAGS[\t ]*=[\t ]*([^#]+?)$', re.MULTILINE)
+                    match = re.search(pattern, data)
+                    if match:
+                        aclocal_amflags = match.group(1).split()
+                    else:
+                        aclocal_amflags = []
                     for aclocal_amflag in aclocal_amflags:
                         if dirisnext:
                             # Ignore absolute directory pathnames, like /usr/local/share/aclocal.