Subject: | ignore handling fails to work, patch included |
About a year ago, Dave Rolsky found and reported a bug in Text::Autoformat that causes
ignore to not work correctly. His description:
"The problem is the use of "$lastignored &&=". Because of Perl's short-circuiting, the ignore
subref is never being called when $lastignored is true. The tests I sent earlier had a bug of
their which masked this bug."
And his patch:
diff -Nru ../Text-Autoformat-1.13/lib/Text/Autoformat.pm ./lib/Text/Autoformat.pm
--- ../Text-Autoformat-1.13/lib/Text/Autoformat.pm 2005-05-04 17:44:23.000000000
-0500
+++ ./lib/Text/Autoformat.pm 2006-11-15 11:57:40.000000000 -0600
@@ -273,8 +273,8 @@
my $lastignored = 1;
for my $index (0..$#paras) {
local $_ = $paras[$index]{raw} . "\n";
- $lastignored &&=
- $paras[$index]{ignore} = $args{ignore}($lastignored);
+ $paras[$index]{ignore} = $args{ignore}($lastignored);
+ $lastignored &&= $paras[$index]{ignore};
next unless $args{mail} && /^--$/;
$remainder = join "\n", map { $_->{raw} } splice @paras, $index;
$remainder .= "\n" unless $remainder =~ /\n\z/;