| 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
| |||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | $dialog = 1 if ($norm_line =~ m/^\w+ (DIALOG|DIALOGEX) /); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | $stringtable = 1 if ($norm_line eq 'STRINGTABLE'); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | $blocklevel++ if ($norm_line eq 'BEGIN'); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | if ($norm_line eq 'END') { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $blocklevel--; | |||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | if ($blocklevel == 0) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | print "[m=$menu,d=$dialog,s=$stringtable,b=$blocklevel]\n" if $self->{parent}->{debug}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | print "[$norm_line]\n" if $self->{parent}->{debug}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||
| 56 | # DIALOG header contents | ||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | if ($dialog && !$blocklevel) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
$dialog and not $blocklevel
MC/DC0%0/2
$dialog and not $blocklevel
$dialog
not $blocklevel
Truth table0%0/3
A and not(B)
A= $dialogB= not $blocklevel
| |||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | if ($line =~ m/^[\t ]*(CAPTION)[\t ]+"((.*?("")*)*?)"/) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 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
$menu or $dialog
MC/DC0%0/3
$menu || $dialog and $blocklevel
$menu
$dialog
$blocklevel
Truth table0%0/5
A or B and C
A= $menuB= $dialogC= $blocklevel
| |||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if ($line =~ m/^[\t ]*(\w+)[\t ]+"((.*?("")*)*?)"(,[\t ]*(\w+)){0,1}/) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | $hint = $6 ? "$1 $6" : $1; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 68 | 0 | $orig_str = $2; | |||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||
| 71 | # STRINGTABLE BEGIN...END block contents | ||||||||||||||||||||||||||||||||||||||
| 72 | ▶ | } elsif ($stringtable && $blocklevel) { | |||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$stringtable and $blocklevel
MC/DC0%0/2
$stringtable and $blocklevel
$stringtable
$blocklevel
Truth table0%0/3
A and B
A= $stringtableB= $blocklevel
| |||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | if ($line =~ m/^[\t ]*(\w+)[\t ]+"((.*?("")*)*?)"/) { # test for one-line string definitions | ||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||
| 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 ]*"((.*?("")*)*?)"/
MC/DC0%0/2
$idstr and $line =~ /^[\t ]*"((.*?("")*)*?)"/
$idstr
$line =~ /^[\t ]*"((.*?("")*)*?)"/
Truth table0%0/3
A and B
A= $idstrB= $line =~ /^[\t ]*"((.*?("")*)*?)"/
| |||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||||||||||||