At 23:19 29/09/2004 +0200, John McNamara wrote:


It probably shouldn't put unnecessary directives on sequential lines either. I might fix that later.


Here is another patch that makes the line directives optional and only adds one directive per removed Pod block.


John.
--


--- Strip.pm    Wed Sep 29 12:04:14 2004
+++ Strip3.pm   Wed Sep 29 22:28:01 2004
@@ -12,13 +12,32 @@
     $new->code_handler
       (
        sub {
+           # Add optional line directives
+           if ($_[2]->{_add_directives} and
+               $_[1] > $_[2]->{_previous_line} +1)
+           {
+               print "#line ", $_[1], "\n";
+           }
+
+           $_[2]->{_previous_line} = $_[1];
+
           print {$_[2]{'output_fh'}} $_[0],"\n";
           return;
        });
+
+    $new->{_previous_line}  = 0;
+    $new->{_add_directives} = 0;
     return $new;
 }


+sub add_line_directives {
+    my $self = shift;
+
+    $self->{_add_directives} = defined $_[0] ? $_[0] : 1;
+}
+
+
 1;
 __END__

@@ -50,11 +69,15 @@

 Pod::Strip is a subclass of Pod::Simple that strips all POD from Perl Code.

-=head1 METOHDS
+=head1 METHODS

 =head2 new

 Generates a new parser object.
+
+=head2 add_line_directives()
+
+Add C<#line> directives to the stripped source so that Perl warnings refer to the unstripped line numbers.

 All other methods are inherited from Pod::Simple







Reply via email to