diff options
author | mkanat%kerio.com <> | 2005-02-27 10:14:05 +0100 |
---|---|---|
committer | mkanat%kerio.com <> | 2005-02-27 10:14:05 +0100 |
commit | 518c6ffa1c75fe083c6b014817e29923ae36a851 (patch) | |
tree | c4b5e73a2257491d68e201ad41cff740f1207bd7 | |
parent | 227cf9e129b811c24fc8a4baac5eab439d60965a (diff) | |
download | bugzilla-518c6ffa1c75fe083c6b014817e29923ae36a851.tar.gz bugzilla-518c6ffa1c75fe083c6b014817e29923ae36a851.tar.xz |
Bug 282349: Comments are forced to being left-justified
Patch By Max Kanat-Alexander <mkanat@kerio.com> r=myk, r=gerv, a=justdave
-rw-r--r-- | Bugzilla/Util.pm | 44 | ||||
-rwxr-xr-x | checksetup.pl | 4 |
2 files changed, 23 insertions, 25 deletions
diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm index 7481c18c3..8fcb900df 100644 --- a/Bugzilla/Util.pm +++ b/Bugzilla/Util.pm @@ -43,28 +43,7 @@ use Bugzilla::Error; use Bugzilla::Constants; use Date::Parse; use Date::Format; -use Text::Autoformat qw(autoformat break_wrap); - -our $autoformat_options = { - # Reformat all paragraphs, not just the first one. - all => 1, - # Break only on spaces, and let long lines overflow. - break => break_wrap, - # Columns are COMMENT_COLS wide. - right => COMMENT_COLS, - # Don't reformat into perfect paragraphs, just wrap. - fill => 0, - # Don't compress whitespace. - squeeze => 0, - # Lines starting with ">" are not wrapped. - ignore => qr/^>/, - # Don't re-arrange numbered lists. - renumber => 0, - # Keep short lines at the end of paragraphs as-is. - widow => 0, - # Even if a paragraph looks centered, don't "auto-center" it. - autocentre => 0, -}; +use Text::Wrap; # This is from the perlsec page, slightly modifed to remove a warning # From that page: @@ -218,7 +197,26 @@ sub diff_strings { sub wrap_comment ($) { my ($comment) = @_; - return autoformat($comment, $autoformat_options); + my $wrappedcomment = ""; + + # Use 'local', as recommended by Text::Wrap's perldoc. + local $Text::Wrap::columns = COMMENT_COLS; + # Make words that are longer than COMMENT_COLS not wrap. + local $Text::Wrap::huge = 'overflow'; + # Don't mess with tabs. + local $Text::Wrap::unexpand = 0; + + # If the line starts with ">", don't wrap it. Otherwise, wrap. + foreach my $line (split(/\r\n|\r|\n/, $comment)) { + if ($line =~ qr/^>/) { + $wrappedcomment .= ($line . "\n"); + } + else { + $wrappedcomment .= (wrap('', '', $line) . "\n"); + } + } + + return $wrappedcomment; } sub format_time { diff --git a/checksetup.pl b/checksetup.pl index e94e9dc0d..0aaebe652 100755 --- a/checksetup.pl +++ b/checksetup.pl @@ -313,8 +313,8 @@ my $modules = [ version => '2.08' }, { - name => 'Text::Autoformat', - version => '0' + name => 'Text::Wrap', + version => '2001.0131' }, { name => 'Mail::Mailer', |