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