Wide/EXTENDED_OS_ERROR.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/ERRNO.pm ↑ Summary
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::EXTENDED_OS_ERROR;
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 # $^E fetching in Perl_magic_get():
39 #
40 # $^E on MacOS is GetSysErrText. Is that mac-roman maybe?
41 #
42 # $^E on VMS is sys$getmsg. Is that the selected NLS thingie?
43 #
44 # $^E on ms-dos is GetLastError.
45 #
46 # $^E on OS2 is DosGetMessage or OSO001.MSG.
47 #
48 BEGIN {
49 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
50 1 utf8::upgrade($u);
51 1 my $e = Scalar::Util::dualvar(0,$u);
52 1 utf8::is_utf8($e) }) {
53 ### dualvar() is utf8
54 1 ▶ 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/EXTENDED_OS_ERROR.pm\"\n sub FETCH {\n return Scalar::Util::dualvar\n (\$^E, POSIX::Wide::_to_wide(\"\$^E\"));\n }\n 1;\n" or die 0 1 1
55 sub FETCH {
56 4 ▶ return Scalar::Util::dualvar
Subroutine FETCH: called CC=1 SCAR=0.0
57 ($^E, POSIX::Wide::_to_wide("$^E"));
58 }
59 1;
60 HERE
61 } else {
62 ### dualvar() is not utf8, using _utf8_on()
63 0 require Encode;
64 0 ▶ eval "\n#line ".(__LINE__+1)." \"".__FILE__."\"\n" . <<'HERE' or die;
Branch: 1 branch
BranchTrueFalseTotal
eval "\n#line 65 \"/root/.cpan/build/POSIX-Wide-10-0/blib/lib/POSIX/Wide/EXTENDED_OS_ERROR.pm\"\n sub FETCH {\n my \$e = Scalar::Util::dualvar\n (\$^E, POSIX::Wide::_to_wide(\"\$^E\"));\n Encode::_utf8_on(\$e);\n return \$e;\n }\n 1;\n" or die 0 0 0
65 sub FETCH {
66 my $e = Scalar::Util::dualvar
67 ($^E, POSIX::Wide::_to_wide("$^E"));
68 Encode::_utf8_on($e);
69 return $e;
70 }
71 1;
72 HERE
73 }
74 }
75  
76 sub STORE {
77 0 ▶ my ($self, $value) = @_;
Subroutine STORE: not called CC=1 SCAR=6.9
78 0 $^E = $value;
79 }
80  
81 1 1;
82 __END__
« Wide/ERRNO.pm ↑ Summary