From fcd963fcf1a72c5237739aa035be5d2f3bfa6ca8 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Wed, 20 Apr 2005 00:55:09 +0000 Subject: Bug 272623: FindWrapPoint is misplaced in process_bug.cgi - Patch by Frédéric Buclin r=mkanat a=myk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bugzilla/Util.pm | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'Bugzilla/Util.pm') diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm index 8fcb900df..2c45e077f 100644 --- a/Bugzilla/Util.pm +++ b/Bugzilla/Util.pm @@ -33,8 +33,8 @@ use base qw(Exporter); html_quote url_quote value_quote xml_quote css_class_quote lsearch max min - diff_arrays - trim diff_strings wrap_comment + diff_arrays diff_strings + trim wrap_comment find_wrap_point format_time format_time_decimal file_mod_time); @@ -219,6 +219,25 @@ sub wrap_comment ($) { return $wrappedcomment; } +sub find_wrap_point ($$) { + my ($string, $maxpos) = @_; + if (!$string) { return 0 } + if (length($string) < $maxpos) { return length($string) } + my $wrappoint = rindex($string, ",", $maxpos); # look for comma + if ($wrappoint < 0) { # can't find comma + $wrappoint = rindex($string, " ", $maxpos); # look for space + if ($wrappoint < 0) { # can't find space + $wrappoint = rindex($string, "-", $maxpos); # look for hyphen + if ($wrappoint < 0) { # can't find hyphen + $wrappoint = $maxpos; # just truncate it + } else { + $wrappoint++; # leave hyphen on the left side + } + } + } + return $wrappoint; +} + sub format_time { my ($time) = @_; @@ -480,6 +499,14 @@ database. =back +=item C + +Search for a comma, a whitespace or a hyphen to split $string, within the first +$maxpos characters. If none of them is found, just split $string at $maxpos. +The search starts at $maxpos and goes back to the beginning of the string. + +=back + =head2 Formatting Time =over 4 -- cgit v1.2.3-24-g4f1b