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