Fix for parsing config files with empty values

Thanks to Stefan Steiner
This commit is contained in:
Duncan Ferguson 2010-12-03 14:18:05 +00:00
parent 5de65fbf77
commit 69a51ae54c
4 changed files with 13 additions and 5 deletions

View file

@ -1,3 +1,6 @@
????-??-?? Duncan Ferguson <duncan_ferguson@user.sf.net> - v4.00_07
* Fix for parsing config files with empty values (Stefan Steiner)
2010-09-20 Duncan Ferguson <duncan_ferguson@user.sf.net> - v4.00_06 2010-09-20 Duncan Ferguson <duncan_ferguson@user.sf.net> - v4.00_06
* Fix test error on 5.8.8 (reported by Wei Wang) * Fix test error on 5.8.8 (reported by Wei Wang)
* Added '--list', '-L' to list available cluster tags (idea from Markus Manzke) * Added '--list', '-L' to list available cluster tags (idea from Markus Manzke)

View file

@ -17,7 +17,7 @@ name: App-ClusterSSH
provides: provides:
App::ClusterSSH: App::ClusterSSH:
file: lib/App/ClusterSSH.pm file: lib/App/ClusterSSH.pm
version: 4.00_06 version: 4.00_07
App::ClusterSSH::Base: App::ClusterSSH::Base:
file: lib/App/ClusterSSH/Base.pm file: lib/App/ClusterSSH/Base.pm
version: 0.02 version: 0.02
@ -40,4 +40,4 @@ resources:
repository: repository:
- http://clusterssh.git.sourceforge.net/ - http://clusterssh.git.sourceforge.net/
- http://github.com/duncs/clusterssh - http://github.com/duncs/clusterssh
version: 4.00_06 version: 4.00_07

1
THANKS
View file

@ -37,3 +37,4 @@ Roland Rosenfeld
Wei Wang Wei Wang
Markus Manzke Markus Manzke
Simon Fraser Simon Fraser
Stefan Steiner

View file

@ -3,7 +3,7 @@ package App::ClusterSSH;
use 5.008.004; use 5.008.004;
use warnings; use warnings;
use strict; use strict;
use version; our $VERSION = version->new('4.00_06'); use version; our $VERSION = version->new('4.00_07');
use Carp; use Carp;
@ -269,6 +269,8 @@ sub parse_config_file($) {
; # ignore blank lines & commented lines ; # ignore blank lines & commented lines
$l =~ s/#.*//; # remove comments from remaining lines $l =~ s/#.*//; # remove comments from remaining lines
$l =~ s/\s*$//; # remove trailing whitespace $l =~ s/\s*$//; # remove trailing whitespace
# look for continuation lines
chomp $l; chomp $l;
if ( $l =~ s/\\\s*$// ) { if ( $l =~ s/\\\s*$// ) {
$l .= <CFG>; $l .= <CFG>;
@ -277,9 +279,11 @@ sub parse_config_file($) {
next unless $l =~ m/\s*(\S+)\s*=\s*(.*)\s*/; next unless $l =~ m/\s*(\S+)\s*=\s*(.*)\s*/;
my ( $key, $value ) = ( $1, $2 ); my ( $key, $value ) = ( $1, $2 );
if ( defined $key && defined $value ) {
$config{$key} = $value; $config{$key} = $value;
logmsg( 3, "$key=$value" ); logmsg( 3, "$key=$value" );
} }
}
close(CFG); close(CFG);
# tidy up entries, just in case # tidy up entries, just in case