Skip Menu |

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

Report information
The Basics
Id: 6390
Status: new
Priority: 0/
Queue: Text-Reform

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

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



Subject: break_at() discards input text; breaks too late
The break_at() function has 2 bugs: 1) The $max value used to search for the $hypen uses the full field width and not the remaining width. If they are not identical, and if there are multiple hyphens in the text, then break_at() may choose a "later" hypen instead of an "earlier" one in the same word. 2) The search for the hyphen within the $max first characters is not anchored at the beginning of the string. If the first hyphen appears later than $max characters, only the last $max characters are used and everything before is discarded. Here is a patch for both bugs: --- Reform.orig Tue Feb 03 01:24:56 2004 +++ Reform.pm Sat May 22 16:25:53 2004 @@ -83,11 +83,11 @@ my @ret; sub { - my $max = $_[2]-$hylen; - if ($max <= 0) { + my $max = $_[1]-$hylen; + if ($_[2]-$hylen <= 0) { @ret = (substr($_[0],0,1), substr($_[0],1)) } - elsif ($_[0] =~ /(.{1,$max}$hyphen)(.*)/s) { + elsif ($_[0] =~ /^(.{1,$max}$hyphen)(.*)/s) { @ret = ($1,$2); } elsif (length($_[0])>$_[2]) { End of patch