Subject: | a scalar ref 'errorfile' parameter makes Perl::Tidy die |
When using a scalar reference as a the 'errorfile' parameter to the
perltidy() method, the script fails with the error
"Not a GLOB reference at
/opt/local/lib/perl5/site_perl/5.8.8/Perl/Tidy.pm line 3827."
Here's a patch for this error, as well as a test script showing the bug.
I guess many other "print $fh" constructs will fail if $fh is a
Perl::Tidy::IOScalar or a Perl::Tidy::IOScalarArray)
Regards,
-- BooK
Subject: | errorfile.t |
use strict;
use warnings;
use Test::More;
use Perl::Tidy;
my $msg =
"1:\thit EOF seeking end of quote/pattern starting at line 1 ending in /\n";
my @test =
( [ SCALAR => \do { my $x = '' }, \$msg ], [ ARRAY => [], [$msg] ], );
plan tests => 3 * @test;
for my $test (@test) {
my ( $tidied_code, $logfile ) = ( '', '' );
local $SIG{__WARN__} = sub {
is(
$_[0],
"## Please see file $test->[0]\n",
"Warning about $test->[0]"
);
};
eval {
Perl::Tidy::perltidy(
source => \'/*', # code that will make Perl::Tidy err
destination => \$tidied_code,
logfile => \$logfile,
errorfile => $test->[1], # for these two
);
};
is( $@, '', "Perl::Tidy didn't die" );
is_deeply( $test->[1], $test->[2], "Error in $test->[0]" );
}
Subject: | perltidy.patch |
--- Perl-Tidy-20060719/lib/Perl/Tidy.pm 2006-07-20 01:36:43.000000000 +0200
+++ Perl-Tidy-new/lib/Perl/Tidy.pm 2007-03-29 23:37:59.000000000 +0200
@@ -3824,7 +3824,7 @@
if ( $self->get_use_prefix() > 0 ) {
my $input_line_number =
Perl::Tidy::Tokenizer::get_input_line_number();
- print $fh_warnings "$input_line_number:\t@_";
+ $fh_warnings->print( "$input_line_number:\t@_" );
$self->write_logfile_entry("WARNING: @_");
}
else {