[perl #107726] Filter::Simple: ‘use’ and then ‘no’
authorRicardo SIGNES <rjbs@cpan.org>
Fri, 26 Aug 2016 13:36:09 +0000 (06:36 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 26 Aug 2016 15:24:33 +0000 (08:24 -0700)
Filter::Simple was erroneously signalling eof if it encountered a
‘no MyFilter’ right after ‘use’:

use MyFilter;
no MyFilter;

In this case it should simply not filter anything.

The reason for the bug was that the ‘while ($status = filter_read())’
loop in Filter::Simple::gen_filter_import was not incrementing $count
(a variable used basically as a boolean to remember whether we are
still getting input from the file) when finding the terminator (no
MyFilter).  So it would conclude after the loop that the file had come
to an end and simply return 0.

[Commit message written by the committer.]

dist/Filter-Simple/lib/Filter/Simple.pm

index 8212919..3ed359a 100644 (file)
@@ -198,6 +198,7 @@ sub gen_filter_import {
                     if ($terminator{terminator} &&
                         m/$terminator{terminator}/) {
                         $lastline = $_;
+                        $count++;
                         last;
                     }
                     $data .= $_;