On Sun, Jun 30, 2024 at 10:28 PM Karl Berry <k...@freefriends.org> wrote:
> Hi Frederic, > > Hello, > NetworkManager: > Use of uninitialized value $var in string eq at > /usr/share/automake-1.16/Automake/Variable.pm line 754, <GEN2> line > 1169. > > From the Makefile.am you sent me separately (attached here for the > record), it seems that is coming from the use of $() in: > > introspection/%.h: introspection/%.c > $() > > Accordingly, I changed scan_variable_expansions (in Variable.pm) to not > worry if the variable name is empty (patch and test below). Could you > retry NetworkManager or the other packages and make sure the Perl > warning is gone, please? > All 3 packages are built successfully with the patch. > > It wasn't entirely clear to me if the line > _vapi_name = $(subst /,_,$(subst -,_,$(subst .,_,$(1)))) > might also be causing trouble, but I think Automake already recognizes > that ok (and gives a warning, by default, but an Automake warning, not a > Perl warning.) > > As an aside, I'm curious as to why the $() is used. It seems > a mysterious way to do nothing. Do you know? --thanks, karl. > No clue, sorry. We'd need to ask the corresponding projects. Fred. > > > ----------------------------------------------------------------------------- > automake: avoid Perl-level warning on empty variable $(). > > https://lists.gnu.org/archive/html/automake/2024-06/msg00085.html > > * lib/Automake/Variable.pm (scan_variable_expansions): recognize > and do nothing if the variable name is empty: $(). > * t/varempty.sh: new test. > * t/list-of-tests.mk (handwritten_TESTS): add it. > diff --git a/lib/Automake/Variable.pm b/lib/Automake/Variable.pm > index db1f6378d..f97aab59f 100644 > --- a/lib/Automake/Variable.pm > +++ b/lib/Automake/Variable.pm > @@ -751,7 +751,11 @@ sub scan_variable_expansions ($) > while ($text =~ m{\$(?:\{([^\}]*)\}|\(([^\)]*)\)|(\$))}g) > { > my $var = $1 || $2 || $3; > - next if $var eq '$'; > + next if (! defined $var) || ($var eq '$'); > + # we check for $var being defined because NetworkManager and other > + # packages use the strange construct $(). > + # https://lists.gnu.org/archive/html/automake/2024-06/msg00085.html > + > # The occurrence may look like $(string1[:subst1=[subst2]]) but > # we want only 'string1'. > $var =~ s/:[^:=]*=[^=]*$//; > diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk > index 1e0f364ba..e80ace470 100644 > --- a/t/list-of-tests.mk > +++ b/t/list-of-tests.mk > @@ -1282,6 +1282,7 @@ t/vala-per-target-flags.sh \ > t/vala-recursive-setup.sh \ > t/vala-vapi.sh \ > t/vala-vpath.sh \ > +t/varempty.sh \ > t/vars.sh \ > t/vars3.sh \ > t/var-recurs.sh \ > diff --git a/t/varempty.sh b/t/varempty.sh > new file mode 100644 > index 000000000..9eb45c421 > --- /dev/null > +++ b/t/varempty.sh > @@ -0,0 +1,36 @@ > +#! /bin/sh > +# Copyright (C) 2024 Free Software Foundation, Inc. > +# > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 2, or (at your option) > +# any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see <https://www.gnu.org/licenses/>. > + > +# An empty variable name $() should not cause a Perl warning, namely: > +# Use of uninitialized value $var in string eq at > +# .../lib/Automake/Variable.pm line 754, <GEN2> line 3. > +# (in scan_variable_expansions) > +# > +# This showed up with the NetworkManager and other packages in Fedora: > +# https://lists.gnu.org/archive/html/automake/2024-06/msg00085.html > +# (The actual purpose of the "$()" is unclear.) > + > +. test-init.sh > + > +cat > Makefile.am << 'END' > +x: > + $() > +END > + > +$ACLOCAL > +$AUTOMAKE > + > +: > Running command: git commit \-q \-F \.\/vc\-dwim\-log\-wBh6_U > \-\-author\=Karl\ Berry\ \<karl\@freefriends\.org\> \-\- ChangeLog > + set +x > > compile finished at Sun Jun 30 13:26:51 2024 > >