Skip Menu |

This queue is for tickets about the Text-Balanced CPAN distribution.

Report information
The Basics
Id: 752
Status: resolved
Priority: 0/
Queue: Text-Balanced

People
Owner: Nobody in particular
Requestors: harleypig [...] harleypig.com
Cc:
AdminCc:

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

Attachments


Subject: Calling a subroutine with a heredoc as a parameter breaks Text::Balanced::extract_multiple.
Calling a subroutine with a heredoc as a parameter breaks Text::Balanced::extract_multiple. (see simplified.pm for example) I discovered this while trying to make Filter::Simple work for some modules I have and am trying to condense a little. The actual error message is in the _success module when there is a 'FILLET' (beginning at line 69). It looks like what is being attempted in this algorithm is the heredoc is to be excised while leaving any additional text on the same line after the heredoc begin alone. The problem I see here is that the algorithm is attempting to do this from a fragment of the original text with numbers relating to the full text. my $extra = substr($res[0], $extrapos-$startlen, $extralen, "\n"); The values in $extrapos, $startlen and $extralen are all relative to the original text. The only one that matters though is $extrapos, which in my example code is 92, but in $res[0] is 0. Either $res[0] needs to be changed to $$textref or '$extrapos-$startlen' needs to be changed to $startlen. I think. I haven't had the chance to fully analyze everything that would be affected by any of this. So I apologize if I've missed something incredibly stoopid. If I can be of further assistance please feel free to contact me. Check attached file 'explain.txt' for system information. Alan Young harleypig@harleypig.com
Download tb_problem.zip
application/x-zip-compressed 3k

Message body not shown because it is not plain text.

From: David Manura
This problem is described in perlbug #25154 (http://bugs6.perl.org/rt3/Ticket/Display.html?id=25154). The patch is also part of the larger patch given in perlbug #25157 (http://bugs6.perl.org/rt3/Ticket/Display.html?id=25157). This patch replaces $extrapos-$startlen with $extrapos-$oppos, where $oppos is set to $_[6]. So, if $$textref is <<TEXT + 123; 1 TEXT and pos($$textref) is initially 0, then $extrapos would be 8, $startlen would be 2, $oppos would be 2, and $res[0] would be <<TEXT + 123; 1 TEXT In this case, the patch has no effect. substr($res[0], $extrapos- $oppos, $extralen) refers to " + 123;\n", which is the fillet to be moved. However, if pos($$textref) is initially 2, then $extrapos would be 8, $startlen would be 0, and $oppos would be 2. As seen, $startlen should be replaced with $oppos. I don't believe it would be correct to simply repleace $res[0] with $$textref. $res[0] is the first return argument of _succeed(), which is therefore the first return argument of match_quotelike(), which under list context should be the extracted string, not the whole string. ughh...that's a lot to think about. -davidm [guest - Mon Jun 17 14:22:06 2002]: Show quoted text
> Calling a subroutine with a heredoc as a parameter breaks > Text::Balanced::extract_multiple. (see simplified.pm for example) > > I discovered this while trying to make Filter::Simple work for some > modules I have and am trying to condense a little. > > The actual error message is in the _success module when there is a > 'FILLET' (beginning at line 69). It looks like what is being > attempted in this algorithm is the heredoc is to be excised while > leaving any additional text on the same line after the heredoc > begin alone. > > The problem I see here is that the algorithm is attempting to do this > from a fragment of the original text with numbers relating to the > full text. > > my $extra = substr($res[0], $extrapos-$startlen, $extralen, "\n"); > > The values in $extrapos, $startlen and $extralen are all relative to > the original text. The only one that matters though is $extrapos, > which in my example code is 92, but in $res[0] is 0. Either > $res[0] needs to be changed to $$textref or '$extrapos-$startlen' > needs to be changed to $startlen. I think. > > I haven't had the chance to fully analyze everything that would be > affected by any of this. So I apologize if I've missed something > incredibly stoopid. If I can be of further assistance please feel > free to contact me. > > Check attached file 'explain.txt' for system information. > > Alan Young > harleypig@harleypig.com
On Thu Jan 22 23:17:00 2004, guest wrote: Show quoted text
> This problem is described in perlbug #25154 > (http://bugs6.perl.org/rt3/Ticket/Display.html?id=25154). The patch is > also part of the larger patch given in perlbug #25157 > (http://bugs6.perl.org/rt3/Ticket/Display.html?id=25157). >
The patch in rt.perl.org#25157 was applied to blead long ago, and is also therefore in Text::Balanced on CPAN since it is currently in sync with blead. So this should be fixed.