File Coverage

blib/lib/ExtUtils/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 ExtUtils::ParseXS::CountLines;
2 19     19   148 use strict;
  19         34  
  19         10470  
3              
4             our $VERSION = '3.61';
5              
6             our $SECTION_END_MARKER;
7              
8             sub TIEHANDLE {
9 314     314   3216 my ($class, $cfile, $fh) = @_;
10 314         2795 $cfile =~ s/\\/\\\\/g;
11 314         1757 $cfile =~ s/"/\\"/g;
12 314         1602 $SECTION_END_MARKER = qq{#line --- "$cfile"};
13              
14 314         13424 return bless {
15             buffer => '',
16             fh => $fh,
17             line_no => 1,
18             }, $class;
19             }
20              
21             sub PRINT {
22 8683     8683   16214 my $self = shift;
23 8683         18450 for (@_) {
24 11382         30903 $self->{buffer} .= $_;
25 11382         65417 while ($self->{buffer} =~ s/^([^\n]*\n)//) {
26 65758         443772 my $line = $1;
27 65758         99520 ++$self->{line_no};
28 65758         103084 $line =~ s|^\#line\s+---(?=\s)|#line $self->{line_no}|;
29 65758         86926 print {$self->{fh}} $line;
  65758         167353  
30             }
31             }
32             }
33              
34             sub PRINTF {
35 306     306   608 my $self = shift;
36 306         522 my $fmt = shift;
37 306         1753 $self->PRINT(sprintf($fmt, @_));
38             }
39              
40             sub DESTROY {
41             # Not necessary if we're careful to end with a "\n"
42 314     314   821 my $self = shift;
43 314         791 print {$self->{fh}} $self->{buffer};
  314         2492  
44             }
45              
46       281     sub UNTIE {
47             # This sub does nothing, but is necessary for references to be released.
48             }
49              
50             sub end_marker {
51 699     699 0 2851 return $SECTION_END_MARKER;
52             }
53              
54             1;