From 75888723dda25e4c2b459bc8e7996c8176fc1a26 Mon Sep 17 00:00:00 2001 From: idl0r Date: Fri, 1 May 2009 22:30:00 +0000 Subject: [PATCH] Don't eat newline, bug 264146. svn path=/; revision=574 --- trunk/src/echangelog/echangelog | 26 ++++++++++++++++++++++++-- 1 file 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; -- 2.26.2