|
|
e63663 |
From ff424639fe863cbd6963add1a79b97290c1606c6 Mon Sep 17 00:00:00 2001
|
|
|
e63663 |
From: rpm-build <rpm-build>
|
|
|
e63663 |
Date: Fri, 3 Feb 2017 12:26:53 +0100
|
|
|
e63663 |
Subject: [PATCH] fold.c: preserve new-lines in mutlibyte text
|
|
|
e63663 |
|
|
|
e63663 |
---
|
|
|
e63663 |
src/fold.c | 49 ++++++++++++++++++++++++-------------------------
|
|
|
e63663 |
1 file changed, 24 insertions(+), 25 deletions(-)
|
|
|
e63663 |
|
|
|
e63663 |
diff --git a/src/fold.c b/src/fold.c
|
|
|
e63663 |
index d23edd5..8c232a7 100644
|
|
|
e63663 |
--- a/src/fold.c
|
|
|
e63663 |
+++ b/src/fold.c
|
|
|
e63663 |
@@ -342,39 +342,38 @@ fold_multibyte_text (FILE *istream, size_t width, int *saved_errno)
|
|
|
e63663 |
}
|
|
|
e63663 |
|
|
|
e63663 |
rescan:
|
|
|
e63663 |
- if (operating_mode == byte_mode) /* byte mode */
|
|
|
e63663 |
+ if (convfail)
|
|
|
e63663 |
+ increment = 1;
|
|
|
e63663 |
+ else if (wc == L'\n')
|
|
|
e63663 |
+ {
|
|
|
e63663 |
+ /* preserve newline */
|
|
|
e63663 |
+ fwrite (line_out, sizeof(char), offset_out, stdout);
|
|
|
e63663 |
+ START_NEW_LINE;
|
|
|
e63663 |
+ continue;
|
|
|
e63663 |
+ }
|
|
|
e63663 |
+ else if (operating_mode == byte_mode) /* byte mode */
|
|
|
e63663 |
increment = mblength;
|
|
|
e63663 |
else if (operating_mode == character_mode) /* character mode */
|
|
|
e63663 |
increment = 1;
|
|
|
e63663 |
- else /* column mode */
|
|
|
e63663 |
+ else /* column mode */
|
|
|
e63663 |
{
|
|
|
e63663 |
- if (convfail)
|
|
|
e63663 |
- increment = 1;
|
|
|
e63663 |
- else
|
|
|
e63663 |
+ switch (wc)
|
|
|
e63663 |
{
|
|
|
e63663 |
- switch (wc)
|
|
|
e63663 |
- {
|
|
|
e63663 |
- case L'\n':
|
|
|
e63663 |
- fwrite (line_out, sizeof(char), offset_out, stdout);
|
|
|
e63663 |
- START_NEW_LINE;
|
|
|
e63663 |
- continue;
|
|
|
e63663 |
+ case L'\b':
|
|
|
e63663 |
+ increment = (column > 0) ? -1 : 0;
|
|
|
e63663 |
+ break;
|
|
|
e63663 |
|
|
|
e63663 |
- case L'\b':
|
|
|
e63663 |
- increment = (column > 0) ? -1 : 0;
|
|
|
e63663 |
- break;
|
|
|
e63663 |
+ case L'\r':
|
|
|
e63663 |
+ increment = -1 * column;
|
|
|
e63663 |
+ break;
|
|
|
e63663 |
|
|
|
e63663 |
- case L'\r':
|
|
|
e63663 |
- increment = -1 * column;
|
|
|
e63663 |
- break;
|
|
|
e63663 |
+ case L'\t':
|
|
|
e63663 |
+ increment = 8 - column % 8;
|
|
|
e63663 |
+ break;
|
|
|
e63663 |
|
|
|
e63663 |
- case L'\t':
|
|
|
e63663 |
- increment = 8 - column % 8;
|
|
|
e63663 |
- break;
|
|
|
e63663 |
-
|
|
|
e63663 |
- default:
|
|
|
e63663 |
- increment = wcwidth (wc);
|
|
|
e63663 |
- increment = (increment < 0) ? 0 : increment;
|
|
|
e63663 |
- }
|
|
|
e63663 |
+ default:
|
|
|
e63663 |
+ increment = wcwidth (wc);
|
|
|
e63663 |
+ increment = (increment < 0) ? 0 : increment;
|
|
|
e63663 |
}
|
|
|
e63663 |
}
|
|
|
e63663 |
|
|
|
e63663 |
--
|
|
|
e63663 |
2.7.4
|
|
|
e63663 |
|