line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
##################################################################### |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# This is a stripped down version of IO::ScalarArray |
4
|
|
|
|
|
|
|
# Given a reference to an array, it supplies either: |
5
|
|
|
|
|
|
|
# a getline method which reads lines (mode='r'), or |
6
|
|
|
|
|
|
|
# a print method which reads lines (mode='w') |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# NOTE: this routine assumes that there aren't any embedded |
9
|
|
|
|
|
|
|
# newlines within any of the array elements. There are no checks |
10
|
|
|
|
|
|
|
# for that. |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
##################################################################### |
13
|
|
|
|
|
|
|
package Perl::Tidy::IOScalarArray; |
14
|
38
|
|
|
38
|
|
306
|
use strict; |
|
38
|
|
|
|
|
107
|
|
|
38
|
|
|
|
|
1207
|
|
15
|
38
|
|
|
38
|
|
261
|
use warnings; |
|
38
|
|
|
|
|
110
|
|
|
38
|
|
|
|
|
881
|
|
16
|
38
|
|
|
38
|
|
208
|
use Carp; |
|
38
|
|
|
|
|
105
|
|
|
38
|
|
|
|
|
21025
|
|
17
|
|
|
|
|
|
|
our $VERSION = '20230701'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub AUTOLOAD { |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Catch any undefined sub calls so that we are sure to get |
22
|
|
|
|
|
|
|
# some diagnostic information. This sub should never be called |
23
|
|
|
|
|
|
|
# except for a programming error. |
24
|
0
|
|
|
0
|
|
0
|
our $AUTOLOAD; |
25
|
0
|
0
|
|
|
|
0
|
return if ( $AUTOLOAD =~ /\bDESTROY$/ ); |
26
|
0
|
|
|
|
|
0
|
my ( $pkg, $fname, $lno ) = caller(); |
27
|
0
|
|
|
|
|
0
|
my $my_package = __PACKAGE__; |
28
|
0
|
|
|
|
|
0
|
print STDERR <<EOM; |
29
|
|
|
|
|
|
|
====================================================================== |
30
|
|
|
|
|
|
|
Error detected in package '$my_package', version $VERSION |
31
|
|
|
|
|
|
|
Received unexpected AUTOLOAD call for sub '$AUTOLOAD' |
32
|
|
|
|
|
|
|
Called from package: '$pkg' |
33
|
|
|
|
|
|
|
Called from File '$fname' at line '$lno' |
34
|
|
|
|
|
|
|
This error is probably due to a recent programming change |
35
|
|
|
|
|
|
|
====================================================================== |
36
|
|
|
|
|
|
|
EOM |
37
|
0
|
|
|
|
|
0
|
exit 1; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
0
|
|
|
sub DESTROY { |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# required to avoid call to AUTOLOAD in some versions of perl |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub new { |
46
|
2
|
|
|
2
|
0
|
9
|
my ( $package, $rarray, $mode ) = @_; |
47
|
2
|
|
|
|
|
7
|
my $ref = ref $rarray; |
48
|
2
|
50
|
|
|
|
12
|
if ( $ref ne 'ARRAY' ) { |
49
|
0
|
|
|
|
|
0
|
confess <<EOM; |
50
|
|
|
|
|
|
|
------------------------------------------------------------------------ |
51
|
|
|
|
|
|
|
expecting ref to ARRAY but got ref to ($ref); trace follows: |
52
|
|
|
|
|
|
|
------------------------------------------------------------------------ |
53
|
|
|
|
|
|
|
EOM |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
56
|
2
|
50
|
|
|
|
12
|
if ( $mode eq 'w' ) { |
|
|
50
|
|
|
|
|
|
57
|
0
|
|
|
|
|
0
|
@{$rarray} = (); |
|
0
|
|
|
|
|
0
|
|
58
|
0
|
|
|
|
|
0
|
return bless [ $rarray, $mode ], $package; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
elsif ( $mode eq 'r' ) { |
61
|
2
|
|
|
|
|
4
|
my $i_next = 0; |
62
|
2
|
|
|
|
|
11
|
return bless [ $rarray, $mode, $i_next ], $package; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
else { |
65
|
0
|
|
|
|
|
0
|
confess <<EOM; |
66
|
|
|
|
|
|
|
------------------------------------------------------------------------ |
67
|
|
|
|
|
|
|
expecting mode = 'r' or 'w' but got mode ($mode); trace follows: |
68
|
|
|
|
|
|
|
------------------------------------------------------------------------ |
69
|
|
|
|
|
|
|
EOM |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub getline { |
74
|
15
|
|
|
15
|
0
|
21
|
my $self = shift; |
75
|
15
|
|
|
|
|
25
|
my $mode = $self->[1]; |
76
|
15
|
50
|
|
|
|
31
|
if ( $mode ne 'r' ) { |
77
|
0
|
|
|
|
|
0
|
confess <<EOM; |
78
|
|
|
|
|
|
|
------------------------------------------------------------------------ |
79
|
|
|
|
|
|
|
getline requires mode = 'r' but mode = ($mode); trace follows: |
80
|
|
|
|
|
|
|
------------------------------------------------------------------------ |
81
|
|
|
|
|
|
|
EOM |
82
|
|
|
|
|
|
|
} |
83
|
15
|
|
|
|
|
27
|
my $i = $self->[2]++; |
84
|
15
|
|
|
|
|
36
|
return $self->[0]->[$i]; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub print { |
88
|
0
|
|
|
0
|
0
|
|
my ( $self, $msg ) = @_; |
89
|
0
|
|
|
|
|
|
my $mode = $self->[1]; |
90
|
0
|
0
|
|
|
|
|
if ( $mode ne 'w' ) { |
91
|
0
|
|
|
|
|
|
confess <<EOM; |
92
|
|
|
|
|
|
|
------------------------------------------------------------------------ |
93
|
|
|
|
|
|
|
print requires mode = 'w' but mode = ($mode); trace follows: |
94
|
|
|
|
|
|
|
------------------------------------------------------------------------ |
95
|
|
|
|
|
|
|
EOM |
96
|
|
|
|
|
|
|
} |
97
|
0
|
|
|
|
|
|
push @{ $self->[0] }, $msg; |
|
0
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
return; |
99
|
|
|
|
|
|
|
} |
100
|
0
|
|
|
0
|
0
|
|
sub close { return } |
101
|
|
|
|
|
|
|
1; |
102
|
|
|
|
|
|
|
|