1 |
Author: idl0r |
2 |
Date: 2009-05-01 22:30:00 +0000 (Fri, 01 May 2009) |
3 |
New Revision: 574 |
4 |
|
5 |
Modified: |
6 |
trunk/src/echangelog/echangelog |
7 |
Log: |
8 |
Don't eat newline, bug 264146. |
9 |
|
10 |
Modified: trunk/src/echangelog/echangelog |
11 |
=================================================================== |
12 |
--- trunk/src/echangelog/echangelog 2009-05-01 22:01:53 UTC (rev 573) |
13 |
+++ trunk/src/echangelog/echangelog 2009-05-01 22:30:00 UTC (rev 574) |
14 |
@@ -89,6 +89,29 @@ |
15 |
return undef; |
16 |
} |
17 |
|
18 |
+# Bug 264146. |
19 |
+# Copied from Text::Wrap. |
20 |
+# The only modified thing is: |
21 |
+# We trim _just_ tab/space etc. but not \n/\r. |
22 |
+# So \h should cover \x09, \x0B, \x0C and \x20. |
23 |
+# \s treats even \n/\r as whitespace. |
24 |
+sub text_fill { |
25 |
+ my ($ip, $xp, @raw) = @_; |
26 |
+ my @para; |
27 |
+ my $pp; |
28 |
+ |
29 |
+ for $pp ( split(/\n\s+/, join("\n", @raw)) ) { |
30 |
+ $pp =~ s/\h+/ /g; |
31 |
+ my $x = Text::Wrap::wrap($ip, $xp, $pp); |
32 |
+ push(@para, $x); |
33 |
+ } |
34 |
+ |
35 |
+ # if paragraph_indent is the same as line_indent, |
36 |
+ # separate paragraphs with blank lines |
37 |
+ my $ps = ($ip eq $xp) ? "\n\n" : "\n"; |
38 |
+ return join ($ps, @para); |
39 |
+} |
40 |
+ |
41 |
GetOptions( |
42 |
'help' => \$opt_help, |
43 |
'strict' => \$opt_strict, |
44 |
@@ -508,8 +531,7 @@ |
45 |
|
46 |
# If there are any long lines, then wrap the input at $columns chars |
47 |
# (leaving 2 chars on left, one char on right, after adding indentation below). |
48 |
-$input =~ s/^\s*(.*?)\s*\z/$1/s; # trim whitespace |
49 |
-$input = Text::Wrap::fill(' ', ' ', $input); |
50 |
+$input = text_fill(' ', ' ', $input); |
51 |
|
52 |
# Prepend the user info to the input |
53 |
# Changes related to bug 213374; |