Blame SOURCES/coreutils-i18n-fold-newline.patch

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