[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/4] New channel `portability-recursive'.
From: |
Ralf Wildenhues |
Subject: |
[PATCH 1/4] New channel `portability-recursive'. |
Date: |
Sun, 8 Mar 2009 10:18:51 +0100 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
[ moving from automake@ ]
* Ralf Wildenhues wrote on Sat, Mar 07, 2009 at 04:16:33PM CET:
> git clone git://git.savannah.gnu.org/automake.git
> git branch je-silent origin/je-silent
(thanks Jan for the typo fix!)
> Detailed patch descriptions will follow on automake-patches,
This first patch in the series adds a new warning channel for warnings
about recursive variable expansions.
This warning channel is currently turned on by -Wall, but it should also
be turned on by -Wportability, I guess; or get its own switch. As noted
in some of the earlier discussions, recursive $(var1$(var2)) variable
expansions are in practice found to be rather portable (when the inner
variable uses ${..} or $(..), not plain $..).
As another FIXME note, a warning message would currently output a
slightly bogus string `$(var2', which should be fixed in the
scan_variable_expansions function. I refrained from that for now,
this is quite a hot code path and I wanted to do some measuring before
adding more non-regular expression matching.
Cheers,
Ralf
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.
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 = 'address@hidden' . "\$";
+my $_VARIABLE_CHARACTERS = 'address@hidden';
+my $_VARIABLE_PATTERN = '^' . $_VARIABLE_CHARACTERS . "\$";
+my $_VARIABLE_RECURSIVE_PATTERN =
+ '^(address@hidden|\$[({]' . $_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");
+ }
}
}
}
- [PATCH 1/4] New channel `portability-recursive'.,
Ralf Wildenhues <=