diff options
author | Ralf Wildenhues <Ralf.Wildenhues@gmx.de> | 2009-03-07 15:57:22 +0100 |
---|---|---|
committer | Ralf Wildenhues <Ralf.Wildenhues@gmx.de> | 2009-03-07 15:57:22 +0100 |
commit | eb3d397f20a68410d4d25e372ae5f84500f2e506 (patch) | |
tree | c88ad99f0ac92370ee6e8e841dfaef7b99d74f77 /lib/Automake/Variable.pm | |
parent | a88a2a277a7b5f835a32c2120ce6afbbeabd4167 (diff) | |
download | automake-eb3d397f20a68410d4d25e372ae5f84500f2e506.tar.gz |
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.
Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
Diffstat (limited to 'lib/Automake/Variable.pm')
-rw-r--r-- | lib/Automake/Variable.pm | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/Automake/Variable.pm b/lib/Automake/Variable.pm index 79bb42c7f..f8265862d 100644 --- a/lib/Automake/Variable.pm +++ b/lib/Automake/Variable.pm @@ -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"); + } } } } |