Wide/ERRNO.pm

filter: Statementstmt 85.1% 23 / 27 Branchbran 33.3% 2 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 7 / 8 Podpod n/a totaltotal 78.0% 32 / 41 SCAR 14.4
CC
4
Cov
76%
BEGIN
5.0
STORE
2.0
BEGIN
1.0
CRAP 4.2
« Wide.pm ↑ Summary Wide/EXTENDED_OS_ERROR.pm »
1 # Copyright 2009, 2010, 2012, 2014 Kevin Ryde
2  
3 # This file is part of POSIX-Wide.
4 #
5 # POSIX-Wide is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 3, or (at your option) any later
8 # version.
9 #
10 # POSIX-Wide is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 # for more details.
14 #
15 # You should have received a copy of the GNU General Public License along
16 # with POSIX-Wide. If not, see <http://www.gnu.org/licenses/>.
17  
18 package POSIX::Wide::ERRNO;
19 1 ▶use 5.008001; # for utf8::is_utf8()
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Scalar::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 # uncomment this to run the ### lines
25 #use Smart::Comments;
26  
27 1 our $VERSION = 10;
28  
29 sub TIESCALAR {
30 1 ▶ my ($class) = @_;
Subroutine TIESCALAR: called CC=1 SCAR=0.0
31 1 my $self;
32 1 return bless \$self, $class;
33 }
34  
35 # dualvar() in Scalar::Util 1.22 (post perl 5.10.1) will propagate the
36 # utf8 flag on its own, for prior versions must turn it on explicitly
37 #
38 BEGIN {
39 1 ▶ if (do { my $u = 'x';
Subroutine BEGIN: called CC=4 SCAR=16.1
Branch: 1 branch
BranchTrueFalseTotal
if (do { my $u = 'x'; utf8::upgrade($u); my $e = &Scalar::Util::dualvar(0, $u); utf8::is_utf8($e) }) { } 1 0 1
40 1 utf8::upgrade($u);
41 1 my $e = Scalar::Util::dualvar(0,$u);
42 1 utf8::is_utf8($e) }) {
43 ### dualvar() is utf8
44 1 ▶ eval "\n#line ".(__LINE__+1)." \"".__FILE__."\"\n" . <<'HERE' or die;
Branch: 1 branch
BranchTrueFalseTotal
eval "\n#line 45 \"/root/.cpan/build/POSIX-Wide-10-0/blib/lib/POSIX/Wide/ERRNO.pm\"\n sub FETCH {\n return Scalar::Util::dualvar\n (\$!, POSIX::Wide::_to_wide(\"\$!\"));\n }\n 1;\n" or die 0 1 1
45 sub FETCH {
46 4 ▶ return Scalar::Util::dualvar
Subroutine FETCH: called CC=1 SCAR=0.0
47 ($!, POSIX::Wide::_to_wide("$!"));
48 }
49 1;
50 HERE
51 } else {
52 ### dualvar() is not utf8, using _utf8_on()
53 0 require Encode;
54 0 ▶ eval "\n#line ".(__LINE__+1)." \"".__FILE__."\"\n" . <<'HERE' or die;
Branch: 1 branch
BranchTrueFalseTotal
eval "\n#line 55 \"/root/.cpan/build/POSIX-Wide-10-0/blib/lib/POSIX/Wide/ERRNO.pm\"\n sub FETCH {\n my \$e = Scalar::Util::dualvar\n (\$!, POSIX::Wide::_to_wide(\"\$!\"));\n Encode::_utf8_on(\$e);\n return \$e;\n }\n 1;\n" or die 0 0 0
55 sub FETCH {
56 my $e = Scalar::Util::dualvar
57 ($!, POSIX::Wide::_to_wide("$!"));
58 Encode::_utf8_on($e);
59 return $e;
60 }
61 1;
62 HERE
63 }
64 }
65  
66 sub STORE {
67 0 ▶ my ($self, $value) = @_;
Subroutine STORE: not called CC=1 SCAR=6.9
68 0 $! = $value;
69 }
70  
71 1 1;
72 __END__
« Wide.pm ↑ Summary Wide/EXTENDED_OS_ERROR.pm »