- fixed rt.cpan.org#31529 variable inheritance failed
	  with multiple named blocks.

	- fixed rt.cpan.org#33447, regex to catch variable
	  names were too strict, now - . + or : are allowed too.

	- fixed rt.cpan.org#33385 and #32978 - using arrayrefs
	  as param to -String didn't work anymore (sic)

	- fixed rt.cpan.org#33216 - variable stack were not properly
	  re-constructed for pre-existing variables if 
	  -MergeDuplicateOptions is turned on.


git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@64 be1acefe-a474-0410-9a34-9b3221f2030f
This commit is contained in:
Thomas von Dein
2009-10-10 16:43:18 +00:00
parent f85e18462c
commit 61397677d3
5 changed files with 54 additions and 13 deletions

View File

@@ -1,3 +1,18 @@
2.38
- fixed rt.cpan.org#31529 variable inheritance failed
with multiple named blocks.
- fixed rt.cpan.org#33447, regex to catch variable
names were too strict, now - . + or : are allowed too.
- fixed rt.cpan.org#33385 and #32978 - using arrayrefs
as param to -String didn't work anymore (sic)
- fixed rt.cpan.org#33216 - variable stack were not properly
re-constructed for pre-existing variables if
-MergeDuplicateOptions is turned on.
2.37 2.37
- "fixed" rt.cpan.org#30199 - check for invalid and - "fixed" rt.cpan.org#30199 - check for invalid and
unsupported structures, especially mixing blocks unsupported structures, especially mixing blocks

View File

@@ -5,7 +5,7 @@
# config values from a given file and # config values from a given file and
# return it as hash structure # return it as hash structure
# #
# Copyright (c) 2000-2007 Thomas Linden <tlinden |AT| cpan.org>. # Copyright (c) 2000-2008 Thomas Linden <tlinden |AT| cpan.org>.
# All Rights Reserved. Std. disclaimer applies. # All Rights Reserved. Std. disclaimer applies.
# Artificial License, same as perl itself. Have fun. # Artificial License, same as perl itself. Have fun.
# #
@@ -32,7 +32,7 @@ use Carp::Heavy;
use Carp; use Carp;
use Exporter; use Exporter;
$Config::General::VERSION = 2.37; $Config::General::VERSION = 2.38;
use vars qw(@ISA @EXPORT_OK); use vars qw(@ISA @EXPORT_OK);
use base qw(Exporter); use base qw(Exporter);
@@ -65,6 +65,7 @@ sub new {
false => '^(off|no|false|0)$', false => '^(off|no|false|0)$',
}, },
DefaultConfig => {}, DefaultConfig => {},
String => '',
level => 1, level => 1,
InterPolateVars => 0, InterPolateVars => 0,
InterPolateEnv => 0, InterPolateEnv => 0,
@@ -287,7 +288,8 @@ sub _prepare {
# handle options which contains values we need (strings, hashrefs or the like) # handle options which contains values we need (strings, hashrefs or the like)
if (exists $conf{-String} ) { if (exists $conf{-String} ) {
if (ref(\$conf{-String}) eq 'SCALAR') { #if (ref(\$conf{-String}) eq 'SCALAR') {
if (not ref $conf{-String}) {
if ( $conf{-String}) { if ( $conf{-String}) {
$self->{StringContent} = $conf{-String}; $self->{StringContent} = $conf{-String};
} }
@@ -295,14 +297,15 @@ sub _prepare {
} }
# re-implement arrayref support, removed after 2.22 as _read were # re-implement arrayref support, removed after 2.22 as _read were
# re-organized # re-organized
elsif(ref(\$conf{-String}) eq 'ARRAY') { # fixed bug#33385
$self->{StringContent} = join '\n', @{$conf{-String}}; elsif(ref($conf{-String}) eq 'ARRAY') {
$self->{StringContent} = join "\n", @{$conf{-String}};
} }
else { else {
croak "Config::General: Parameter -String must be a SCALAR!\n"; croak "Config::General: Parameter -String must be a SCALAR or ARRAYREF!\n";
} }
delete $conf{-String};
} }
if (exists $conf{-Tie}) { if (exists $conf{-Tie}) {
if ($conf{-Tie}) { if ($conf{-Tie}) {
$self->{Tie} = delete $conf{-Tie}; $self->{Tie} = delete $conf{-Tie};
@@ -592,6 +595,7 @@ sub _read {
} }
# remove the \ from all characters if BackslashEscape is turned on # remove the \ from all characters if BackslashEscape is turned on
# FIXME (rt.cpan.org#33218
if ($this->{BackslashEscape}) { if ($this->{BackslashEscape}) {
s/\\(.)/$1/g; s/\\(.)/$1/g;
} }
@@ -770,6 +774,12 @@ sub _parse {
if (exists $config->{$option}) { if (exists $config->{$option}) {
if ($this->{MergeDuplicateOptions}) { if ($this->{MergeDuplicateOptions}) {
$config->{$option} = $this->_parse_value($config, $option, $value); $config->{$option} = $this->_parse_value($config, $option, $value);
# bugfix rt.cpan.org#33216
if ($this->{InterPolateVars}) {
# save pair on local stack
$config->{__stack}->{$option} = $config->{$option};
}
} }
else { else {
if (! $this->{AllowMultiOptions} ) { if (! $this->{AllowMultiOptions} ) {
@@ -905,7 +915,16 @@ sub _parse {
else { else {
push @ar, $savevalue; push @ar, $savevalue;
} }
push @ar, $this->_parse( $this->_hashref(), \@newcontent);
# fixes rt#31529
my $tmphash = $this->_hashref();
if ($this->{InterPolateVars}) {
# inherit current __stack to new block
$tmphash->{__stack} = $config->{__stack};
}
push @ar, $this->_parse( $tmphash, \@newcontent);
$config->{$block} = \@ar; $config->{$block} = \@ar;
} }
} }
@@ -2390,7 +2409,7 @@ Thomas Linden <tlinden |AT| cpan.org>
=head1 VERSION =head1 VERSION
2.37 2.38
=cut =cut

View File

@@ -8,7 +8,7 @@
# #
package Config::General::Interpolated; package Config::General::Interpolated;
$Config::General::Interpolated::VERSION = "2.09"; $Config::General::Interpolated::VERSION = "2.10";
use strict; use strict;
use Carp; use Carp;
@@ -47,7 +47,7 @@ sub _set_regex {
# but can't begin with a '\' # but can't begin with a '\'
\$ # dollar sign \$ # dollar sign
(\{)? # $2: optional opening curly (\{)? # $2: optional opening curly
([a-zA-Z_]\w*) # $3: capturing variable name ([a-zA-Z0-9_\-\.:\+,]+) # $3: capturing variable name (fix of #33447)
( (
?(2) # $4: if there's the opening curly... ?(2) # $4: if there's the opening curly...
\} # ... match closing curly \} # ... match closing curly

2
README
View File

@@ -104,4 +104,4 @@ AUTHOR
VERSION VERSION
2.34 2.38

View File

@@ -8,7 +8,7 @@
use Data::Dumper; use Data::Dumper;
use Test::More tests => 43; use Test::More tests => 45;
#use Test::More qw(no_plan); #use Test::More qw(no_plan);
### 1 ### 1
@@ -450,3 +450,10 @@ foreach my $pos (40 .. 43) {
}; };
ok($@ =~ /^Config::General/, "$pos: Structural error checks"); ok($@ =~ /^Config::General/, "$pos: Structural error checks");
} }
my $conf44;
eval {
$conf44 = new Config::General(-String => [ 'foo bar' ]);
};
ok(! $@, "-String arrayref");
is_deeply({ $conf44->getall }, { foo => 'bar' }, "-String arrayref contents");