Die/sysread.pm

filter: Statementstmt 100% 14 / 14 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 100% 20 / 20 CC 3 SCAR 9.2
CC
3
Cov
100%
sysread
3.0
BEGIN
1.0
CRAP 2.5
« Die/sysopen.pm ↑ Summary Die/accept.pm »
1 package IO::Die;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 #----------------------------------------------------------------------
6 #NOTE: read() and sysread() implementations are exactly the same except
7 #for the CORE:: function call. Alas, Perl’s prototyping stuff seems to
8 #make it impossible not to duplicate code here.
9  
10 104 ▶sub sysread {
Subroutine sysread: called CC=3 SCAR=11.0
11 104 my ( $NS, $fh, @length_offset ) = ( shift, shift, @_[ 1 .. $#_ ] );
12  
13 #https://github.com/pjcj/Devel--Cover/issues/125
14 #my ( $NS, $fh, $buffer_sr, @length_offset ) = ( shift, shift, \shift, @_ );
15  
16 104 my ( $length, $offset ) = @length_offset;
17  
18 104 local ( $!, $^E );
19  
20 #NOTE: Perl’s prototypes can throw errors on things like:
21 #(@length_offset > 1) ? $offset : ()
22 #...so the following writes out the two forms of sysread():
23  
24 104 my $ret;
25 104 ▶ if ( @length_offset > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@length_offset > 1) { } 1 103 104
26 1 $ret = CORE::sysread( $fh, $_[0], $length, $offset );
27 }
28 else {
29 103 $ret = CORE::sysread( $fh, $_[0], $length );
30 }
31  
32 104 ▶ if ( !defined $ret ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ret) 1 103 104
33 1 $NS->__THROW( 'Read', length => $length );
34 }
35  
36 103 return $ret;
37 }
38  
39 1 1;
« Die/sysopen.pm ↑ Summary Die/accept.pm »