Cleanup of ERROR/WARNING message enhancement.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2012-05-04 07:01:08 -07:00
parent 097ab853db
commit 1d90ee174c

View File

@ -808,22 +808,33 @@ my @abbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
# Create 'currentlineinfo' # Create 'currentlineinfo'
# #
sub currentlineinfo() { sub currentlineinfo() {
if ( $currentfile ) { my $linenumber = $currentlinenumber || 1;
my $lineinfo = " $currentfilename ";
if ( $currentlinenumber eq 'EOF' ) { if ( $currentfile ) {
my $lineinfo = @includestack || @openstack ? "\n $currentfilename " : " $currentfilename ";
if ( $linenumber eq 'EOF' ) {
$lineinfo .= '(EOF)' $lineinfo .= '(EOF)'
} else { } else {
$currentlinenumber ||= 1; $lineinfo .= "(line $linenumber)";
$lineinfo .= "(line $currentlinenumber)"; }
#
# Unwind the current include stack
#
for ( my $i = @includestack - 1; $i >= 0; $i-- ) {
my $info = $includestack[$i];
$linenumber = $info->[2] || 1;
$lineinfo .= "\n from $info->[1] (line $linenumber)";
}
#
# Now unwind the open stack; each element is an include stack
#
for ( my $i = @openstack - 1; $i >= 0; $i-- ) { for ( my $i = @openstack - 1; $i >= 0; $i-- ) {
my $istack = $openstack[$i]; my $istack = $openstack[$i];
for ( my $j = ( @$istack - 1 ); $j >= 0; $j-- ) { for ( my $j = ( @$istack - 1 ); $j >= 0; $j-- ) {
my $info = $istack->[$j]; my $info = $istack->[$j];
$lineinfo .= "\n from $info->[1] (line $info->[2])"; $linenumber = $info->[2] || 1;
} $lineinfo .= "\n from $info->[1] (line $linenumber)";
} }
} }
@ -894,7 +905,6 @@ sub cleanup() {
# Issue fatal error message and die # Issue fatal error message and die
# #
sub fatal_error { sub fatal_error {
my $linenumber = $currentlinenumber || 1;
my $currentlineinfo = currentlineinfo; my $currentlineinfo = currentlineinfo;
$| = 1; #Reset output buffering (flush any partially filled buffers). $| = 1; #Reset output buffering (flush any partially filled buffers).