From eb3d397f20a68410d4d25e372ae5f84500f2e506 Mon Sep 17 00:00:00 2001 From: Ralf Wildenhues Date: Sat, 7 Mar 2009 15:57:22 +0100 Subject: [PATCH] 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 --- ChangeLog | 13 +++++++++++++ lib/Automake/ChannelDefs.pm | 3 ++- lib/Automake/Variable.pm | 20 ++++++++++++++++---- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index bc8ad4d..e436f04 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 2009-03-07 Ralf Wildenhues + 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 + Improve NetBSD 'make -n' output for many standard targets. * automake.in (handle_tags): Let .MAKE depend on `tags-recursive' and `ctags-recursive' if appropriate. diff --git a/lib/Automake/ChannelDefs.pm b/lib/Automake/ChannelDefs.pm index 15362b5..60520b7 100644 --- a/lib/Automake/ChannelDefs.pm +++ b/lib/Automake/ChannelDefs.pm @@ -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'; diff --git a/lib/Automake/Variable.pm b/lib/Automake/Variable.pm index 79bb42c..f826586 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"); + } } } } -- 2.7.4