File Coverage

blib/lib/XS/Install/FrozenShit/ParseXS/CountLines.pm
Criterion Covered Total %
statement 24 24 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 0 1 0.0
total 31 32 96.8


line stmt bran cond sub pod time code
1             package
2             XS::Install::FrozenShit::ParseXS::CountLines;
3 1     1   4 use strict;
  1         1  
  1         367  
4              
5             our $VERSION = '3.57';
6              
7             our $SECTION_END_MARKER;
8              
9             sub TIEHANDLE {
10 1     1   10 my ($class, $cfile, $fh) = @_;
11 1         10 $cfile =~ s/\\/\\\\/g;
12 1         102 $cfile =~ s/"/\\"/g;
13 1         10 $SECTION_END_MARKER = qq{#line --- "$cfile"};
14              
15 1         31 return bless {
16             buffer => '',
17             fh => $fh,
18             line_no => 1,
19             }, $class;
20             }
21              
22             sub PRINT {
23 321     321   570 my $self = shift;
24 321         651 for (@_) {
25 368         863 $self->{buffer} .= $_;
26 368         1679 while ($self->{buffer} =~ s/^([^\n]*\n)//) {
27 548         1195 my $line = $1;
28 548         1087 ++$self->{line_no};
29 548         1005 $line =~ s|^\#line\s+---(?=\s)|#line $self->{line_no}|;
30 548         829 print {$self->{fh}} $line;
  548         3284  
31             }
32             }
33             }
34              
35             sub PRINTF {
36 4     4   10 my $self = shift;
37 4         12 my $fmt = shift;
38 4         23 $self->PRINT(sprintf($fmt, @_));
39             }
40              
41             sub DESTROY {
42             # Not necessary if we're careful to end with a "\n"
43 1     1   4 my $self = shift;
44 1         3 print {$self->{fh}} $self->{buffer};
  1         9  
45             }
46              
47       1     sub UNTIE {
48             # This sub does nothing, but is necessary for references to be released.
49             }
50              
51             sub end_marker {
52 7     7 0 26 return $SECTION_END_MARKER;
53             }
54              
55             1;