[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gnulib-tool.py: Make regular expression more strict.
From: |
Bruno Haible |
Subject: |
Re: gnulib-tool.py: Make regular expression more strict. |
Date: |
Tue, 02 Apr 2024 16:35:40 +0200 |
Hello Collin,
> The 'inttostr' module seems like the best way to show this:
>
> diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py
> index fac29883f9..1724b250da 100644
> --- a/pygnulib/GLModuleSystem.py
> +++ b/pygnulib/GLModuleSystem.py
> @@ -1039,6 +1039,8 @@ class GLModuleTable(object):
> pattern = re.compile(r'^lib_SOURCES[\t ]*\+=([^#]*).*$',
> re.M)
> for matching_rhs in pattern.findall(snippet):
> files = matching_rhs.split(' ')
> + if module.name == 'inttostr':
> + print(files)
> for file in files:
> # Ignore .h files since they are not compiled.
> if not file.endswith('.h'):
>
> ['', '', '', '', 'imaxtostr.c', '', '', '', 'inttostr.c', '', '', '',
> 'offtostr.c', '', '', '', 'uinttostr.c', '', '', '',
> 'umaxtostr.c\n\nEXTRA_DIST', '+=', 'anytostr.c',
> 'inttostr.h\n\nEXTRA_lib_SOURCES', '+=', 'anytostr.c\n\n']
>
> After this patch:
>
> ['imaxtostr.c', 'inttostr.c', 'offtostr.c', 'uinttostr.c', 'umaxtostr.c']
Indeed, the previous value of 'files' was bad. And if modules/inttostr had
been like this:
lib_SOURCES += \
inttostr.h
the bad vs. correct file list would have been:
['', '', '', '', 'inttostr.h\n\nEXTRA_DIST', '+=', 'anytostr.c', ...]
['inttostr.h']
The bad file list does not lead to adding the 'dummy' module, whereas
the good file list does.
I'm thus applying your patch, with this modified ChangeLog entry. (If a patch
has visible effects, the entry's title line should mention these effects.)
You have also taught me about the use non-greedy regex matching :)
2024-04-02 Collin Funk <collin.funk1@gmail.com>
gnulib-tool.py: Fix determination whether to add the dummy module.
* pygnulib/GLModuleSystem.py (GLModuleSystem.add_dummy): Only match the
'lib_SOURCES' variable; stop at end-of-line.