Skip Menu |

This queue is for tickets about the Perl-Tidy CPAN distribution.

Report information
The Basics
Id: 25926
Status: resolved
Priority: 0/
Queue: Perl-Tidy

People
Owner: Nobody in particular
Requestors: book [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: (no value)
Fixed in: (no value)



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 {
From: BOOK [...] cpan.org
On Thu Mar 29 20:26:04 2007, BOOK wrote: Show quoted text
> > 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)
Here is a better patch, that at least correct all the issues in the subroutine.
--- Perl-Tidy-20060719/lib/Perl/Tidy.pm 2006-07-20 01:36:43.000000000 +0200 +++ Perl-Tidy-new/lib/Perl/Tidy.pm 2007-03-30 10:07:59.000000000 +0200 @@ -3824,11 +3824,11 @@ 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 { - print $fh_warnings @_; + $fh_warnings->print(@_); $self->write_logfile_entry(@_); } } @@ -3836,7 +3836,7 @@ $self->{_warning_count} = $warning_count; if ( $warning_count == WARNING_LIMIT ) { - print $fh_warnings "No further warnings will be given"; + $fh_warnings->print ("No further warnings will be given"); } } }
Subject: Re: [rt.cpan.org #25926] a scalar ref 'errorfile' parameter makes Perl::Tidy die
Date: Fri, 30 Mar 2007 06:37:45 -0700
To: Philippe Bruhat via RT <bug-Perl-Tidy [...] rt.cpan.org>
From: Steve Hancock <perltidy [...] users.sourceforge.net>
Thanks!! Steve On Fri, Mar 30, 2007 at 04:11:10AM -0400, Philippe Bruhat via RT wrote: Show quoted text
> > Queue: Perl-Tidy > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=25926 > > > On Thu Mar 29 20:26:04 2007, BOOK wrote:
> > > > 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)
> > Here is a better patch, that at least correct all the issues in the > subroutine. >
Show quoted text
> --- Perl-Tidy-20060719/lib/Perl/Tidy.pm 2006-07-20 01:36:43.000000000 +0200 > +++ Perl-Tidy-new/lib/Perl/Tidy.pm 2007-03-30 10:07:59.000000000 +0200 > @@ -3824,11 +3824,11 @@ > 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 { > - print $fh_warnings @_; > + $fh_warnings->print(@_); > $self->write_logfile_entry(@_); > } > } > @@ -3836,7 +3836,7 @@ > $self->{_warning_count} = $warning_count; > > if ( $warning_count == WARNING_LIMIT ) { > - print $fh_warnings "No further warnings will be given"; > + $fh_warnings->print ("No further warnings will be given"); > } > } > }
This is corrected in version 20070424.