From: Karl Berry Date: Sun, 30 Jun 2024 20:26:51 +0000 (-0700) Subject: automake: avoid Perl-level warning on empty variable $(). X-Git-Tag: v1.17~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b020a9ca888a3af2e18ecd77fa66c6ca6811329f;p=thirdparty%2Fautomake.git 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 . + +# 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, 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 + +: