line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
##################################################################### |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# the Perl::Tidy::LineSource class supplies an object with a 'get_line()' method |
4
|
|
|
|
|
|
|
# which returns the next line to be parsed |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
##################################################################### |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package Perl::Tidy::LineSource; |
9
|
38
|
|
|
38
|
|
348
|
use strict; |
|
38
|
|
|
|
|
101
|
|
|
38
|
|
|
|
|
1176
|
|
10
|
38
|
|
|
38
|
|
239
|
use warnings; |
|
38
|
|
|
|
|
95
|
|
|
38
|
|
|
|
|
1045
|
|
11
|
38
|
|
|
38
|
|
242
|
use English qw( -no_match_vars ); |
|
38
|
|
|
|
|
110
|
|
|
38
|
|
|
|
|
443
|
|
12
|
|
|
|
|
|
|
our $VERSION = '20230701'; |
13
|
|
|
|
|
|
|
|
14
|
38
|
|
|
38
|
|
17442
|
use constant DEVEL_MODE => 0; |
|
38
|
|
|
|
|
97
|
|
|
38
|
|
|
|
|
24881
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub AUTOLOAD { |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Catch any undefined sub calls so that we are sure to get |
19
|
|
|
|
|
|
|
# some diagnostic information. This sub should never be called |
20
|
|
|
|
|
|
|
# except for a programming error. |
21
|
0
|
|
|
0
|
|
0
|
our $AUTOLOAD; |
22
|
0
|
0
|
|
|
|
0
|
return if ( $AUTOLOAD =~ /\bDESTROY$/ ); |
23
|
0
|
|
|
|
|
0
|
my ( $pkg, $fname, $lno ) = caller(); |
24
|
0
|
|
|
|
|
0
|
my $my_package = __PACKAGE__; |
25
|
0
|
|
|
|
|
0
|
print STDERR <<EOM; |
26
|
|
|
|
|
|
|
====================================================================== |
27
|
|
|
|
|
|
|
Error detected in package '$my_package', version $VERSION |
28
|
|
|
|
|
|
|
Received unexpected AUTOLOAD call for sub '$AUTOLOAD' |
29
|
|
|
|
|
|
|
Called from package: '$pkg' |
30
|
|
|
|
|
|
|
Called from File '$fname' at line '$lno' |
31
|
|
|
|
|
|
|
This error is probably due to a recent programming change |
32
|
|
|
|
|
|
|
====================================================================== |
33
|
|
|
|
|
|
|
EOM |
34
|
0
|
|
|
|
|
0
|
exit 1; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
0
|
|
|
sub DESTROY { |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# required to avoid call to AUTOLOAD in some versions of perl |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub new { |
43
|
|
|
|
|
|
|
|
44
|
1115
|
|
|
1115
|
0
|
4100
|
my ( $class, @args ) = @_; |
45
|
|
|
|
|
|
|
|
46
|
1115
|
|
|
|
|
4673
|
my %defaults = ( |
47
|
|
|
|
|
|
|
input_file => undef, |
48
|
|
|
|
|
|
|
rOpts => undef, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
1115
|
|
|
|
|
4765
|
my %args = ( %defaults, @args ); |
52
|
|
|
|
|
|
|
|
53
|
1115
|
|
|
|
|
2995
|
my $input_file = $args{input_file}; |
54
|
1115
|
|
|
|
|
2310
|
my $rOpts = $args{rOpts}; |
55
|
|
|
|
|
|
|
|
56
|
1115
|
|
|
|
|
3664
|
( my $fh, $input_file ) = Perl::Tidy::streamhandle( $input_file, 'r' ); |
57
|
1115
|
50
|
|
|
|
4283
|
return unless $fh; |
58
|
|
|
|
|
|
|
|
59
|
1115
|
|
|
|
|
10074
|
return bless { |
60
|
|
|
|
|
|
|
_fh => $fh, |
61
|
|
|
|
|
|
|
_filename => $input_file, |
62
|
|
|
|
|
|
|
_rinput_buffer => [], |
63
|
|
|
|
|
|
|
_started => 0, |
64
|
|
|
|
|
|
|
}, $class; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub close_input_file { |
68
|
561
|
|
|
561
|
0
|
1314
|
my $self = shift; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Only close physical files, not STDIN and other objects |
71
|
561
|
|
|
|
|
1976
|
my $filename = $self->{_filename}; |
72
|
561
|
50
|
33
|
|
|
3616
|
if ( $filename ne '-' && !ref $filename ) { |
73
|
561
|
|
|
|
|
1450
|
my $ok = eval { $self->{_fh}->close(); 1 }; |
|
561
|
|
|
|
|
3159
|
|
|
561
|
|
|
|
|
1565
|
|
74
|
561
|
50
|
50
|
|
|
2643
|
if ( !$ok && DEVEL_MODE ) { |
75
|
0
|
|
|
|
|
0
|
Fault("Could not close file handle(): $EVAL_ERROR\n"); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
561
|
|
|
|
|
1335
|
return; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub get_line { |
82
|
16466
|
|
|
16466
|
0
|
24877
|
my $self = shift; |
83
|
16466
|
|
|
|
|
22221
|
my $line = undef; |
84
|
16466
|
|
|
|
|
25957
|
my $fh = $self->{_fh}; |
85
|
16466
|
|
|
|
|
23820
|
my $rinput_buffer = $self->{_rinput_buffer}; |
86
|
|
|
|
|
|
|
|
87
|
16466
|
50
|
|
|
|
21112
|
if ( scalar( @{$rinput_buffer} ) ) { |
|
16466
|
|
|
|
|
30081
|
|
88
|
0
|
|
|
|
|
0
|
$line = shift @{$rinput_buffer}; |
|
0
|
|
|
|
|
0
|
|
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
else { |
91
|
16466
|
|
|
|
|
39965
|
$line = $fh->getline(); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# patch to read raw mac files under unix, dos |
94
|
|
|
|
|
|
|
# see if the first line has embedded \r's |
95
|
16466
|
100
|
100
|
|
|
58029
|
if ( $line && !$self->{_started} ) { |
96
|
1111
|
50
|
|
|
|
5445
|
if ( $line =~ /[\015][^\015\012]/ ) { |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# found one -- break the line up and store in a buffer |
99
|
0
|
|
|
|
|
0
|
@{$rinput_buffer} = map { $_ . "\n" } split /\015/, $line; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
100
|
0
|
|
|
|
|
0
|
my $count = @{$rinput_buffer}; |
|
0
|
|
|
|
|
0
|
|
101
|
0
|
|
|
|
|
0
|
$line = shift @{$rinput_buffer}; |
|
0
|
|
|
|
|
0
|
|
102
|
|
|
|
|
|
|
} |
103
|
1111
|
|
|
|
|
2554
|
$self->{_started}++; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
} |
106
|
16466
|
|
|
|
|
43107
|
return $line; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
1; |