diff options
| author | fukachan <fukachan> | 2002-06-24 09:43:23 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2002-06-24 09:43:23 +0000 |
| commit | 4927c490fe46bf2a6cc8de27a29c8e0efd67ecee (patch) | |
| tree | f68e78058bdb624848d7c2ef50e52faa5efd36fa /fml/lib/FML/Config.pm | |
| parent | 0c187034bc7f7f139e4d125e52a3f82de9c2e9d6 (diff) | |
| download | fml8-4927c490fe46bf2a6cc8de27a29c8e0efd67ecee.tar.gz fml8-4927c490fe46bf2a6cc8de27a29c8e0efd67ecee.tar.bz2 fml8-4927c490fe46bf2a6cc8de27a29c8e0efd67ecee.zip | |
more defined() checks and sanity check if could
Diffstat (limited to 'fml/lib/FML/Config.pm')
| -rw-r--r-- | fml/lib/FML/Config.pm | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/fml/lib/FML/Config.pm b/fml/lib/FML/Config.pm index dee69a3a..c075df90 100644 --- a/fml/lib/FML/Config.pm +++ b/fml/lib/FML/Config.pm @@ -3,7 +3,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Config.pm,v 1.59 2002/04/11 05:20:55 fukachan Exp $ +# $FML: Config.pm,v 1.60 2002/06/22 14:25:11 fukachan Exp $ # package FML::Config; @@ -199,6 +199,11 @@ sub set my ($self, $key, $value) = @_; $self->{ $key } = $value; $need_expansion_variables = 1; + + if ($debug > 1) { + my (@c) = caller; + print "XXX $c[1] $c[2] ($key = $value)<br>\n"; + } } @@ -379,20 +384,32 @@ sub _read_file sub _evaluate { my ($config, $key, $mode, $value) = @_; - my @buf = split(/\s+/, $config->{ $key }); + my @buf = (); + + if (defined $config->{ $key }) { + @buf = split(/\s+/, $config->{ $key }); + } if ($mode eq '+') { push(@buf, $value); } elsif ($mode eq '-') { my @newbuf = (); - for (@buf) { - push(@newbuf, $_) if $value ne $_; + BUF: + for my $s (@buf) { + next unless defined $s; + next unless $s; + push(@newbuf, $s) if $value ne $s; } @buf = @newbuf; } - return join(" ", @buf); + if (@buf) { + return join(" ", @buf); + } + else { + return ''; + } } @@ -485,7 +502,9 @@ sub write print $fh $comment->{$k} if defined $comment->{$k}; print $fh "$k = "; - print $fh join("\n\t", split(/\s+/, $config->{$k})); + if (defined $config->{$k}) { + print $fh join("\n\t", split(/\s+/, $config->{$k})); + } print $fh "\n"; print $fh "\n"; } |
