mirror of
https://gitlab.com/shorewall/code.git
synced 2025-06-01 07:25:42 +02:00
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:
parent
160ba9570e
commit
d4ec028a7e
@ -56,6 +56,7 @@ our @EXPORT = qw(ALLIPv4
|
|||||||
$command
|
$command
|
||||||
$doing
|
$doing
|
||||||
$done
|
$done
|
||||||
|
$verbose
|
||||||
);
|
);
|
||||||
our @EXPORT_OK = ();
|
our @EXPORT_OK = ();
|
||||||
our @VERSION = 1.00;
|
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 ( $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 $object = 0; # Object file Handle Reference
|
||||||
my $lastlineblank = 0; # Avoid extra blank lines in the output
|
my $lastlineblank = 0; # Avoid extra blank lines in the output
|
||||||
my $indent = '';
|
my $indent = '';
|
||||||
my ( $dir, $file ); # Object's Directory and File
|
my ( $dir, $file ); # Object's Directory and File
|
||||||
my $tempfile; # Temporary File Name
|
my $tempfile; # Temporary File Name
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
$verbose = $ENV{VERBOSE} || 0;
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Fatal Error
|
# Fatal Error
|
||||||
#
|
#
|
||||||
@ -166,28 +173,27 @@ sub save_progress_message_short( $ ) {
|
|||||||
emit "progress_message $_[0]" if $object;
|
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() {
|
sub timestamp() {
|
||||||
my ($sec, $min, $hr) = ( localtime ) [0,1,2];
|
my ($sec, $min, $hr) = ( localtime ) [0,1,2];
|
||||||
printf '%02d:%02d:%02d ', $hr, $min, $sec;
|
printf '%02d:%02d:%02d ', $hr, $min, $sec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub progress_message {
|
||||||
|
if ( $verbose > 1 ) {
|
||||||
|
timestamp if $ENV{TIMESTAMP};
|
||||||
|
print "@_\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub progress_message2 {
|
sub progress_message2 {
|
||||||
if ( $ENV{VERBOSE} > 0 ) {
|
if ( $verbose > 0 ) {
|
||||||
timestamp if $ENV{TIMESTAMP};
|
timestamp if $ENV{TIMESTAMP};
|
||||||
print "@_\n";
|
print "@_\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub progress_message3 {
|
sub progress_message3 {
|
||||||
if ( $ENV{VERBOSE} >= 0 ) {
|
if ( $verbose >= 0 ) {
|
||||||
timestamp if $ENV{TIMESTAMP};
|
timestamp if $ENV{TIMESTAMP};
|
||||||
print "@_\n";
|
print "@_\n";
|
||||||
}
|
}
|
||||||
|
@ -370,9 +370,10 @@ sub read_a_line {
|
|||||||
$currentlinenumber++;
|
$currentlinenumber++;
|
||||||
next if $nextline =~ /^\s*#/;
|
next if $nextline =~ /^\s*#/;
|
||||||
next if $nextline =~ /^\s*$/;
|
next if $nextline =~ /^\s*$/;
|
||||||
|
|
||||||
$nextline =~ s/#.*$//;
|
$nextline =~ s/#.*$//;
|
||||||
|
|
||||||
chomp $nextline;
|
chomp $nextline;
|
||||||
|
$nextline =~ s/\s+/ /g if $verbose >= 2;
|
||||||
|
|
||||||
if ( substr( $nextline, -1, 1 ) eq '\\' ) {
|
if ( substr( $nextline, -1, 1 ) eq '\\' ) {
|
||||||
$line .= substr( $nextline, 0, -1 );
|
$line .= substr( $nextline, 0, -1 );
|
||||||
@ -480,14 +481,14 @@ sub get_configuration() {
|
|||||||
open_file $file;
|
open_file $file;
|
||||||
|
|
||||||
while ( read_a_line ) {
|
while ( read_a_line ) {
|
||||||
if ( $line =~ /^([a-zA-Z]\w*)\s*=\s*(.*)$/ ) {
|
if ( $line =~ /^([a-zA-Z]\w*)=(.*?)\s*$/ ) {
|
||||||
my ($var, $val) = ($1, $2);
|
my ($var, $val) = ($1, $2);
|
||||||
unless ( exists $config{$var} ) {
|
unless ( exists $config{$var} ) {
|
||||||
warning_message "Unknown configuration option \"$var\" ignored";
|
warning_message "Unknown configuration option \"$var\" ignored";
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
$config{$var} = $val =~ /\"([^\"]*)\"$/ ? $1 : $val;
|
$config{$var} = ( $val =~ /\"([^\"]*)\"$/ ? $1 : $val );
|
||||||
} else {
|
} else {
|
||||||
fatal_error "Unrecognized entry in $file: $line";
|
fatal_error "Unrecognized entry in $file: $line";
|
||||||
}
|
}
|
||||||
@ -510,7 +511,7 @@ sub get_configuration() {
|
|||||||
next if $line =~ /^\s*#/;
|
next if $line =~ /^\s*#/;
|
||||||
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);
|
my ($var, $val) = ($1, $2);
|
||||||
unless ( exists $capabilities{$var} ) {
|
unless ( exists $capabilities{$var} ) {
|
||||||
warning_message "Unknown capability \"$var\" ignored";
|
warning_message "Unknown capability \"$var\" ignored";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user