]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
New channel `portability-recursive'.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 7 Mar 2009 14:57:22 +0000 (15:57 +0100)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 7 Mar 2009 14:57:22 +0000 (15:57 +0100)
Add new channel for portability warnings about recursive make
variable expansions `$(var1$(var2))'.  Enable it alongside
`-Wportability'.

* lib/Automake/ChannelDefs.pm (Automake::ChannelDefs): Register
channel `portability-recursive'.
* lib/Automake/Variable.pm (_VARIABLE_CHARACTERS)
(_VARIABLE_RECURSIVE_PATTERN): New variables.
(check_variable_expansions): Diagnose recursive variable
expansions through the new channel.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
ChangeLog
lib/Automake/ChannelDefs.pm
lib/Automake/Variable.pm

index bc8ad4d0034c2b18c43ba5d2f27bc7e279d43ebf..e436f046cfdba8963d908bfe670fd11d1b7e64f9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2009-03-07  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
+
+       New channel `portability-recursive'.
+       Add new channel for portability warnings about recursive make
+       variable expansions `$(var1$(var2))'.  Enable it alongside
+       `-Wportability'.
+       * lib/Automake/ChannelDefs.pm (Automake::ChannelDefs): Register
+       channel `portability-recursive'.
+       * lib/Automake/Variable.pm (_VARIABLE_CHARACTERS)
+       (_VARIABLE_RECURSIVE_PATTERN): New variables.
+       (check_variable_expansions): Diagnose recursive variable
+       expansions through the new channel.
+
 2009-03-07  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        Improve NetBSD 'make -n' output for many standard targets.
index 15362b514fbc2ced2fa4ae77fc6128c8b508081f..60520b735675477a1d88eeb8d9a4c7146d95e4f7 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2002, 2003, 2006, 2008 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2006, 2008, 2009 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
@@ -154,6 +154,7 @@ register_channel 'gnu', type => 'warning';
 register_channel 'obsolete', type => 'warning', silent => 1;
 register_channel 'override', type => 'warning', silent => 1;
 register_channel 'portability', type => 'warning', silent => 1;
+register_channel 'portability-recursive', type => 'warning', silent => 1;
 register_channel 'syntax', type => 'warning';
 register_channel 'unsupported', type => 'warning';
 
index 79bb42c7f72baf190fcdb45af39d210497e5d7bc..f8265862d24c102731ef43a0773ce9593c04a087 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2003, 2004, 2005, 2006, 2008  Free Software Foundation, Inc.
+# Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009  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
@@ -128,7 +128,10 @@ non-object).
 
 =cut
 
-my $_VARIABLE_PATTERN = '^[.A-Za-z0-9_@]+' . "\$";
+my $_VARIABLE_CHARACTERS = '[.A-Za-z0-9_@]+';
+my $_VARIABLE_PATTERN = '^' . $_VARIABLE_CHARACTERS . "\$";
+my $_VARIABLE_RECURSIVE_PATTERN =
+    '^([.A-Za-z0-9_@]|\$[({]' . $_VARIABLE_CHARACTERS . '[})]?)+' . "\$";
 
 # The order in which variables should be output.  (May contain
 # duplicates -- only the first occurrence matters.)
@@ -771,8 +774,17 @@ sub check_variable_expansions ($$)
          # Mention this in the diagnostic.
          my $gnuext = "";
          $gnuext = "\n(probably a GNU make extension)" if $var =~ / /;
-         msg ('portability', $where,
-              "$var: non-POSIX variable name$gnuext");
+         # Accept recursive variable expansions if so desired
+         # (we hope they are rather portable in practice).
+         if ($var =~ /$_VARIABLE_RECURSIVE_PATTERN/o)
+           {
+             msg ('portability-recursive', $where,
+                  "$var: non-POSIX recursive variable expansion$gnuext");
+           }
+         else
+           {
+             msg ('portability', $where, "$var: non-POSIX variable name$gnuext");
+           }
        }
     }
 }