| 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
| |||||||||||
| 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
| |||||||||||
| 33 | 1 | $NS->__THROW( 'Read', length => $length ); | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 103 | return $ret; | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 1 | 1; | |||||||||