Print out the include/open stack in WARNING and ERROR messages.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2012-05-03 17:17:55 -07:00
parent bd30d59f3d
commit 3e37f47fb5

View File

@ -804,13 +804,42 @@ sub initialize( $;$ ) {
my @abbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
#
# Create 'currentlineinfo'
#
sub currentlineinfo() {
if ( $currentfile ) {
my $lineinfo = " $currentfilename ";
if ( $currentlinenumber eq 'EOF' ) {
$lineinfo .= '(EOF)'
} else {
$currentlinenumber ||= 1;
$lineinfo .= "(line $currentlinenumber)";
for ( my $i = @openstack - 1; $i >= 0; $i-- ) {
my $istack = $openstack[$i];
for ( my $j = ( @$istack - 1 ); $j >= 0; $j-- ) {
my $info = $istack->[$j];
$lineinfo .= "\n from $info->[1] (line $info->[2])";
}
}
}
$lineinfo;
} else {
'';
}
}
#
# Issue a Warning Message
#
sub warning_message
{
my $linenumber = $currentlinenumber || 1;
my $currentlineinfo = $currentfile ? " : $currentfilename " . ( $linenumber eq 'EOF' ? '(EOF)' : "(line $linenumber)" ) : '';
my $currentlineinfo = currentlineinfo;
our @localtime;
$| = 1; #Reset output buffering (flush any partially filled buffers).
@ -866,7 +895,7 @@ sub cleanup() {
#
sub fatal_error {
my $linenumber = $currentlinenumber || 1;
my $currentlineinfo = $currentfile ? " : $currentfilename " . ( $linenumber eq 'EOF' ? '(EOF)' : "(line $linenumber)" ) : '';
my $currentlineinfo = currentlineinfo;
$| = 1; #Reset output buffering (flush any partially filled buffers).
@ -1901,7 +1930,7 @@ EOF
#
sub push_open( $ ) {
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber, $ifstack ];
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber, $ifstack ] if $currentfile;
my @a = @includestack;
push @openstack, \@a;
@includestack = ();