[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gnulib-tool.py: Fix crash when no ACLOCAL_AMFLAGS is found.
From: |
Collin Funk |
Subject: |
Re: gnulib-tool.py: Fix crash when no ACLOCAL_AMFLAGS is found. |
Date: |
Sun, 02 Jun 2024 04:06:08 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Hi Bruno,
Bruno Haible <bruno@clisp.org> writes:
> Thanks for this recipe. I think this is worth a unit test, since it
> is a special case that is otherwise not tested.
Agreed. I can add one later today.
> The regular expression doesn't seem right:
[...]
> The point of using a non-greedy operator is to not include newlines
> in the match, right? So,
> re.compile(r'^ACLOCAL_AMFLAGS[\t ]*=[\t ]*([^#]*)', re.MULTILINE)
> wouldn't work?
Oops, good catch. I was trying to be clever and failed. :)
Here is something like what I was trying to do:
===================
import re
string = """
ACLOCAL_AMFLAGS =
ACLOCAL_AMFLAGS = -I m4 -I glm4 # ignore this please
"""
pattern = re.compile(r'^ACLOCAL_AMFLAGS[\t ]*=[\t ]*(.+?)[\t ]*(?:#|$)',
re.MULTILINE)
print('"' + re.search(pattern, string).group(1) + '"')
===================
Not sure if Makefile.am's are written like that in practice but here is
the output:
$ ./main.py
"-I m4 -I glm4"
Collin