lib/Serge/Engine/Plugin/parse_rc.pm

filter: Statementstmt 11.6% 7 / 60 Branchbran 0.0% 0 / 42 Conditioncond 0.0% 0 / 15 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 50.0% 2 / 4 Podpod 0.0% 0 / 2 totaltotal 6.8% 9 / 132 SCAR 65.2
CC
28
Cov
6%
parse
812.0
name
2.0
BEGIN
1.0
CRAP 679.5
« lib/Serge/Engine/Plugin/parse_php_xhtml.pm ↑ Summary lib/Serge/Command/import.pm »
1 package Serge::Engine::Plugin::parse_rc;
2 1 ▶use parent Serge::Engine::Plugin::Base::Parser;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 sub name {
7 0 ▶ return 'Windows .RC parser plugin';
Subroutine name: not called CC=1 SCAR=6.9
Pod undocumented
8 }
9  
10 sub parse {
11 0 ▶ my ($self, $textref, $callbackref, $lang) = @_;
Subroutine parse: not called CC=28 SCAR=67.0
Pod undocumented
12  
13 0 ▶ die 'callbackref not specified' unless $callbackref;
Branch: 1 branch
BranchTrueFalseTotal
unless $callbackref 0 0 0
14  
15 0 my $translated_text;
16  
17 # Finding translatable strings in file
18  
19 my $menu;
20 0 my $dialog;
21 0 my $stringtable;
22 0 my $blocklevel = 0;
23 0 my $idstr;
24  
25 0 foreach my $line (split(/\n/, $$textref)) {
26 0 my $norm_line = $line;
27  
28 0 my $hint;
29 my $orig_str;
30 0 my $translated_str;
31  
32 # normalize line
33  
34 0 $norm_line =~ s/^[\t ]+//g;
35 0 $norm_line =~ s/[\t ]+$//g;
36 0 $norm_line =~ s/[\t ]+/ /g;
37 0 $norm_line =~ s/^(.*?)\/\/.*$/$1/g; # get rid of comments
38  
39 0 ▶ $menu = 1 if ($norm_line =~ m/ MENU$/);
Branch: 1 branch
BranchTrueFalseTotal
if $norm_line =~ / MENU$/ 0 0 0
40 0 ▶ $dialog = 1 if ($norm_line =~ m/^\w+ (DIALOG|DIALOGEX) /);
Branch: 1 branch
BranchTrueFalseTotal
if $norm_line =~ /^\w+ (DIALOG|DIALOGEX) / 0 0 0
41 0 ▶ $stringtable = 1 if ($norm_line eq 'STRINGTABLE');
Branch: 1 branch
BranchTrueFalseTotal
if $norm_line eq "STRINGTABLE" 0 0 0
42 0 ▶ $blocklevel++ if ($norm_line eq 'BEGIN');
Branch: 1 branch
BranchTrueFalseTotal
if $norm_line eq "BEGIN" 0 0 0
43 0 ▶ if ($norm_line eq 'END') {
Branch: 1 branch
BranchTrueFalseTotal
if ($norm_line eq "END") 0 0 0
44 0 $blocklevel--;
45 0 ▶ if ($blocklevel == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($blocklevel == 0) 0 0 0
46 0 $menu = undef;
47 0 $dialog = undef;
48 0 $stringtable = undef;
49 }
50 }
51  
52 0 ▶ print "$line\n" if $self->{parent}->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"parent"}{"debug"} 0 0 0
53 0 ▶ print "[m=$menu,d=$dialog,s=$stringtable,b=$blocklevel]\n" if $self->{parent}->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"parent"}{"debug"} 0 0 0
54 0 ▶ print "[$norm_line]\n" if $self->{parent}->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"parent"}{"debug"} 0 0 0
55  
56 # DIALOG header contents
57 0 ▶ if ($dialog && !$blocklevel) {
Branch: 3 branches
BranchTrueFalseTotal
if ($dialog and not $blocklevel) { } 0 0 0
elsif ($menu || $dialog and $blocklevel) { } 0 0 0
elsif ($stringtable and $blocklevel) { } 0 0 0
Condition0%0/3
$dialog and not $blocklevel
!ll&&!rl&&r
000
MC/DC0%0/2
$dialog and not $blocklevel
$dialog not $blocklevel
Truth table0%0/3
A and not(B)
A= $dialogB= not $blocklevel
ABresult
0X0
100
111
58  
59 0 ▶ if ($line =~ m/^[\t ]*(CAPTION)[\t ]+"((.*?("")*)*?)"/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^[\t ]*(CAPTION)[\t ]+"((.*?("")*)*?)"/) 0 0 0
60 0 $hint = $1;
61 0 $orig_str = $2;
62 }
63  
64 # MENU and DIALOGEX BEGIN...END block contents
65 ▶ } elsif (($menu || $dialog) && $blocklevel) {
Condition0%0/6
$menu || $dialog and $blocklevel
!ll&&!rl&&r
000
$menu or $dialog
l!l&&r!l&&!r
000
MC/DC0%0/3
$menu || $dialog and $blocklevel
$menu $dialog $blocklevel
Truth table0%0/5
A or B and C
A= $menuB= $dialogC= $blocklevel
ABCresult
00X0
1X00
0100
1X11
0111
66 0 ▶ if ($line =~ m/^[\t ]*(\w+)[\t ]+"((.*?("")*)*?)"(,[\t ]*(\w+)){0,1}/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^[\t ]*(\w+)[\t ]+"((.*?("")*)*?)"(,[\t ]*(\w+)){0,1}/) 0 0 0
67 0 ▶ $hint = $6 ? "$1 $6" : $1;
Branch: 1 branch
BranchTrueFalseTotal
$6 ? : 0 0 0
68 0 $orig_str = $2;
69 }
70  
71 # STRINGTABLE BEGIN...END block contents
72 ▶ } elsif ($stringtable && $blocklevel) {
Condition0%0/3
$stringtable and $blocklevel
!ll&&!rl&&r
000
MC/DC0%0/2
$stringtable and $blocklevel
$stringtable $blocklevel
Truth table0%0/3
A and B
A= $stringtableB= $blocklevel
ABresult
0X0
100
111
73 0 ▶ if ($line =~ m/^[\t ]*(\w+)[\t ]+"((.*?("")*)*?)"/) { # test for one-line string definitions
Branch: 3 branches
BranchTrueFalseTotal
if ($line =~ /^[\t ]*(\w+)[\t ]+"((.*?("")*)*?)"/) { } 0 0 0
elsif ($line =~ m[^[\t ]*(\w+)[\t ]*(//.*)*$]) { } 0 0 0
elsif ($idstr and $line =~ /^[\t ]*"((.*?("")*)*?)"/) { } 0 0 0
74 0 $hint = $1;
75 0 $orig_str = $2;
76 } elsif ($line =~ m/^[\t ]*(\w+)[\t ]*(\/\/.*)*$/) { # test for the first line (id) of the two-line string definitions
77 0 $idstr = $1;
78 ▶ } elsif ($idstr && ($line =~ /^[\t ]*"((.*?("")*)*?)"/)) { # test for the second line (string) of the two-line string definitions
Condition0%0/3
$idstr and $line =~ /^[\t ]*"((.*?("")*)*?)"/
!ll&&!rl&&r
000
MC/DC0%0/2
$idstr and $line =~ /^[\t ]*"((.*?("")*)*?)"/
$idstr $line =~ /^[\t ]*"((.*?("")*)*?)"/
Truth table0%0/3
A and B
A= $idstrB= $line =~ /^[\t ]*"((.*?("")*)*?)"/
ABresult
0X0
100
111
79 0 $hint = $idstr;
80 0 $orig_str = $1;
81 } else {
82 0 $idstr = undef;
83 }
84 }
85  
86 0 ▶ if ($orig_str) {
Branch: 1 branch
BranchTrueFalseTotal
if ($orig_str) 0 0 0
87 0 my $str = $orig_str;
88 0 $str =~ s/""/"/g;
89 0 $translated_str = &$callbackref($str, undef, $hint, undef, $lang, $idstr);
90 }
91  
92 0 ▶ if ($lang) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lang) 0 0 0
93 0 $translated_str =~ s/"/""/g;
94 0 $translated_str =~ s/\n/\\n/g;
95 0 $line =~ s/\Q"$orig_str"\E/"$translated_str"/;
96 0 $translated_text .= $line."\n";
97 }
98 }
99  
100 0 return $translated_text;
101 }
102  
103 1 1;
« lib/Serge/Engine/Plugin/parse_php_xhtml.pm ↑ Summary lib/Serge/Command/import.pm »