line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::Maker::Config; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
59
|
use utf8; |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
86
|
|
4
|
9
|
|
|
9
|
|
273
|
use warnings; |
|
9
|
|
|
|
|
23
|
|
|
9
|
|
|
|
|
293
|
|
5
|
9
|
|
|
9
|
|
54
|
use strict; |
|
9
|
|
|
|
|
25
|
|
|
9
|
|
|
|
|
294
|
|
6
|
|
|
|
|
|
|
|
7
|
9
|
|
|
9
|
|
52
|
use Carp; |
|
9
|
|
|
|
|
26
|
|
|
9
|
|
|
|
|
848
|
|
8
|
9
|
|
|
9
|
|
52
|
use Parse::RecDescent; |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
222
|
|
9
|
|
|
|
|
|
|
|
10
|
9
|
|
|
9
|
|
359
|
use Config::Maker; |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
915
|
|
11
|
9
|
|
|
9
|
|
54
|
use Config::Maker::Encode; |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
1413
|
|
12
|
9
|
|
|
9
|
|
5753
|
use Config::Maker::Option; |
|
9
|
|
|
|
|
38
|
|
|
9
|
|
|
|
|
320
|
|
13
|
9
|
|
|
9
|
|
7475
|
use Config::Maker::Option::Meta; |
|
9
|
|
|
|
|
29
|
|
|
9
|
|
|
|
|
276
|
|
14
|
9
|
|
|
9
|
|
61
|
use Config::Maker::Type; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
5622
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $parser = $Config::Maker::parser; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Now to the parser itself... |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
21
|
94
|
|
|
94
|
0
|
25761
|
my ($class, $root) = @_; |
22
|
|
|
|
|
|
|
|
23
|
94
|
50
|
|
|
|
953
|
unless(UNIVERSAL::isa($root, 'Config::Maker::Option')) { |
24
|
|
|
|
|
|
|
# We didn't get a Config::Maker::Option, so let's assume we've got |
25
|
|
|
|
|
|
|
# a filename |
26
|
94
|
|
|
|
|
870
|
my $type = Config::Maker::Type->root; |
27
|
|
|
|
|
|
|
|
28
|
94
|
|
|
|
|
523
|
my $children = $class->read($root, $type); |
29
|
|
|
|
|
|
|
|
30
|
94
|
|
|
|
|
827
|
$root = $type->instantiate({ -children => $children }); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
bless { |
34
|
94
|
|
|
|
|
1233
|
root => $root, |
35
|
|
|
|
|
|
|
meta => Config::Maker::Option::Meta->new( |
36
|
|
|
|
|
|
|
-type => Config::Maker::Type->meta() |
37
|
|
|
|
|
|
|
), |
38
|
|
|
|
|
|
|
}, $class; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub read { |
42
|
98
|
|
|
98
|
0
|
309
|
my ($class, $file, $type) = @_; |
43
|
98
|
|
|
|
|
193
|
my ($fh, $text); |
44
|
98
|
|
|
|
|
255
|
my $enc = 'system'; |
45
|
|
|
|
|
|
|
|
46
|
98
|
|
|
|
|
524
|
$file = Config::Maker::locate($file); |
47
|
|
|
|
|
|
|
|
48
|
98
|
50
|
|
|
|
5923
|
open($fh, '<', $file) |
49
|
|
|
|
|
|
|
or croak "Failed to open $file: $!"; |
50
|
|
|
|
|
|
|
{ |
51
|
98
|
|
|
|
|
206
|
local $/; |
|
98
|
|
|
|
|
1193
|
|
52
|
98
|
|
|
|
|
3686
|
$text = <$fh>; |
53
|
|
|
|
|
|
|
} |
54
|
98
|
|
|
|
|
10018
|
close $fh; |
55
|
|
|
|
|
|
|
|
56
|
98
|
100
|
66
|
|
|
3505
|
if((substr($text, 0, 250) =~ /^\s*#.*$Config::Maker::fenc([[:alnum:]_-]+)/m) || |
57
|
|
|
|
|
|
|
(substr($text, -250) =~ /^\s*#.*$Config::Maker::fenc([[:alnum:]_-]+)/m)) { |
58
|
2
|
|
|
|
|
7
|
$enc = $1; |
59
|
|
|
|
|
|
|
} |
60
|
98
|
|
|
|
|
1250
|
$text = decode($enc, $text); |
61
|
|
|
|
|
|
|
|
62
|
98
|
|
|
|
|
8167
|
LOG("Loading configuration from $file using encoding $enc"); |
63
|
98
|
|
|
|
|
1308
|
my $options = $parser->configuration($text, undef, $type); |
64
|
98
|
50
|
|
|
|
2460
|
croak "Configuration file $file contained errors" |
65
|
|
|
|
|
|
|
unless defined $options; |
66
|
|
|
|
|
|
|
|
67
|
98
|
|
|
|
|
959
|
return $options; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub meta { |
71
|
0
|
|
|
0
|
0
|
0
|
my ($self, $name) = @_; |
72
|
0
|
|
|
|
|
0
|
$self->{meta}->get($name); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub set_meta { |
76
|
135
|
|
|
135
|
0
|
371
|
my ($self, $name, $value) = @_; |
77
|
135
|
|
|
|
|
647
|
$self->{meta}->set_child($name, $value); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |