Subject: | Parse::RecDescent 1.94 bug report |
Date: | Fri, 22 Jun 2007 23:44:10 -0400 |
To: | <bug-Parse-RecDescent [...] rt.cpan.org> |
From: | "Vallon, Justin" <jvallon [...] bear.com> |
module - Parse::RecDescent 1.94
When calling a parser with $parser->rule(\$text), I am getting some
warnings about lvalues and scalars.
sub AUTOLOAD # ($parser, $text; $linenum, @args)
{
croak "Could not find method: $AUTOLOAD\n" unless ref $_[0];
my $class = ref($_[0]) || $_[0];
my $text = ref($_[1]) ? ${$_[1]} : $_[1];
$_[0]->{lastlinenum} = $_[2]||_linecount($_[1]);
$_[0]->{lastlinenum} = _linecount($_[1]);
$_[0]->{lastlinenum} += $_[2] if @_ > 2;
$_[0]->{offsetlinenum} = $_[0]->{lastlinenum};
$_[0]->{fulltext} = $text;
If \$text is passed, _linecount(\$text) is called, and it gives "Attempt
to use reference as lvalue in substr".
The call to _linecount($_[1]) should be _linecount($text). Also, the
first lastlinenum setting is unnecessary.
Patch:
--- ./lib/Parse/RecDescent.pm.~1~ 2003-04-09 04:29:37.000000000
-0400
+++ ./lib/Parse/RecDescent.pm 2007-05-31 14:53:33.001675000 -0400
@@ -2778,8 +2778,7 @@
croak "Could not find method: $AUTOLOAD\n" unless ref $_[0];
my $class = ref($_[0]) || $_[0];
my $text = ref($_[1]) ? ${$_[1]} : $_[1];
- $_[0]->{lastlinenum} = $_[2]||_linecount($_[1]);
- $_[0]->{lastlinenum} = _linecount($_[1]);
+ $_[0]->{lastlinenum} = _linecount($text);
$_[0]->{lastlinenum} += $_[2] if @_ > 2;
$_[0]->{offsetlinenum} = $_[0]->{lastlinenum};
$_[0]->{fulltext} = $text;
-Justin
***********************************************************************
Bear Stearns is not responsible for any recommendation, solicitation,
offer or agreement or any information about any transaction, customer
account or account activity contained in this communication.
***********************************************************************