line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Localizer::Scanner::Perl; |
2
|
1
|
|
|
1
|
|
553
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
4
|
1
|
|
|
1
|
|
5
|
use utf8; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
5
|
1
|
|
|
1
|
|
26
|
use 5.010_001; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
43
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use constant NUL => 0; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
62
|
|
8
|
1
|
|
|
1
|
|
4
|
use constant BEG => 1; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
31
|
|
9
|
1
|
|
|
1
|
|
10
|
use constant PAR => 2; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
31
|
|
10
|
1
|
|
|
1
|
|
3
|
use constant HERE => 10; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
11
|
1
|
|
|
1
|
|
3
|
use constant QUO1 => 3; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
12
|
1
|
|
|
1
|
|
3
|
use constant QUO2 => 4; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
13
|
1
|
|
|
1
|
|
4
|
use constant QUO3 => 5; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
14
|
1
|
|
|
1
|
|
4
|
use constant QUO4 => 6; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
15
|
1
|
|
|
1
|
|
5
|
use constant QUO5 => 7; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
16
|
1
|
|
|
1
|
|
4
|
use constant QUO6 => 8; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
17
|
1
|
|
|
1
|
|
5
|
use constant QUO7 => 9; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2151
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
1
|
|
|
1
|
0
|
10
|
my $class = shift; |
21
|
1
|
|
|
|
|
4
|
bless { }, $class; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub scan { |
25
|
1
|
|
|
1
|
1
|
4
|
my($self, $result, $filename, $data) = @_; |
26
|
1
|
|
|
|
|
5
|
$self->_walker($data, $result, $filename); |
27
|
1
|
|
|
|
|
76
|
return $result; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub scan_file { |
31
|
1
|
|
|
1
|
1
|
7
|
my ($self, $result, $filename) = @_; |
32
|
1
|
50
|
|
1
|
|
10
|
open my $fh, '<:encoding(utf-8)', $filename |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
55
|
|
33
|
|
|
|
|
|
|
or die "Cannot open file '$filename' for reading: $!"; |
34
|
1
|
|
|
|
|
14624
|
my $data = do { local $/; <$fh> }; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
40
|
|
35
|
1
|
|
|
|
|
117
|
return $self->scan($result, $filename, $data); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Imported from Locale::Maketext::Extract::Plugin::Perl |
39
|
|
|
|
|
|
|
sub _walker { |
40
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
41
|
1
|
|
|
|
|
2
|
local $_ = shift; |
42
|
1
|
|
|
|
|
4
|
my ($result, $filename) = @_; |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
0
|
|
8
|
local $SIG{__WARN__} = sub { die @_ }; |
|
0
|
|
|
|
|
0
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Perl code: |
47
|
1
|
|
|
|
|
3
|
my ( $state, $line_offset, $str, $str_part, $vars, $quo, $heredoc ) |
48
|
|
|
|
|
|
|
= ( 0, 0 ); |
49
|
1
|
|
|
|
|
89
|
my $orig = 1 + ( () = ( ( my $__ = $_ ) =~ /\n/g ) ); |
50
|
|
|
|
|
|
|
|
51
|
429
|
100
|
|
|
|
1666
|
PARSER: { |
52
|
1
|
|
|
|
|
14
|
$_ = substr( $_, pos($_) ) if ( pos($_) ); |
53
|
429
|
|
|
|
|
8923
|
my $line = $orig - ( () = ( ( my $__ = $_ ) =~ /\n/g ) ); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# various ways to spell the localization function |
56
|
|
|
|
|
|
|
$state == NUL |
57
|
|
|
|
|
|
|
&& m/\b(translate|maketext|gettext|__?|loc(?:ali[sz]e)?|l|x)/gc |
58
|
429
|
100
|
100
|
|
|
3694
|
&& do { $state = BEG; redo }; |
|
57
|
|
|
|
|
57
|
|
|
57
|
|
|
|
|
86
|
|
59
|
372
|
100
|
100
|
|
|
1015
|
$state == BEG && m/^([\s\t\n]*)/gc && redo; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# begin () |
62
|
|
|
|
|
|
|
$state == BEG |
63
|
|
|
|
|
|
|
&& m/^([\S\(])\s*/gc |
64
|
313
|
100
|
66
|
|
|
755
|
&& do { $state = ( ( $1 eq '(' ) ? PAR : NUL ); redo }; |
|
57
|
100
|
|
|
|
130
|
|
|
57
|
|
|
|
|
65
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# concat |
67
|
|
|
|
|
|
|
$state == PAR |
68
|
|
|
|
|
|
|
&& defined($str) |
69
|
|
|
|
|
|
|
&& m/^(\s*\.\s*)/gc |
70
|
256
|
50
|
100
|
|
|
833
|
&& do { $line_offset += ( () = ( ( my $__ = $1 ) =~ /\n/g ) ); redo }; |
|
0
|
|
66
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# str_part |
73
|
256
|
100
|
100
|
|
|
635
|
$state == PAR && defined($str_part) && do { |
74
|
42
|
100
|
100
|
|
|
141
|
if ( ( $quo == QUO1 ) || ( $quo == QUO5 ) ) { |
|
|
100
|
|
|
|
|
|
75
|
18
|
50
|
|
|
|
65
|
$str_part =~ s/\\([\\'])/$1/g |
76
|
|
|
|
|
|
|
if ($str_part); # normalize q strings |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
elsif ( $quo != QUO6 ) { |
79
|
23
|
100
|
|
|
|
80
|
$str_part =~ s/(\\(?:[0x]..|c?.))/"qq($1)"/eeg |
|
12
|
|
|
|
|
742
|
|
80
|
|
|
|
|
|
|
if ($str_part); # normalize qq / qx strings |
81
|
|
|
|
|
|
|
} |
82
|
42
|
|
|
|
|
77
|
$str .= $str_part; |
83
|
42
|
|
|
|
|
41
|
undef $str_part; |
84
|
42
|
|
|
|
|
36
|
undef $quo; |
85
|
42
|
|
|
|
|
47
|
redo; |
86
|
|
|
|
|
|
|
}; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# begin or end of string |
89
|
214
|
100
|
100
|
|
|
553
|
$state == PAR && m/^(\')/gc && do { $state = $quo = QUO1; redo }; |
|
12
|
|
|
|
|
15
|
|
|
12
|
|
|
|
|
15
|
|
90
|
202
|
100
|
100
|
|
|
504
|
$state == QUO1 && m/^([^'\\]+)/gc && do { $str_part .= $1; redo }; |
|
20
|
|
|
|
|
59
|
|
|
20
|
|
|
|
|
22
|
|
91
|
182
|
100
|
100
|
|
|
373
|
$state == QUO1 && m/^((?:\\.)+)/gcs && do { $str_part .= $1; redo }; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
10
|
|
92
|
174
|
100
|
66
|
|
|
326
|
$state == QUO1 && m/^\'/gc && do { $state = PAR; redo }; |
|
12
|
|
|
|
|
13
|
|
|
12
|
|
|
|
|
16
|
|
93
|
|
|
|
|
|
|
|
94
|
162
|
100
|
100
|
|
|
466
|
$state == PAR && m/^\"/gc && do { $state = $quo = QUO2; redo }; |
|
18
|
|
|
|
|
21
|
|
|
18
|
|
|
|
|
21
|
|
95
|
144
|
100
|
100
|
|
|
406
|
$state == QUO2 && m/^([^"\\]+)/gc && do { $str_part .= $1; redo }; |
|
26
|
|
|
|
|
47
|
|
|
26
|
|
|
|
|
34
|
|
96
|
118
|
100
|
100
|
|
|
260
|
$state == QUO2 && m/^((?:\\.)+)/gcs && do { $str_part .= $1; redo }; |
|
10
|
|
|
|
|
14
|
|
|
10
|
|
|
|
|
11
|
|
97
|
108
|
100
|
66
|
|
|
232
|
$state == QUO2 && m/^\"/gc && do { $state = PAR; redo }; |
|
18
|
|
|
|
|
16
|
|
|
18
|
|
|
|
|
20
|
|
98
|
|
|
|
|
|
|
|
99
|
90
|
50
|
66
|
|
|
250
|
$state == PAR && m/^\`/gc && do { $state = $quo = QUO3; redo }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
100
|
90
|
50
|
33
|
|
|
146
|
$state == QUO3 && m/^([^\`]*)/gc && do { $str_part .= $1; redo }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
101
|
90
|
50
|
33
|
|
|
150
|
$state == QUO3 && m/^\`/gc && do { $state = PAR; redo }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
102
|
|
|
|
|
|
|
|
103
|
90
|
100
|
100
|
|
|
237
|
$state == PAR && m/^qq\{/gc && do { $state = $quo = QUO4; redo }; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
2
|
|
104
|
89
|
100
|
100
|
|
|
170
|
$state == QUO4 && m/^([^\}]*)/gc && do { $str_part .= $1; redo }; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
3
|
|
105
|
87
|
100
|
66
|
|
|
153
|
$state == QUO4 && m/^\}/gc && do { $state = PAR; redo }; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
106
|
|
|
|
|
|
|
|
107
|
86
|
100
|
100
|
|
|
246
|
$state == PAR && m/^q\{/gc && do { $state = $quo = QUO5; redo }; |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
8
|
|
108
|
80
|
100
|
100
|
|
|
244
|
$state == QUO5 && m/^([^\}]*)/gc && do { $str_part .= $1; redo }; |
|
12
|
|
|
|
|
22
|
|
|
12
|
|
|
|
|
11
|
|
109
|
68
|
100
|
66
|
|
|
133
|
$state == QUO5 && m/^\}/gc && do { $state = PAR; redo }; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
7
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# find heredoc terminator, then get the |
112
|
|
|
|
|
|
|
#heredoc and go back to current position |
113
|
|
|
|
|
|
|
$state == PAR |
114
|
|
|
|
|
|
|
&& m/^<<\s*\'/gc |
115
|
62
|
100
|
100
|
|
|
221
|
&& do { $state = $quo = QUO6; $heredoc = ''; redo }; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
2
|
|
116
|
61
|
100
|
100
|
|
|
126
|
$state == QUO6 && m/^([^'\\\n]+)/gc && do { $heredoc .= $1; redo }; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
117
|
60
|
50
|
66
|
|
|
101
|
$state == QUO6 && m/^((?:\\.)+)/gc && do { $heredoc .= $1; redo }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
118
|
|
|
|
|
|
|
$state == QUO6 |
119
|
|
|
|
|
|
|
&& m/^\'/gc |
120
|
60
|
100
|
66
|
|
|
107
|
&& do { $state = HERE; $heredoc =~ s/\\\'/\'/g; redo }; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
$state == PAR |
123
|
|
|
|
|
|
|
&& m/^<<\s*\"/gc |
124
|
59
|
100
|
100
|
|
|
205
|
&& do { $state = $quo = QUO7; $heredoc = ''; redo }; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
2
|
|
125
|
57
|
100
|
100
|
|
|
115
|
$state == QUO7 && m/^([^"\\\n]+)/gc && do { $heredoc .= $1; redo }; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
126
|
56
|
50
|
66
|
|
|
109
|
$state == QUO7 && m/^((?:\\.)+)/gc && do { $heredoc .= $1; redo }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
127
|
|
|
|
|
|
|
$state == QUO7 |
128
|
|
|
|
|
|
|
&& m/^\"/gc |
129
|
56
|
100
|
66
|
|
|
100
|
&& do { $state = HERE; $heredoc =~ s/\\\"/\"/g; redo }; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
3
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
$state == PAR |
132
|
|
|
|
|
|
|
&& m/^<<(\w*)/gc |
133
|
54
|
100
|
100
|
|
|
182
|
&& do { $state = HERE; $quo = QUO7; $heredoc = $1; redo }; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
51
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# jump ahead and get the heredoc, then s/// also |
136
|
|
|
|
|
|
|
# resets the pos and we are back at the current pos |
137
|
|
|
|
|
|
|
$state == HERE |
138
|
|
|
|
|
|
|
&& m/^.*\r?\n/gc |
139
|
|
|
|
|
|
|
&& s/\G(.*?\r?\n)$heredoc(\r?\n)//s |
140
|
51
|
50
|
66
|
|
|
239
|
&& do { $state = PAR; $str_part .= $1; $line_offset++; redo }; |
|
6
|
|
66
|
|
|
7
|
|
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
4
|
|
|
6
|
|
|
|
|
12
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
# end () |
143
|
|
|
|
|
|
|
# |
144
|
|
|
|
|
|
|
|
145
|
45
|
100
|
100
|
|
|
213
|
$state == PAR && m/^\s*[\)]/gc && do { |
146
|
43
|
|
|
|
|
43
|
$state = NUL; |
147
|
43
|
100
|
|
|
|
68
|
$vars =~ s/[\n\r]//g if ($vars); |
148
|
|
|
|
|
|
|
|
149
|
43
|
100
|
|
|
|
64
|
if ($str) { |
150
|
41
|
|
|
|
|
127
|
$result->add_entry_position( $str, $filename, $line - $line_offset ) # <= [MODIFIED] remove mystery line modifier |
151
|
|
|
|
|
|
|
} |
152
|
43
|
|
|
|
|
436
|
undef $str; |
153
|
43
|
|
|
|
|
41
|
undef $vars; |
154
|
43
|
|
|
|
|
36
|
undef $heredoc; |
155
|
43
|
|
|
|
|
44
|
$line_offset = 0; |
156
|
43
|
|
|
|
|
47
|
redo; |
157
|
|
|
|
|
|
|
}; |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
# a line of vars |
160
|
2
|
100
|
66
|
|
|
15
|
$state == PAR && m/^([^\)]*)/gc && do { $vars .= "$1\n"; redo }; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
1
|
|
|
|
|
16
|
return $result; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
1; |
167
|
|
|
|
|
|
|
__END__ |