mirror of
https://codeberg.org/scip/Config-General.git
synced 2025-12-16 04:01:02 +01:00
2.29
- applied patch by brian@kronos.com via rt.cpan.org #11211. - applied patch by plasmaball@pchome.com.tw via rt.cpan.org #5846 - added new files to MANIFEST file. - added example.cfg to show the config format. git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@55 be1acefe-a474-0410-9a34-9b3221f2030f
This commit is contained in:
17
Changelog
17
Changelog
@@ -1,4 +1,21 @@
|
||||
2.29
|
||||
- applied patch by brian@kronos.com via rt.cpan.org
|
||||
#11211.
|
||||
|
||||
- applied patch by plasmaball@pchome.com.tw via
|
||||
rt.cpan.org #5846
|
||||
|
||||
- added new files to MANIFEST file.
|
||||
|
||||
- added example.cfg to show the config format.
|
||||
|
||||
|
||||
2.28
|
||||
- fixed bug in save(), now blocks containing whitespaces
|
||||
will be saved using quotes, in addition the parser observes
|
||||
the quoting feature, added portion about this to the pod
|
||||
doc. pointed out by Jeff Murphy <jcmurphy@jeffmurphy.org>.
|
||||
|
||||
- added internal list of files opened so far to avoid
|
||||
reading in the same file multiple times.
|
||||
Suggested by Michael Graham.
|
||||
|
||||
@@ -26,7 +26,7 @@ use Carp::Heavy;
|
||||
use Carp;
|
||||
use Exporter;
|
||||
|
||||
$Config::General::VERSION = "2.28";
|
||||
$Config::General::VERSION = "2.29";
|
||||
|
||||
use vars qw(@ISA @EXPORT);
|
||||
@ISA = qw(Exporter);
|
||||
@@ -86,6 +86,7 @@ sub new {
|
||||
|
||||
parsed => 0, # internal state stuff for variable interpolation
|
||||
upperkey => "",
|
||||
upperkeys => [],
|
||||
lastkey => "",
|
||||
prevkey => " ",
|
||||
files => {}, # which files we have read, if any
|
||||
@@ -771,7 +772,7 @@ sub _parse {
|
||||
|
||||
sub _savelast {
|
||||
my($this, $key) = @_;
|
||||
$this->{upperkey} = $this->{lastkey};
|
||||
push(@{$this->{upperkeys}}, $this->{lastkey});
|
||||
$this->{lastkey} = $this->{prevkey};
|
||||
$this->{prevkey} = $key;
|
||||
}
|
||||
@@ -779,7 +780,7 @@ sub _savelast {
|
||||
sub _backlast {
|
||||
my($this, $key) = @_;
|
||||
$this->{prevkey} = $this->{lastkey};
|
||||
$this->{lastkey} = $this->{upperkey};
|
||||
$this->{lastkey} = pop(@{$this->{upperkeys}});
|
||||
}
|
||||
|
||||
sub _parse_value {
|
||||
@@ -2069,7 +2070,7 @@ Thomas Linden <tom@daemon.de>
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
2.28
|
||||
2.29
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#
|
||||
|
||||
package Config::General::Interpolated;
|
||||
$Config::General::Interpolated::VERSION = "2.04";
|
||||
$Config::General::Interpolated::VERSION = "2.05";
|
||||
|
||||
use strict;
|
||||
use Carp;
|
||||
@@ -85,12 +85,13 @@ sub _interpolate {
|
||||
$value =~ s{$this->{regex}}{
|
||||
my $con = $1;
|
||||
my $var = $3;
|
||||
$var = lc($var) if $this->{LowerCaseNames};
|
||||
if (exists $this->{stack}->{ $this->{level} }->{ $prevkey }->{$var}) {
|
||||
$con . $this->{stack}->{ $this->{level} }->{ $prevkey }->{$var};
|
||||
}
|
||||
else {
|
||||
if ($this->{StrictVars}) {
|
||||
croak "Use of uninitialized variable \$" . $var . "\n";
|
||||
croak "Use of uninitialized variable (\$$var) while loading config entry: $key = $value\n";
|
||||
}
|
||||
else {
|
||||
# be cool
|
||||
@@ -114,15 +115,17 @@ sub _interpolate_hash {
|
||||
#
|
||||
my ($this, $config) = @_;
|
||||
|
||||
$this->{level} = 1;
|
||||
$this->{upperkey} = "";
|
||||
$this->{lastkey} = "";
|
||||
$this->{prevkey} = " ";
|
||||
$this->{level} = 1;
|
||||
$this->{upperkey} = "";
|
||||
$this->{upperkeys} = [];
|
||||
$this->{lastkey} = "";
|
||||
$this->{prevkey} = " ";
|
||||
|
||||
$config = $this->_var_hash_stacker($config);
|
||||
|
||||
$this->{level} = 1;
|
||||
$this->{upperkey} = "";
|
||||
$this->{upperkeys} = [];
|
||||
$this->{lastkey} = "";
|
||||
$this->{prevkey} = " ";
|
||||
|
||||
@@ -296,7 +299,7 @@ See L<http://www.perl.com/perl/misc/Artistic.html>
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
2.04
|
||||
2.05
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
7
MANIFEST
7
MANIFEST
@@ -8,6 +8,12 @@ README
|
||||
t/cfg.16
|
||||
t/cfg.17
|
||||
t/cfg.19
|
||||
t/cfg.20.a
|
||||
t/cfg.20.b
|
||||
t/cfg.20.c
|
||||
t/sub1/sub2/sub3/cfg.sub3
|
||||
t/sub1/sub2/cfg.sub2
|
||||
t/sub1/cfg.sub1
|
||||
t/cfg.2
|
||||
t/cfg.3
|
||||
t/cfg.4
|
||||
@@ -17,3 +23,4 @@ t/cfg.7
|
||||
t/cfg.8
|
||||
t/run.t
|
||||
t/test.rc
|
||||
example.cfg
|
||||
|
||||
74
example.cfg
Normal file
74
example.cfg
Normal file
@@ -0,0 +1,74 @@
|
||||
# -*-sh-*- (ignore, this is just for my operation system, emacs,
|
||||
# to function properly)
|
||||
#
|
||||
# This is an example of a config file supported by Config::General.
|
||||
# It shows almost all features of the format and its flexibility.
|
||||
#
|
||||
# To try it, install Config::General as usual and execute the
|
||||
# following perlscript:
|
||||
#
|
||||
# use Config::General;
|
||||
# use Data::Dumper;
|
||||
# my %conf = ParseConfig(-ConfigFile => "example.cfg", -InterPolateVars => 1);
|
||||
# print Dumper(\%C);'
|
||||
#
|
||||
# This will parse the config and print out a stringified version
|
||||
# of the hash it produces, which can be used in your program.
|
||||
#
|
||||
|
||||
|
||||
/*
|
||||
* c-style comment
|
||||
*/
|
||||
|
||||
# variable assignment
|
||||
option1 = blah
|
||||
option2 blubber
|
||||
option3 = "something special" # this is a comment
|
||||
|
||||
option4 = parameters can be written on \
|
||||
multiple lines
|
||||
|
||||
# duplicate options will be made into an array
|
||||
huc = 12
|
||||
huc = 17
|
||||
huc = 133
|
||||
|
||||
# options can be organized in blocks too
|
||||
<sql>
|
||||
user = hans
|
||||
server = mc200
|
||||
db = maxis
|
||||
passwd = D3rf8d
|
||||
|
||||
# nested blocks are no problem
|
||||
<tablestructure>
|
||||
index int(100000)
|
||||
name char(100)
|
||||
prename char(100)
|
||||
status int(10)
|
||||
</tablestructure>
|
||||
</sql>
|
||||
|
||||
# named blocks can also be used
|
||||
<area santa-barbara>
|
||||
# block names containing whitespaces must be quoted
|
||||
<"kyla cole">
|
||||
# blocks maybe empty
|
||||
</"kyla cole">
|
||||
</area>
|
||||
|
||||
# here-docs are fully supported
|
||||
usage <<EOF
|
||||
use with care
|
||||
and don't ask me
|
||||
EOF
|
||||
|
||||
# use of variable interpolation
|
||||
var1 = hoho
|
||||
msg = $var1
|
||||
|
||||
|
||||
|
||||
|
||||
# that's it for today.
|
||||
Reference in New Issue
Block a user