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

dd59ef
From 493f1291993a352e47a79fa7471880289df2efc4 Mon Sep 17 00:00:00 2001
dd59ef
From: Kamil Dudka <kdudka@redhat.com>
dd59ef
Date: Fri, 3 Feb 2017 12:26:53 +0100
dd59ef
Subject: [PATCH] fold: preserve new-lines in mutlibyte text (#1418505)
dd59ef
dd59ef
---
dd59ef
 src/fold.c | 55 +++++++++++++++++++++++++++----------------------------
dd59ef
 1 file changed, 27 insertions(+), 28 deletions(-)
dd59ef
dd59ef
diff --git a/src/fold.c b/src/fold.c
dd59ef
index 51abea8..4106f24 100644
dd59ef
--- a/src/fold.c
dd59ef
+++ b/src/fold.c
dd59ef
@@ -342,39 +342,38 @@ fold_multibyte_text (FILE *istream, size_t width, int *saved_errno)
dd59ef
         }
dd59ef
 
dd59ef
 rescan:
dd59ef
-      if (operating_mode == byte_mode)                        /* byte mode */
dd59ef
+      if (convfail)
dd59ef
+        increment = 1;
dd59ef
+      else if (wc == L'\n')
dd59ef
+        {
dd59ef
+          /* preserve newline */
dd59ef
+          fwrite (line_out, sizeof(char), offset_out, stdout);
dd59ef
+          START_NEW_LINE;
dd59ef
+          continue;
dd59ef
+        }
dd59ef
+      else if (operating_mode == byte_mode)                  /* byte mode */
dd59ef
         increment = mblength;
dd59ef
       else if (operating_mode == character_mode)        /* character mode */
dd59ef
         increment = 1;
dd59ef
-      else                                                /* column mode */
dd59ef
+      else                                                 /* column mode */
dd59ef
         {
dd59ef
-          if (convfail)
dd59ef
-            increment = 1;
dd59ef
-          else
dd59ef
+          switch (wc)
dd59ef
             {
dd59ef
-              switch (wc)
dd59ef
-                {
dd59ef
-                case L'\n':
dd59ef
-                  fwrite (line_out, sizeof(char), offset_out, stdout);
dd59ef
-                  START_NEW_LINE;
dd59ef
-                  continue;
dd59ef
-                  
dd59ef
-                case L'\b':
dd59ef
-                  increment = (column > 0) ? -1 : 0;
dd59ef
-                  break;
dd59ef
-
dd59ef
-                case L'\r':
dd59ef
-                  increment = -1 * column;
dd59ef
-                  break;
dd59ef
-
dd59ef
-                case L'\t':
dd59ef
-                  increment = 8 - column % 8;
dd59ef
-                  break;
dd59ef
-
dd59ef
-                default:
dd59ef
-                  increment = wcwidth (wc);
dd59ef
-                  increment = (increment < 0) ? 0 : increment;
dd59ef
-                }
dd59ef
+            case L'\b':
dd59ef
+              increment = (column > 0) ? -1 : 0;
dd59ef
+              break;
dd59ef
+
dd59ef
+            case L'\r':
dd59ef
+              increment = -1 * column;
dd59ef
+              break;
dd59ef
+
dd59ef
+            case L'\t':
dd59ef
+              increment = 8 - column % 8;
dd59ef
+              break;
dd59ef
+
dd59ef
+            default:
dd59ef
+              increment = wcwidth (wc);
dd59ef
+              increment = (increment < 0) ? 0 : increment;
dd59ef
             }
dd59ef
         }
dd59ef
 
dd59ef
-- 
dd59ef
2.13.5
dd59ef