Don't get crossed up by trailing whitespace in shorewall.conf; beautify line images in progress messages

git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@5764 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
teastep 2007-03-30 23:21:08 +00:00
parent 160ba9570e
commit d4ec028a7e
2 changed files with 21 additions and 14 deletions

View File

@ -56,6 +56,7 @@ our @EXPORT = qw(ALLIPv4
$command
$doing
$done
$verbose
);
our @EXPORT_OK = ();
our @VERSION = 1.00;
@ -73,12 +74,18 @@ our $line = ''; # Current config file line
our ( $command, $doing, $done ) = qw/ compile Compiling Compiled/; #describe the current command, it's present progressive, and it's completion.
our $verbose;
my $object = 0; # Object file Handle Reference
my $lastlineblank = 0; # Avoid extra blank lines in the output
my $indent = '';
my ( $dir, $file ); # Object's Directory and File
my $tempfile; # Temporary File Name
BEGIN {
$verbose = $ENV{VERBOSE} || 0;
}
#
# Fatal Error
#
@ -166,28 +173,27 @@ sub save_progress_message_short( $ ) {
emit "progress_message $_[0]" if $object;
}
sub progress_message {
if ( $ENV{VERBOSE} > 1 ) {
my $ts = '';
$ts = ( localtime ) . ' ' if $ENV{TIMESTAMP};
print "${ts}@_\n";
}
}
sub timestamp() {
my ($sec, $min, $hr) = ( localtime ) [0,1,2];
printf '%02d:%02d:%02d ', $hr, $min, $sec;
}
sub progress_message {
if ( $verbose > 1 ) {
timestamp if $ENV{TIMESTAMP};
print "@_\n";
}
}
sub progress_message2 {
if ( $ENV{VERBOSE} > 0 ) {
if ( $verbose > 0 ) {
timestamp if $ENV{TIMESTAMP};
print "@_\n";
}
}
sub progress_message3 {
if ( $ENV{VERBOSE} >= 0 ) {
if ( $verbose >= 0 ) {
timestamp if $ENV{TIMESTAMP};
print "@_\n";
}

View File

@ -370,9 +370,10 @@ sub read_a_line {
$currentlinenumber++;
next if $nextline =~ /^\s*#/;
next if $nextline =~ /^\s*$/;
$nextline =~ s/#.*$//;
chomp $nextline;
$nextline =~ s/\s+/ /g if $verbose >= 2;
if ( substr( $nextline, -1, 1 ) eq '\\' ) {
$line .= substr( $nextline, 0, -1 );
@ -480,14 +481,14 @@ sub get_configuration() {
open_file $file;
while ( read_a_line ) {
if ( $line =~ /^([a-zA-Z]\w*)\s*=\s*(.*)$/ ) {
if ( $line =~ /^([a-zA-Z]\w*)=(.*?)\s*$/ ) {
my ($var, $val) = ($1, $2);
unless ( exists $config{$var} ) {
warning_message "Unknown configuration option \"$var\" ignored";
next;
}
$config{$var} = $val =~ /\"([^\"]*)\"$/ ? $1 : $val;
$config{$var} = ( $val =~ /\"([^\"]*)\"$/ ? $1 : $val );
} else {
fatal_error "Unrecognized entry in $file: $line";
}
@ -510,7 +511,7 @@ sub get_configuration() {
next if $line =~ /^\s*#/;
next if $line =~ /^\s*$/;
if ( $line =~ /^([a-zA-Z]\w*)\s*=\s*(.*)$/ ) {
if ( $line =~ /^([a-zA-Z]\w*)=(.*)$/ ) {
my ($var, $val) = ($1, $2);
unless ( exists $capabilities{$var} ) {
warning_message "Unknown capability \"$var\" ignored";