blib/lib/Text/VCardFast.pm

filter: Statementstmt 94.9% 186 / 196 Branchbran 76.1% 64 / 84 Conditioncond 63.4% 33 / 52 MC/DCmcdc 33.3% 10 / 30 Subroutinesub 100% 12 / 12 Podpod 25.0% 2 / 8 totaltotal 80.3% 307 / 382 CC 70 SCAR 33.7
CC
70
Cov
85%
hash2vcardlines_pp
41.6
vcardlines2hash_pp
31.6
foldline
6.0
CRAP 29.1
↑ Summary vparse.c »
1 package Text::VCardFast;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 ▶use Encode qw(decode_utf8 encode_utf8);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use MIME::Base64 qw(decode_base64 encode_base64);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 5 require Exporter;
10  
11 5 our @ISA = qw(Exporter);
12  
13 # Items to export into callers namespace by default. Note: do not export
14 # names by default without a very good reason. Use EXPORT_OK instead.
15 # Do not simply export all your public functions/methods/constants.
16  
17 # This allows declaration use Text::VCardFast ':all';
18 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
19 # will save memory.
20 5 our %EXPORT_TAGS = ( 'all' => [ qw(
21 vcard2hash
22 hash2vcard
23 ) ] );
24  
25 5 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
26  
27 5 our @EXPORT = qw(
28 vcard2hash
29 hash2vcard
30 );
31  
32 5 our $VERSION = '0.12';
33  
34 5 require XSLoader;
35 5 XSLoader::load('Text::VCardFast', $VERSION);
36  
37 # public API
38  
39 5 ▶sub vcard2hash { &vcard2hash_c }
Subroutine vcard2hash: called CC=1 SCAR=0.0
Pod documented
40 15 ▶sub hash2vcard { &hash2vcard_pp }
Subroutine hash2vcard: called CC=1 SCAR=0.0
Pod documented
41  
42 # Implementation
43  
44 31 ▶sub vcard2hash_c {
Subroutine vcard2hash_c: called CC=3 SCAR=11.0
Pod undocumented
45 31 my $vcard = shift;
46 31 my %params = @_;
47 31 ▶ if (utf8::is_utf8($vcard)) {
Branch: 1 branch
BranchTrueFalseTotal
if (utf8::is_utf8($vcard)) 24 7 31
48 24 utf8::encode($vcard);
49 24 $params{is_utf8} = 1;
50 }
51 31 ▶ unless ($vcard =~ m/\n\S/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($vcard =~ /\n\S/) 1 30 31
52 # cruddy card with \r as line separator?
53 1 $vcard =~ tr/\r/\n/;
54 }
55 31 my $hash = Text::VCardFast::_vcard2hash($vcard, \%params);
56 25 return $hash;
57 }
58  
59 # pureperl version
60  
61 # VCard parsing and formatting {{{
62  
63 5 my %RFC6868Map = ("n" => "\n", "^" => "^", "'" => "\"");
64 5 my %RFC6868RevMap = reverse %RFC6868Map;
65 5 my %UnescapeMap = ("n" => "\n", "N" => "\n");
66  
67 5 my $Pos = 1;
68 5 my @PropOutputOrder = qw(version fn n nickname lang gender org title role bday anniversary email tel adr url impp);
69 5 my %PropOutputOrder = map { $_ => $Pos++ } @PropOutputOrder;
70 5 my @ParamOutputOrder = qw(type pref);
71 5 my %ParamOutputOrder = map { $_ => $Pos++ } @ParamOutputOrder;
72  
73 12 ▶sub vcard2hash_pp {
Subroutine vcard2hash_pp: called CC=2 SCAR=7.4
Pod undocumented
74 12 my $vcard = shift;
75 12 ▶ unless ($vcard =~ m/\n\S/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($vcard =~ /\n\S/) 0 12 12
76 # cruddy card with \r as line separator?
77 0 $vcard =~ tr/\r/\n/;
78 }
79 12 my %params = @_;
80 12 return vcardlines2hash_pp(\%params, (split /\r?\n/, $vcard));
81 }
82  
83 12 ▶sub vcardlines2hash_pp {
Subroutine vcardlines2hash_pp: called CC=28 SCAR=34.5
Pod undocumented
84 12 my $args = shift;
85 12 local $_;
86  
87 12 my %MultiFieldMap;
88 my %MultiParamMap;
89 12 ▶ if ($args->{multival}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"multival"}) 12 0 12
90 12 %MultiFieldMap = map { $_ => 1 } @{$args->{multival}};
91 }
92 12 ▶ if ($args->{multiparam}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"multiparam"}) 12 0 12
93 12 %MultiParamMap = map { $_ => 1 } @{$args->{multiparam}};
94 }
95  
96 # rfc2425, rfc2426, rfc6350, rfc6868
97  
98 12 my @Path;
99 my $Current;
100 12 ▶ while ($_ = shift @_) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ = shift @_) 169 12 181
101 # Strip EOL
102 190 s/\r?\n$//;
103  
104 # 5.8.1 - Unfold lines if next line starts with space or tab
105 190 ▶ if (@_ && $_[0] =~ s/^[ \t]//) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and $_[0] =~ s/^[ \t]//) 21 169 190
Condition100%3/3
@_ and $_[0] =~ s/^[ \t]//
!ll&&!rl&&r
1215721
MC/DC100%2/2
@_ and $_[0] =~ s/^[ \t]//
@_ $_[0] =~ s/^[ \t]//
Truth table100%3/3
A and B
A= @_B= $_[0] =~ s/^[ \t]//
ABresult
0X0
100
111
106 21 $_ .= shift @_;
107 21 redo;
108 }
109  
110 # Ignore empty lines
111 169 ▶ next if /^\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
if /^\s*$/ 0 169 169
112  
113 169 ▶ if (/^BEGIN:(.*)/i) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^BEGIN:(.*)/i) 13 156 169
114 13 push @Path, $Current;
115 13 $Current = { type => lc $1 };
116 13 push @{ $Path[-1]{objects} }, $Current;
117 13 next;
118 }
119 156 ▶ if (/^END:(.*)/i) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^END:(.*)/i) 13 143 156
120 die "END $1 in $Current->{type}"
121 13 ▶ unless $Current->{type} eq lc $1;
Branch: 1 branch
BranchTrueFalseTotal
unless $Current->{"type"} eq lc $1 0 13 13
122 13 $Current = pop @Path;
123 13 ▶ return $Current if ($args->{only_one} and not @Path);
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"only_one"} and not @Path 0 13 13
Condition33%1/3
$args->{"only_one"} and not @Path
!ll&&!rl&&r
1300
MC/DC0%0/2
$args->{"only_one"} and not @Path
$args->{"only_one"} not @Path
Truth table33%1/3
A and not(B)
A= $args->{"only_one"}B= not @Path
ABresult
0X0
100
111
124 13 next;
125 }
126  
127 # 5.8.2 - Parse '[group "."] name *(";" param) ":" value'
128 # In v2.1, params may not have "=value" part
129 # In v4, "," is allowed in non-quoted param value
130 143 my ($Name) = /^([^;:]*)/gc;
131 143 my @Params = /\G;(?:([\w\-]+)=)?("[^"]*"|[^";:=]*)/gc;
132 143 my ($Value) = /\G:(.*)$/g;
133  
134 # 5.8.2 - Type names and parameter names are case insensitive
135 143 my $LName = lc $Name;
136  
137 143 my %Props;
138  
139 # Remove group from each property name and add as attribute
140 # (in v4, group names are case insensitive as well)
141 143 ▶ if ($LName =~ s/^(.+)\.(.*?)$/$2/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LName =~ s/^(.+)\.(.*?)$/$2/) 18 125 143
142 18 $Props{group} = $1;
143 }
144  
145 143 $Props{name} = $LName;
146  
147 # Parse out parameters
148 143 my %Params;
149 143 ▶ while (@Params) {
Branch: 1 branch
BranchTrueFalseTotal
if (@Params) 100 143 243
150 # Parsed into param => param-value pairs
151 100 my ($PName, $PValue) = splice @Params, 0, 2;
152 100 ▶ if (not defined $PName) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $PName) 7 93 100
153 7 ▶ if ($args->{barekeys}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{'barekeys'}) { } 0 7 7
154 0 $PName = $PValue;
155 0 $PValue = undef;
156 }
157 else {
158 7 $PName = 'type';
159 }
160 }
161  
162 # 5.8.2 - parameter names are case insensitive
163 100 my $LPName = lc $PName;
164  
165 100 my @PValue = (undef);
166 100 ▶ if (defined $PValue) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $PValue) 100 0 100
167 100 $PValue =~ s/^"(.*)"$/$1/;
168 # \n needed for label, but assume any \; is meant to be ; as well
169 100 ▶ $PValue =~ s#\\(.)#$UnescapeMap{$1} // $1#ge;
Condition33%1/3
$UnescapeMap{$1} // $1
l!l&&r!l&&!r
600
MC/DC0%0/2
$UnescapeMap{$1} // $1
$UnescapeMap{$1} $1
Truth table33%1/3
A // B
A= $UnescapeMap{$1}B= $1
ABresult
1X1
011
000
170 # And RFC6868 recoding
171 100 $PValue =~ s/\^([n^'])/$RFC6868Map{$1}/g;
172 100 ▶ if ($MultiParamMap{$LPName}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($MultiParamMap{$LPName}) { } 70 30 100
173 70 @PValue = split /,/, $PValue;
174 }
175 else {
176 30 @PValue = ($PValue);
177 }
178 }
179  
180 100 ▶ if (exists $Params{$LPName}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $Params{$LPName}) { } 15 85 100
181 15 push @{$Params{$LPName}}, @PValue;
182 } else {
183 85 $Params{$LPName} = \@PValue;
184 }
185 }
186 143 ▶ $Props{params} = \%Params if keys %Params;
Branch: 1 branch
BranchTrueFalseTotal
if keys %Params 63 80 143
187  
188 143 my $Encoding = $Params{encoding};
189  
190 143 ▶ if ($MultiFieldMap{$LName}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($MultiFieldMap{$LName}) { } 26 117 143
elsif ($Encoding and lc $Encoding eq 'b') { } 0 117 117
191 # use negative 'limit' to force trailing fields
192 26 $Value = [ split /(?<!\\);/, $Value, -1 ];
193 0 ▶ s#\\(.)#$UnescapeMap{$1} // $1#ge for @$Value;
Condition0%0/3
$UnescapeMap{$1} // $1
l!l&&r!l&&!r
000
MC/DC0%0/2
$UnescapeMap{$1} // $1
$UnescapeMap{$1} $1
Truth table0%0/3
A // B
A= $UnescapeMap{$1}B= $1
ABresult
1X1
011
000
194 26 $Props{values} = $Value;
195 ▶ } elsif ($Encoding && lc $Encoding eq 'b') {
Condition66%2/3
$Encoding and lc $Encoding eq "b"
!ll&&!rl&&r
11610
MC/DC0%0/2
$Encoding and lc $Encoding eq "b"
$Encoding lc $Encoding eq "b"
Truth table66%2/3
A and B
A= $EncodingB= lc $Encoding eq "b"
ABresult
0X0
100
111
196 # Don't bother unescaping base64 value
197  
198 0 $Props{value} = $Value;
199 } else {
200 117 ▶ $Value =~ s#\\(.)#$UnescapeMap{$1} // $1#ge;
Condition66%2/3
$UnescapeMap{$1} // $1
l!l&&r!l&&!r
1470
MC/DC0%0/2
$UnescapeMap{$1} // $1
$UnescapeMap{$1} $1
Truth table66%2/3
A // B
A= $UnescapeMap{$1}B= $1
ABresult
1X1
011
000
201 117 $Props{value} = $Value;
202 }
203  
204 143 push @{$Current->{properties}->{$LName}}, \%Props;
205 }
206  
207 # something did a BEGIN but no END - TODO, unwind this nicely as
208 # it may be more than one level
209 12 ▶ die "BEGIN $Current->{type} without matching END"
Branch: 1 branch
BranchTrueFalseTotal
if @Path 0 12 12
210 if @Path;
211  
212 12 return $Current;
213 }
214  
215 15 ▶sub hash2vcard_pp {
Subroutine hash2vcard_pp: called CC=2 SCAR=7.2
Pod undocumented
216 15 ▶ return join "", map { $_ . ($_[1] // "\n") } hash2vcardlines_pp($_[0]);
Condition50%1/2
$_[1] // "\n"
l!l
0223
MC/DC0%0/1
$_[1] // "\n"
$_[1]
Truth table50%1/2
A
A= $_[1]
Aresult
11
00
217 }
218  
219 31 ▶sub hash2vcardlines_pp {
Subroutine hash2vcardlines_pp: called CC=34 SCAR=37.3
Pod undocumented
220 31 ▶ my $Objects = shift->{objects} // [];
Condition100%2/2
+(shift())->{"objects"} // []
l!l
1912
MC/DC100%1/1
+(shift())->{"objects"} // []
+(shift())->{"objects"}
Truth table100%2/2
A
A= +(shift())->{"objects"}
Aresult
11
00
221  
222 31 my @Lines;
223 31 for my $Card (@$Objects) {
224 # We group properties in the same group together, track if we've
225 # already output a property
226 16 my %DoneProps;
227  
228 16 my $Props = $Card->{properties};
229  
230 # Order the properties
231 my @PropKeys = sort {
232 16 ▶ ($PropOutputOrder{$a} // 1000) <=> ($PropOutputOrder{$b} // 1000)
Condition85%6/7
($PropOutputOrder{$a} // 1000) <=> ($PropOutputOrder{$b} // 1000) || $a cmp $b
l!l&&r!l&&!r
250470
$PropOutputOrder{$a} // 1000
l!l
21681
$PropOutputOrder{$b} // 1000
l!l
21285
MC/DC0%0/2
($PropOutputOrder{$a} // 1000) <=> ($PropOutputOrder{$b} // 1000) || $a cmp $b
$PropOutputOrder{$a} $a cmp $b
MC/DC100%1/1
$PropOutputOrder{$b} // 1000
$PropOutputOrder{$b}
Truth table66%2/3
A || B
A= $PropOutputOrder{$a}B= $a cmp $b
ABresult
1X1
011
000
Truth table100%2/2
A
A= $PropOutputOrder{$b}
Aresult
11
00
233 || $a cmp $b
234 } keys %$Props;
235  
236 # Make sure items in the same group are output together
237 16 ▶ my $Groups = $Card->{groups} || do {
Condition33%1/3
$Card->{'groups'} || do { my %Groups; foreach $_ (map {@$_;} values %$Props) { push @{$Groups{$_->{'group'}};}, $_ if $_->{'group'}; } ; \%Groups }
l!l&&r!l&&!r
0160
MC/DC0%0/2
$Card->{'groups'} || do { my %Groups; foreach $_ (map {@$_;} values %$Props) { push @{$Groups{$_->{'group'}};}, $_ if $_->{'group'}; } ; \%Groups }
$Card->{'groups'} do { my %Groups; foreach $_ (map {@$_;} values %$Props) { push @{$Groups{$_->{'group'}};}, $_ if $_->{'group'}; } ; \%Groups }
Truth table33%1/3
A || B
A= $Card->{'groups'}B= do { my %Groups; foreach $_ (map {@$_;} values %$Props) { push @{$Groups{$_->{'group'}};}, $_ if $_->{'group'}; } ; \%Groups }
ABresult
1X1
011
000
238 16 my %Groups;
239 16 for (map { @$_ } values %$Props) {
240 146 ▶ push @{$Groups{$_->{group}}}, $_ if $_->{group};
Branch: 1 branch
BranchTrueFalseTotal
if $_->{"group"} 18 128 146
241 }
242 16 \%Groups;
243 };
244  
245 # Generate output list
246 16 my @OutputProps;
247 16 for my $PropKey (@PropKeys) {
248 125 my @PropVals = @{$Props->{$PropKey}};
249 125 for my $PropVal (@PropVals) {
250 146 ▶ next if $DoneProps{"$PropVal"}++;
Branch: 1 branch
BranchTrueFalseTotal
if $DoneProps{"$PropVal"}++ 9 137 146
251  
252 137 push @OutputProps, $PropVal;
253  
254 # If it has a group, output all values in that group together
255 137 ▶ if (my $Group = $PropVal->{group}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $Group = $PropVal->{"group"}) 9 128 137
256 9 push @OutputProps, grep { !$DoneProps{"$_"}++ } @{$Groups->{$Group}};
257 }
258 }
259 }
260  
261 16 my $Type = uc $Card->{type};
262 16 push @Lines, ("BEGIN:" . $Type);
263  
264 16 for (@OutputProps) {
265 # Skip deleted or synthetic properties
266 146 ▶ next if $_->{deleted} || $_->{name} eq 'online';
Branch: 1 branch
BranchTrueFalseTotal
if $_->{"deleted"} or $_->{"name"} eq "online" 0 146 146
Condition33%1/3
$_->{"deleted"} or $_->{"name"} eq "online"
l!l&&r!l&&!r
00146
MC/DC0%0/2
$_->{"deleted"} or $_->{"name"} eq "online"
$_->{"deleted"} $_->{"name"} eq "online"
Truth table33%1/3
A or B
A= $_->{"deleted"}B= $_->{"name"} eq "online"
ABresult
1X1
011
000
267  
268 146 my $Binary = $_->{binary};
269 146 ▶ if ($Binary) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Binary) 0 146 146
270 0 ▶ my $Encoding = ($_->{params}->{encoding} //= []);
Condition0%0/2
$_->{"params"}{"encoding"} //= []
l!l
00
MC/DC0%0/1
$_->{"params"}{"encoding"} //= []
$_->{"params"}{"encoding"}
Truth table0%0/2
A
A= $_->{"params"}{"encoding"}
Aresult
11
00
271 0 ▶ push @$Encoding, "b" if !@$Encoding;
Branch: 1 branch
BranchTrueFalseTotal
unless @$Encoding 0 0 0
272 }
273  
274 146 my $LName = $_->{name};
275 146 my $Group = $_->{group};
276  
277 # rfc6350 3.3 - it is RECOMMENDED that property and parameter names be upper-case on output.
278 146 ▶ my $Line = ($Group ? (uc $Group . ".") : "") . uc $LName;
Branch: 1 branch
BranchTrueFalseTotal
$Group ? : 18 128 146
279  
280 146 ▶ while (my ($Param, $ParamVals) = each %{$_->{params} // {}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$_->{"params"} // {};}) 85 146 231
Condition100%2/2
$_->{"params"} // {}
l!l
14883
MC/DC100%1/1
$_->{"params"} // {}
$_->{"params"}
Truth table100%2/2
A
A= $_->{"params"}
Aresult
11
00
281 85 ▶ if (!defined $ParamVals) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ParamVals) 0 85 85
282 0 $Line .= ";" . uc($Param);
283 }
284 85 ▶ for (ref($ParamVals) ? @$ParamVals : $ParamVals) {
Branch: 1 branch
BranchTrueFalseTotal
ref $ParamVals ? : 85 0 85
285 114 ▶ my $PV = $_ // next; # Modify copy
Condition50%1/2
$_ // (next)
l!l
1140
MC/DC0%0/1
$_ // (next)
$_
Truth table50%1/2
A
A= $_
Aresult
11
00
286 114 ▶ $PV =~ s/\n/\\N/g if $Param eq 'label';
Branch: 1 branch
BranchTrueFalseTotal
if $Param eq "label" 4 110 114
287 114 $PV =~ s/([\n^"])/'^' . $RFC6868RevMap{$1}/ge;
288 114 ▶ $PV = '"' . $PV . '"' if $PV =~ /\W/;
Branch: 1 branch
BranchTrueFalseTotal
if $PV =~ /\W/ 6 108 114
289 114 $Line .= ";" . uc($Param) . "=" . $PV;
290 }
291 }
292 146 $Line .= ":";
293  
294 146 ▶ my $Value = $_->{values} || $_->{value};
Condition100%3/3
$_->{'values'} || $_->{'value'}
l!l&&r!l&&!r
261191
MC/DC100%2/2
$_->{'values'} || $_->{'value'}
$_->{'values'} $_->{'value'}
Truth table100%3/3
A || B
A= $_->{'values'}B= $_->{'value'}
ABresult
1X1
011
000
295  
296 146 ▶ if ($_->{binary}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->{'binary'}) { } 0 146 146
297 0 $Value = encode_base64($Value, '');
298  
299 } else {
300 my @Values = map {
301 146 ▶ my $V = ref($_) ? $$_ : $_; # Modify copy
Branch: 1 branch
BranchTrueFalseTotal
ref $_ ? : 0 253 253
302 253 ▶ $V //= '';
Condition50%1/2
$V //= ""
l!l
2530
MC/DC0%0/1
$V //= ""
$V
Truth table50%1/2
A
A= $V
Aresult
11
00
303 # rfc6350 3.4 (v4, assume clarifies many v3 semantics)
304 # - a SEMICOLON in a field of such a "compound" property MUST be
305 # escaped with a BACKSLASH character
306 # - a COMMA character in one of a field's values MUST be escaped
307 # with a BACKSLASH character
308 # - BACKSLASH characters in values MUST be escaped with a BACKSLASH
309 # character.
310 253 $V =~ s/([\,\;\\])/\\$1/g;
311 # - NEWLINE (U+000A) characters in values MUST be encoded
312 # by two characters: a BACKSLASH followed by either an 'n' (U+006E)
313 # or an 'N' (U+004E).
314 253 $V =~ s/\n/\\n/g;
315 253 ▶ $V;
Branch: 1 branch
BranchTrueFalseTotal
ref $Value ? : 26 120 146
316 } ref $Value ? @$Value : $Value;
317  
318 146 $Value = join ";", @Values;
319  
320 # Stripped v4 proto prefix, add it back
321 146 ▶ if (my $ProtoStrip = $_->{proto_strip}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ProtoStrip = $_->{"proto_strip"}) 0 146 146
322 0 $Value = $ProtoStrip . $Value;
323 }
324  
325 # If it's a perl unicode string, make it utf-8 bytes
326 #if (utf8::is_utf8($Value)) {
327 #$Value = encode_utf8($Value);
328 #}
329 }
330  
331 146 $Line .= $Value;
332  
333 146 push @Lines, foldline($Line);
334 }
335  
336 16 push @Lines, hash2vcardlines_pp($Card);
337  
338 16 push @Lines, "END:" . $Type;
339 }
340  
341 31 return @Lines;
342 }
343  
344 146 ▶sub foldline {
Subroutine foldline: called CC=6 SCAR=17.9
Pod undocumented
345 146 local $_ = shift;
346  
347 # Fold at every \n, regardless of position
348 # Try folding on at whitespace boundaries after 60 chars first
349 # Otherwise fold to 75 chars, but don't split utf-8 unicode char or end with a \
350 146 my @Out;
351 146 ▶ while (/\G(.{0,75}?\\n)/gc || /\G(.{60,75})(?<=[^\n\t ])(?=[\n\t ])/gc || /\G(.{0,74}[^\\])(?![\x80-\xbf])/gc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G(.{0,75}?\\n)/cg or /\G(.{60,75})(?<=[^\n\t ])(?=[\n\t ])/cg or /\G(.{0,74}[^\\])(?![\x80-\xbf])/cg) 191 146 337
Condition100%6/6
/\G(.{0,75}?\\n)/cg or /\G(.{60,75})(?<=[^\n\t ])(?=[\n\t ])/cg or /\G(.{0,74}[^\\])(?![\x80-\xbf])/cg
l!l&&r!l&&!r
34157146
/\G(.{0,75}?\\n)/cg or /\G(.{60,75})(?<=[^\n\t ])(?=[\n\t ])/cg
l!l&&r!l&&!r
2212303
MC/DC100%3/3
/\G(.{0,75}?\\n)/cg or /\G(.{60,75})(?<=[^\n\t ])(?=[\n\t ])/cg or /\G(.{0,74}[^\\])(?![\x80-\xbf])/cg
/\G(.{0,75}?\\n)/cg /\G(.{60,75})(?<=[^\n\t ])(?=[\n\t ])/cg /\G(.{0,74}[^\\])(?![\x80-\xbf])/cg
Truth table100%4/4
A or B or C
A= /\G(.{0,75}?\\n)/cgB= /\G(.{60,75})(?<=[^\n\t ])(?=[\n\t ])/cgC= /\G(.{0,74}[^\\])(?![\x80-\xbf])/cg
ABCresult
1XX1
01X1
0011
0000
352 191 ▶ push @Out, (@Out ? " " . $1 : $1);
Branch: 1 branch
BranchTrueFalseTotal
@Out ? : 45 146 191
353 }
354 146 ▶ push @Out, " " . substr($_, pos($_)) if pos $_ != length $_;
Branch: 1 branch
BranchTrueFalseTotal
if pos $_ != length $_ 0 146 146
355  
356 146 return @Out;
357 }
358  
359 # }}}
360  
361 5 1;
362  
363 5 1;
364 __END__
↑ Summary vparse.c »