mirror of
https://codeberg.org/scip/Config-General.git
synced 2025-12-17 04:31:00 +01:00
2.11 - heavy change in the variable interpolation code.
Peter Sergeant <pete@clueball.com> reported this mis-behavior. The problem was that the whole hash was feeded to ::Interpolated.pm, but as we all know, perl hashes doesn't preserve the order. So, in our case the module sometimes was unable to resolve variablenames, because they were stored in a different location as it occured in the config. The change is, that Config::General now calls ::Interpolate.pm (new sub: _interpolate()) itself directly on a per-key/value pair basis. The internal varstack is now stored on $this globally. So, now a variable will be known when it occurs. period :- git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@37 be1acefe-a474-0410-9a34-9b3221f2030f
This commit is contained in:
34
General.pm
34
General.pm
@@ -17,7 +17,7 @@ use strict;
|
||||
use Carp;
|
||||
use Exporter;
|
||||
|
||||
$Config::General::VERSION = "2.10";
|
||||
$Config::General::VERSION = "2.11";
|
||||
|
||||
use vars qw(@ISA @EXPORT);
|
||||
@ISA = qw(Exporter);
|
||||
@@ -179,6 +179,22 @@ sub new {
|
||||
$self->{StoreDelimiter} = " " if(!$self->{StoreDelimiter});
|
||||
}
|
||||
|
||||
if ($self->{InterPolateVars}) {
|
||||
#
|
||||
# we are blessing here again, to get into the ::InterPolated namespace
|
||||
# for inheriting the methods available overthere, which we doesn't have.
|
||||
#
|
||||
bless($self, "Config::General::Interpolated");
|
||||
eval {
|
||||
require Config::General::Interpolated;
|
||||
};
|
||||
if ($@) {
|
||||
croak $@;
|
||||
}
|
||||
# pre-compile the variable regexp
|
||||
$self->{regex} = $self->_set_regex();
|
||||
}
|
||||
|
||||
# process as usual
|
||||
if (!$self->{parsed}) {
|
||||
if (exists $self->{StringContent}) {
|
||||
@@ -222,16 +238,6 @@ sub new {
|
||||
#
|
||||
# Submodule handling. Parsing is already done at this point.
|
||||
#
|
||||
if ($self->{InterPolateVars}) {
|
||||
eval {
|
||||
require Config::General::Interpolated;
|
||||
};
|
||||
if ($@) {
|
||||
croak $@;
|
||||
}
|
||||
$self->{regex} = Config::General::Interpolated::_set_regex();
|
||||
$self->{config} = Config::General::Interpolated::_vars($self, $self->{config}, {});
|
||||
}
|
||||
if ($self->{ExtendedAccess}) {
|
||||
#
|
||||
# we are blessing here again, to get into the ::Extended namespace
|
||||
@@ -590,6 +596,10 @@ sub _parse_value {
|
||||
# avoid "Use of uninitialized value"
|
||||
$value = '' unless defined $value;
|
||||
|
||||
if ($this->{InterPolateVars}) {
|
||||
$value = $this->_interpolate($option, $value);
|
||||
}
|
||||
|
||||
# make true/false values to 1 or 0 (-AutoTrue)
|
||||
if ($this->{AutoTrue}) {
|
||||
if ($value =~ /$this->{AutoTrueFlags}->{true}/io) {
|
||||
@@ -1714,7 +1724,7 @@ Thomas Linden <tom@daemon.de>
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
2.10
|
||||
2.11
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
Reference in New Issue
Block a user