diff options
author | idl0r <idl0r@gentoo.org> | 2009-05-01 22:30:00 +0000 |
---|---|---|
committer | idl0r <idl0r@gentoo.org> | 2009-05-01 22:30:00 +0000 |
commit | 75888723dda25e4c2b459bc8e7996c8176fc1a26 (patch) | |
tree | 58285a57da2704cec1e63f550d26a8f0b557da9e | |
parent | Removed duplicate sort call. (diff) | |
download | gentoolkit-75888723dda25e4c2b459bc8e7996c8176fc1a26.tar.gz gentoolkit-75888723dda25e4c2b459bc8e7996c8176fc1a26.tar.bz2 gentoolkit-75888723dda25e4c2b459bc8e7996c8176fc1a26.zip |
Don't eat newline, bug 264146.
svn path=/; revision=574
-rwxr-xr-x | trunk/src/echangelog/echangelog | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/trunk/src/echangelog/echangelog b/trunk/src/echangelog/echangelog index f198db5..9f9e365 100755 --- a/trunk/src/echangelog/echangelog +++ b/trunk/src/echangelog/echangelog @@ -89,6 +89,29 @@ sub getenv($) { return undef; } +# Bug 264146. +# Copied from Text::Wrap. +# The only modified thing is: +# We trim _just_ tab/space etc. but not \n/\r. +# So \h should cover \x09, \x0B, \x0C and \x20. +# \s treats even \n/\r as whitespace. +sub text_fill { + my ($ip, $xp, @raw) = @_; + my @para; + my $pp; + + for $pp ( split(/\n\s+/, join("\n", @raw)) ) { + $pp =~ s/\h+/ /g; + my $x = Text::Wrap::wrap($ip, $xp, $pp); + push(@para, $x); + } + + # if paragraph_indent is the same as line_indent, + # separate paragraphs with blank lines + my $ps = ($ip eq $xp) ? "\n\n" : "\n"; + return join ($ps, @para); +} + GetOptions( 'help' => \$opt_help, 'strict' => \$opt_strict, @@ -508,8 +531,7 @@ die "Empty entry; aborting\n" unless $input =~ /\S/; # If there are any long lines, then wrap the input at $columns chars # (leaving 2 chars on left, one char on right, after adding indentation below). -$input =~ s/^\s*(.*?)\s*\z/$1/s; # trim whitespace -$input = Text::Wrap::fill(' ', ' ', $input); +$input = text_fill(' ', ' ', $input); # Prepend the user info to the input # Changes related to bug 213374; |