| 1 | package Locale::VersionedMessages; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # Copyright (c) 2010-2015 Sullivan Beck. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | require 5.008; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | our $VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | $VERSION='0.96'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 4 | my($class) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 4 | my $self = { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 'err' => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 'set' => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 'mess' => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 'search' => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 4 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 4 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | sub version { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
version: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | my($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | return $VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 46 | ▶ | sub err { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
err: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 46 | my($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 46 | return $$self{'err'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 4 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 6 | ▶ | sub set { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set: called CC=5 SCAR=16.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 6 | my($self,@set) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 6 | $$self{'err'} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 6 | ▶ | if (! @set) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | return sort keys %{ $$self{'set'} }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 6 | foreach my $set (@set) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 6 | ▶ | if ($set !~ /^[a-zA-Z0-9_]+$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | $$self{'err'} = "Set must be alphanumeric/underscore: $set"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 6 | my $m = "Locale::VersionedMessages::Sets::$set"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 6 | eval "require $m"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 6 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | chomp($@); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 1 | $$self{'err'} = "Unable to load set: $set: $@"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 5 | my $def_locale = ${ "${m}::DefaultLocale" }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 5 | my @all_locale = @{ "${m}::AllLocale" }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 5 | my %messages = %{ "${m}::Messages" }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | $$self{'set'}{$set} = { 'def_loc' => $def_locale, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 5 | 'all_loc' => { map {$_,1} @all_locale }, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 'messages' => \%messages, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 'search' => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 5 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 4 | ▶ | use strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 1 | ▶ | sub query_set_default { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query_set_default: called CC=2 SCAR=7.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | my($self,$set) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | $$self{'err'} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | ▶ | if (! exists $$self{'set'}{$set}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | $$self{'err'} = "Set not loaded: $set"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | return $$self{'set'}{$set}{'def_loc'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | ▶ | sub query_set_locales { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query_set_locales: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | my($self,$set) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 1 | $$self{'err'} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 1 | ▶ | if (! exists $$self{'set'}{$set}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | $$self{'err'} = "Set not loaded: $set"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | return sort keys %{ $$self{'set'}{$set}{'all_loc'} }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 1 | ▶ | sub query_set_msgid { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query_set_msgid: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | my($self,$set) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 1 | $$self{'err'} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 1 | ▶ | if (! exists $$self{'set'}{$set}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $$self{'err'} = "Set not loaded: $set"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | return sort keys %{ $$self{'set'}{$set}{'messages'} }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 6 | ▶ | sub search { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 6 | my($self,@locale) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 6 | $$self{'err'} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 6 | my $set; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 6 | ▶ | if (@locale && exists $$self{'set'}{$locale[0]}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@locale and exists $self->{"set"}{$locale[0]}
MC/DC100%2/2
@locale and exists $self->{"set"}{$locale[0]}
@locale
exists $self->{"set"}{$locale[0]}
Truth table100%3/3
A and B
A= @localeB= exists $self->{"set"}{$locale[0]}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 2 | $set = shift(@locale); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 6 | ▶ | if ($set && @locale) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
$set and @locale
MC/DC100%2/2
$set and @locale
$set
@locale
Truth table100%3/3
A and B
A= $setB= @locale
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | $$self{'set'}{$set}{'search'} = [@locale]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } elsif (@locale) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 3 | $$self{'search'} = [@locale]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } elsif ($set) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 1 | $$self{'set'}{$set}{'search'} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 1 | $$self{'search'} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 6 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 6 | ▶ | sub query_search { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query_search: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 6 | my($self,$set) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 6 | $$self{'err'} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 6 | ▶ | if ($set) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 3 | ▶ | if (! exists $$self{'set'}{$set}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $$self{'err'} = "Set not loaded: $set"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 3 | return @{ $$self{'set'}{$set}{'search'} }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 3 | return @{ $$self{'search'} }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 4 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 8 | ▶ | sub _load_lexicon { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_lexicon: called CC=6 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 8 | my($self,$set,$locale) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 8 | ▶ | return if (exists $$self{'mess'}{$set}{$locale}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 5 | ▶ | if ($set !~ /^[a-zA-Z0-9_]+$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | $$self{'err'} = "Set must be alphanumeric/underscore: $set"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 5 | my $m = "Locale::VersionedMessages::Sets::${set}::${locale}"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 5 | eval "require $m"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 5 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | chomp($@); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $$self{'err'} = "Unable to load lexicon: $set [$locale]: $@"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 5 | $$self{'mess'}{$set}{$locale} = { %{ "${m}::Messages" } }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 5 | foreach my $msgid (sort keys %{ $$self{'mess'}{$set}{$locale} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 24 | ▶ | if (! exists $$self{'set'}{$set}{'messages'}{$msgid}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $$self{'err'} = "Undefined message ID in lexicon: $set [$locale $msgid]"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 4 | ▶ | use strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 26 | ▶ | sub message { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
message: called CC=17 SCAR=30.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 26 | my($self,$set,$msgid,@args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 26 | $$self{'err'} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | # Parse arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 26 | my($locale,%vals); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 26 | ▶ | if (@args && @args % 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@args and @args % 2
MC/DC50%1/2
@args and @args % 2
@args
@args % 2
Truth table66%2/3
A and B
A= @argsB= @args % 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 22 | $locale = shift(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 22 | %vals = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 22 | ▶ | if (! exists $$self{'set'}{$set}{'all_loc'}{$locale}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $$self{'err'} = "Set not defined in locale: $set [ $locale ]"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 4 | %vals = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | # Look up the message. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 26 | my @locale; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 26 | ▶ | if ($locale) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 22 | @locale = ($locale); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | ▶ | } elsif (exists $$self{'set'}{$set}{'search'} && | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
exists $self->{"set"}{$set}{"search"} and @{$self->{"set"}{$set}{"search"};}
MC/DC0%0/2
exists $self->{"set"}{$set}{"search"} and @{$self->{"set"}{$set}{"search"};}
exists $self->{"set"}{$set}{"search"}
@{$self->{"set"}{$set}{"search"};}
Truth table33%1/3
A and B
A= exists $self->{"set"}{$set}{"search"}B= @{$self->{"set"}{$set}{"search"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 4 | @{ $$self{'set'}{$set}{'search'} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | @locale = @{ $$self{'set'}{$set}{'search'} }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | ▶ | } elsif (exists $$self{'search'} && | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
exists $self->{"search"} and @{$self->{"search"};}
MC/DC50%1/2
exists $self->{"search"} and @{$self->{"search"};}
exists $self->{"search"}
@{$self->{"search"};}
Truth table66%2/3
A and B
A= exists $self->{"search"}B= @{$self->{"search"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 4 | @{ $$self{'search'} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 3 | @locale = (@{ $$self{'search'} }, $$self{'set'}{$set}{'def_loc'}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | @locale = ($$self{'set'}{$set}{'def_loc'}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 26 | my $message; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 26 | foreach my $l (@locale) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 27 | ▶ | next if (! exists $$self{'set'}{$set}{'all_loc'}{$l}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 27 | ▶ | if (! exists $$self{'mess'}{$set}{$l}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 4 | $self->_load_lexicon($set,$l); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 4 | ▶ | if ($$self{'err'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | return (''); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 27 | ▶ | if (exists $$self{'mess'}{$set}{$l}{$msgid}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 24 | $locale = $l; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 24 | $message = $$self{'mess'}{$set}{$l}{$msgid}{'text'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 24 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 26 | ▶ | if (! $message) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 2 | $$self{'err'} = "Message not found in specified lexicons: $msgid"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 24 | $message = $self->_fix_message($set,$msgid,$message,$locale,%vals); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 24 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 3 | return ($message,$locale); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 21 | return $message; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 3 | ▶ | sub query_msg_locales { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query_msg_locales: called CC=6 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 3 | my($self,$set,$msgid) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 3 | $$self{'err'} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 3 | ▶ | if (! exists $$self{'set'}{$set}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | $$self{'err'} = "Set not loaded: $set"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 3 | ▶ | if (! exists $$self{'set'}{$set}{'messages'}{$msgid}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 1 | $$self{'err'} = "Message ID not defined in set: $set [$msgid]"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 1 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 2 | my %all_loc = %{ $$self{'set'}{$set}{'all_loc'} }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 2 | my $def_loc = $$self{'set'}{$set}{'def_loc'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 2 | delete $all_loc{$def_loc}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 2 | my @locale = ($def_loc); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 2 | foreach my $locale (sort keys %all_loc) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 4 | $self->_load_lexicon($set,$locale); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 4 | ▶ | return () if ($$self{'err'}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 4 | ▶ | if (exists $$self{'mess'}{$set}{$locale}{$msgid}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 3 | push(@locale,$locale); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 2 | return @locale; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 6 | ▶ | sub query_msg_vers { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query_msg_vers: called CC=6 SCAR=20.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 6 | my($self,$set,$msgid,$locale) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 6 | $$self{'err'} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 6 | ▶ | if (! exists $$self{'set'}{$set}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | $$self{'err'} = "Set not loaded: $set"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 6 | ▶ | if (! exists $$self{'set'}{$set}{'messages'}{$msgid}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $$self{'err'} = "Message ID not defined in set: $set [$msgid]"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 6 | ▶ | $locale = $$self{'set'}{$set}{'def_loc'} if (! $locale); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 6 | ▶ | if (! exists $$self{'set'}{$set}{'all_loc'}{$locale}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $$self{'err'} = "Lexicon not available for set: $set [$locale]"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 6 | ▶ | if (exists $$self{'mess'}{$set}{$locale}{$msgid}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 5 | return $$self{'mess'}{$set}{$locale}{$msgid}{'vers'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | # MESSAGE SUBSTITUTIONS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | # This takes a message and performs substitutions for each of | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | # the different substitution values. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 24 | ▶ | sub _fix_message { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fix_message: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 24 | my($self,$set,$msgid,$message,$locale,%vals) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | # No substitutions. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 24 | my @vals; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 24 | ▶ | if (exists $$self{'set'}{$set}{'messages'}{$msgid}{'vals'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 21 | @vals = @{ $$self{'set'}{$set}{'messages'}{$msgid}{'vals'} }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 24 | ▶ | if (! @vals) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 4 | ▶ | if (%vals) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 1 | $$self{'err'} = "Message does not contain substitutions, but " . | |||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | "values were supplied: $msgid"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 1 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 3 | return $message; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | # Check each substitution. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 20 | foreach my $val (sort @vals) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 20 | my $done; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 20 | ▶ | if (! exists $vals{$val}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 1 | $$self{'err'} = "A required substitution value was not passed in: " . | |||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | "$msgid [$val]"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 1 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | ($message,$done) = $self->_substitute($set,$msgid,$locale, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 19 | $message,$val,$vals{$val}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 19 | ▶ | return '' if ($$self{'err'}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 13 | ▶ | if (! $done) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 1 | $$self{'err'} = "The message in a lexicon does not contain a required " . | |||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | "substitution: $msgid [$locale $val]"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 1 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 12 | delete $vals{$val}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 12 | foreach my $val (sort keys %vals) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 1 | $$self{'err'} = "An invalid value was passed in: $msgid [$val]"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 1 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 11 | return $message; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | # This does the acutal substitution for a single substitution value. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | # If the substitution is found, $done = 1 will be returned. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 19 | ▶ | sub _substitute { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_substitute: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 19 | my($self,$set,$msgid,$locale,$message,$var,$val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 19 | my $done = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | # Simple substitutions: [foo] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 19 | ▶ | if ($message =~ s/\[\s*$var\s*\]/$val/sg) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 4 | $done = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | # Formatted substitutions: [ foo : FORMAT ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 19 | my $fmt_re = qr/\s*:\s*(%.*?)/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 19 | ▶ | while ($message =~ s/\[\s*$var$fmt_re\s*\]/__L_M_TMP__/s) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 3 | my $fmt = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 4 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 3 | $val = sprintf($fmt,$val); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 3 | ▶ | if ($val eq $fmt) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 2 | $$self{'err'} = "Invalid sprintf format: $msgid [$locale $var]"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 1 | $message =~ s/__L_M_TMP__/$val/s; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 1 | $done = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | # Quant substitutions: [ foo : quant [ : FORMAT ] ... ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 17 | my ($msg,$d) = $self->_quant($set,$msgid,$locale,$message,$var,$val); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 17 | ▶ | return if ($$self{'err'}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 13 | $message = $msg; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 13 | ▶ | $done = $d if ($d); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 13 | return ($message,$done); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | # This tests a string for any quant substitutions and returns the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | # string. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 17 | ▶ | sub _quant { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_quant: called CC=13 SCAR=25.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 17 | my($self,$set,$msgid,$locale,$mess,$var,$val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 17 | my $val_orig = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 17 | my $fmt_re = qr/\s*:\s*(%.*?)/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 17 | my $brack_re = qr/\s+\[([^]]*?)\]/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 17 | my $sq_re = qr/\s+'([^']*?)'/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 17 | my $dq_re = qr/\s+"([^"]*?)"/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 17 | my $ws_re = qr/\s+(\S*)/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 17 | my $tok_re = qr/(?:$brack_re|$sq_re|$dq_re|$ws_re)/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 17 | my $tmp = '__L_M_TMP__'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 17 | my $done = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | SUBST: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 17 | ▶ | while ($mess =~ s/\[\s*$var\s*:\s*quant\s*(?:$fmt_re)?($tok_re+)\s*\]/$tmp/s) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 11 | my $fmt = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 11 | my $tokens= $2; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 11 | ▶ | if ($fmt) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 4 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | $val = sprintf($fmt,$val); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | if ($val eq $fmt) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | $$self{'err'} = "Invalid sprintf format: $msgid [$locale $var]"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 11 | my @tok; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 11 | ▶ | while ($tokens =~ s/^$tok_re//) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 38 | ▶ | push(@tok, $1 || $2 || $3 || $4); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition88%8/9
$1 || $2 || $3 || $4
$1 or $2 or $3
$1 or $2
MC/DC0%0/4
$1 || $2 || $3 || $4
$1
$2
$3
$4
Truth table80%4/5
A or B or C || D
A= $1B= $2C= $3D= $4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 11 | ▶ | if (@tok % 2 == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 1 | $$self{'err'} = "Default string required in quant substitution: " . | |||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | "$msgid [$locale $var]"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | # @tok is (TEST, STRING, TEST, STRING, ..., DEFAULT_STRING) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 10 | ▶ | while (@tok) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 15 | my $ele = shift(@tok); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | # DEFAULT_STRING | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 15 | ▶ | if (! @tok) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 3 | $ele =~ s/_$var/$val/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 3 | $mess =~ s/$tmp/$ele/s; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 3 | $done = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 3 | next SUBST; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | # TEST, STRING | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 12 | my $flag = $self->_test($set,$msgid,$locale,$var,$val_orig,$ele); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 12 | ▶ | return if ($$self{'err'}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 9 | $ele = shift(@tok); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 9 | ▶ | if ($flag) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 4 | $ele =~ s/_$var/$val/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 4 | $mess =~ s/$tmp/$ele/s; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 4 | $done = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 4 | next SUBST; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 13 | return($mess,$done); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | # This parses a condition string and returns 1 if the condition is true for | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | # this value. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 12 | ▶ | sub _test { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_test: called CC=28 SCAR=39.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 12 | my($self,$set,$msgid,$locale,$var,$n,$test) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | # $n must be an unsigned integer | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 12 | ▶ | if ($n !~ /^\d+$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 1 | $$self{'err'} = "Quantity test requires an unsigned integer: " . | |||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | "$msgid [$locale $var]"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | # Currently, test can only have: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | # whitespace | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | # _VAR | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | # ( ) && || < <= == != >= > | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | # DIGITS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | # in them. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 11 | my $tmp = $test; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 11 | $tmp =~ s/(?:\s|\d|_$var|[()&|<=!>])//g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 11 | ▶ | if ($tmp) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 1 | $$self{'err'} = "Quantity test contains invalid characters: " . | |||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | "$msgid [$locale $var]"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | # Parse the tests. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | # 1) _VAR => $n | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 10 | $test =~ s/\s*_$var\s*/ $n /g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | # 2) DIGITS % DIGITS => DIGITS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 10 | ▶ | while ($test =~ s/\s*(\d+)\s*%\s*(\d+)\s*/__L_M_TMP__/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | my $m = $1 % $2; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | $test =~ s/__L_M_TMP__/ $m /; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | # 3) DIGITS OP DIGITS => 0 or 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 10 | ▶ | while ($test =~ s/\s*(\d+)\s*(==|>=|<=|!=|>|<)\s*(\d+)\s*/__L_M_TMP__/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 11 | my($m,$op,$n) = ($1,$2,$3); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 11 | my $x; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 11 | ▶ | if ($op eq '==') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 9 | ▶ | $x = ($m==$n ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } elsif ($op eq '!=') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | ▶ | $x = ($m!=$n ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | } elsif ($op eq '>=') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | ▶ | $x = ($m>=$n ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } elsif ($op eq '<=') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 1 | ▶ | $x = ($m<=$n ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | } elsif ($op eq '>') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 1 | ▶ | $x = ($m>$n ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | } elsif ($op eq '<') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | $x = ($m<$n ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 11 | $test =~ s/__L_M_TMP__/$x/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | # Repeat until done: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | # 4) (DIGITS) => DIGITS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | # 5) DIGITS BOP DIGITS => 0 or 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 10 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 11 | my $done = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 11 | ▶ | if ($test =~ s/\s*\(\s*(\d+)\s*\)\s*/$1/g) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 1 | $done = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 11 | ▶ | while ($test =~ s/\s*(\d+)\s*(\|\||&&)\s*(\d+)\s*/__L_M_TMP__/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 1 | my($m,$op,$n) = ($1,$2,$3); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 1 | my $x; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 1 | ▶ | if ($op eq '&&') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 1 | ▶ | $x = ($m && $n ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$m and $n
MC/DC0%0/2
$m and $n
$m
$n
Truth table33%1/3
A and B
A= $mB= $n
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | } elsif ($op eq '||') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | ▶ | $x = ($m || $n ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$m or $n
MC/DC0%0/2
$m or $n
$m
$n
Truth table0%0/3
A or B
A= $mB= $n
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 1 | $test =~ s/__L_M_TMP__/$x/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 1 | $done = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 11 | ▶ | last if ($done); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | # Final check: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | # 6) DIGITS => 0 or 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 10 | ▶ | if ($test =~ /^\s*(\d+)\s*$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 9 | ▶ | return ($1 ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 1 | $$self{'err'} = "Quantity test malformed: $msgid [$locale $var]"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | # Local Variables: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | # mode: cperl | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | # indent-tabs-mode: nil | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | # cperl-indent-level: 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | # cperl-continued-statement-offset: 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | # cperl-continued-brace-offset: 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | # cperl-brace-offset: 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | # cperl-brace-imaginary-offset: 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | # cperl-label-offset: 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | # End: | ||||||||||||||||||||||||||||||||||||||||||||||||||