]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
automake: avoid Perl-level warning on empty variable $().
authorKarl Berry <karl@freefriends.org>
Sun, 30 Jun 2024 20:26:51 +0000 (13:26 -0700)
committerKarl Berry <karl@freefriends.org>
Sun, 30 Jun 2024 20:26:51 +0000 (13:26 -0700)
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.

lib/Automake/Variable.pm
t/list-of-tests.mk
t/varempty.sh [new file with mode: 0644]

index db1f6378d52cb594e98a4408c91e744bc0bd4b64..f97aab59ff65ca0a68ee43eb8f5f5df65caed4fe 100644 (file)
@@ -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/:[^:=]*=[^=]*$//;
index 1e0f364ba525ffaa6b7493bd31252c4cfb3022f4..e80ace4704973893cbf30e61831eb864d110c22b 100644 (file)
@@ -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 (file)
index 0000000..9eb45c4
--- /dev/null
@@ -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
+
+: