line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of Config-Model-Xorg |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2007-2018 by Dominique Dumont. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# The GNU Lesser General Public License, Version 2.1, February 1999 |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
package Config::Model::Backend::Xorg ; |
11
|
|
|
|
|
|
|
$Config::Model::Backend::Xorg::VERSION = '1.114'; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
4154
|
use Mouse ; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
14
|
1
|
|
|
1
|
|
583
|
use Carp ; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
87
|
|
15
|
1
|
|
|
1
|
|
7
|
use Log::Log4perl qw(get_logger :levels); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
extends 'Config::Model::Backend::Any'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
with 'Config::Model::Backend::Xorg::Read'; |
20
|
|
|
|
|
|
|
with 'Config::Model::Backend::Xorg::Write'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $logger = get_logger("Backend::Xorg") ; |
23
|
|
|
|
|
|
|
|
24
|
10
|
|
|
10
|
1
|
764
|
sub annotation { return 0 ;} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub read { |
27
|
10
|
|
|
10
|
1
|
2412950
|
my $self = shift ; |
28
|
10
|
|
|
|
|
105
|
my %args = @_ ; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# args are: |
31
|
|
|
|
|
|
|
# object => $obj, # Config::Model::Node object |
32
|
|
|
|
|
|
|
# root => './my_test', # fake root directory, userd for tests |
33
|
|
|
|
|
|
|
# config_dir => /etc/foo', # absolute path |
34
|
|
|
|
|
|
|
# file => 'foo.conf', # file name |
35
|
|
|
|
|
|
|
# file_path => './my_test/etc/foo/foo.conf' |
36
|
|
|
|
|
|
|
# io_handle => $io # IO::File object |
37
|
|
|
|
|
|
|
# check => yes|no|skip |
38
|
|
|
|
|
|
|
|
39
|
10
|
50
|
|
|
|
57
|
return 0 unless defined $args{io_handle} ; # no file to read |
40
|
10
|
|
50
|
|
|
51
|
my $check = $args{check} || 'yes' ; |
41
|
|
|
|
|
|
|
|
42
|
10
|
|
|
|
|
21
|
my @lines ; |
43
|
|
|
|
|
|
|
|
44
|
10
|
|
|
|
|
24
|
my $idx = 0 ; |
45
|
|
|
|
|
|
|
# store also input line number |
46
|
10
|
|
|
|
|
40
|
foreach my $line ($args{file_path}->lines_utf8) { |
47
|
1158
|
|
|
|
|
4643
|
$line =~ s/#.*$//; |
48
|
1158
|
|
|
|
|
2816
|
$line =~ s/^\s*//; |
49
|
1158
|
|
|
|
|
3244
|
$line =~ s/\s+$//; |
50
|
1158
|
|
|
|
|
3323
|
push @lines, [ "line ".$idx++ ,$line ] |
51
|
|
|
|
|
|
|
} |
52
|
10
|
|
|
|
|
96
|
my @raw_xorg_conf = grep { $_->[1] !~ /^\s*$/ ;} @lines; |
|
1158
|
|
|
|
|
2438
|
|
53
|
10
|
|
|
|
|
312
|
chomp @raw_xorg_conf ; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
#print Dumper(\@raw_xorg_conf); exit ; |
56
|
10
|
|
|
|
|
78
|
my $data = parse_raw_xorg(\@raw_xorg_conf) ; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
#return $data if $test ; |
59
|
|
|
|
|
|
|
#print Dumper($data); exit ; |
60
|
|
|
|
|
|
|
|
61
|
10
|
|
|
|
|
56
|
parse_all($data, $args{object}) ; |
62
|
10
|
|
|
|
|
617
|
return 1; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub write { |
66
|
5
|
|
|
5
|
1
|
5699878
|
my $self = shift ; |
67
|
5
|
|
|
|
|
39
|
my %args = @_ ; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# args are: |
70
|
|
|
|
|
|
|
# object => $obj, # Config::Model::Node object |
71
|
|
|
|
|
|
|
# root => './my_test', # fake root directory, userd for tests |
72
|
|
|
|
|
|
|
# config_dir => /etc/foo', # absolute path |
73
|
|
|
|
|
|
|
# file => 'foo.conf', # file name |
74
|
|
|
|
|
|
|
# file_path => './my_test/etc/foo/foo.conf' |
75
|
|
|
|
|
|
|
# io_handle => $io # IO::File object |
76
|
|
|
|
|
|
|
# check => yes|no|skip |
77
|
|
|
|
|
|
|
|
78
|
5
|
|
|
|
|
41
|
my $a_ref = write_all( $args{object} ) ; |
79
|
5
|
|
|
|
|
26
|
$args{file_path}->spew_utf8( map {"$_\n"} @$a_ref ) ; |
|
594
|
|
|
|
|
1312
|
|
80
|
|
|
|
|
|
|
|
81
|
5
|
|
|
|
|
10478
|
return 1; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__END__ |