Subject: bug#64461: closed (Re: [bug-diffutils] bug#64461: strange output of "diff -l -y")

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 04 Jul 2023 17:48:02 +0000

Your bug report

#64461: strange output of "diff -l -y"

which was filed against the diffutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
64461: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64461
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: [bug-diffutils] bug#64461: strange output of "diff -l -y"
From: Paul Eggert <[email-masked]>
To: Bruno Haible <[email-masked]>
Cc: [email-masked]
Date: Tue, 4 Jul 2023 10:47:35 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

Thanks, I installed that, followed by the attached NEWS update. Luckily 
nobody uses diff -ly.

From 8474b6e088627b4b21672374cc63cf2d26cb8eda Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Tue, 4 Jul 2023 10:43:09 -0700
Subject: [PATCH] doc: mention bug#64461 in NEWS

---
 NEWS | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/NEWS b/NEWS
index 0059415..f93196d 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,9 @@ GNU diffutils NEWS                                    -*- outline -*-
     cp /proc/cmdline t; cmp -s /proc/cmdline t || echo files differ
   [bug present since "the beginning"]
 
+  diff -ly no longer mishandles non-ASCII input
+  [bug#64461 introduced in 2.9]
+
 
 * Noteworthy changes in release 3.10 (2023-05-21) [stable]
 
-- 
2.39.2

Subject: strange output of "diff -l -y"
From: Bruno Haible <[email-masked]>
To: [email-masked]
Date: Tue, 04 Jul 2023 18:47:04 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

Seen with diffutils 'master' branch today:

$ cat foo1.txt
你好
$ cat foo2.txt
早晨, 你好
$ src/diff -y foo1.txt foo2.txt
你好                                                          | 早晨, 你好
$ src/diff -l -y foo1.txt foo2.txt

2023-07-04 18:41           diff -l -y foo1.txt foo2.txt           Page 1

                                                              | , 

你好早晨你好

(and the last line is not terminated by a newline).

This is strange, isn't it? 'diff' has separate the ASCII from the
non-ASCII parts of the input. With the attached patch, the output becomes:

$ src/diff -l -y foo1.txt foo2.txt

2023-07-04 18:42           diff -l -y foo1.txt foo2.txt           Page 1

你好                                                          | 早晨, 你好

(which is more what I had expected).

>From cb52fa88d5f2d9bc4894a7eccd90fdc2e03f5af4 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email-masked]>
Date: Tue, 4 Jul 2023 18:45:33 +0200
Subject: [PATCH] diff: Fix output of "diff -l -y" for non-ASCII input files

* src/side.c (print_half_line): Output the multibyte character to out,
not stdout.
---
 src/side.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/side.c b/src/side.c
index 2f566f8..46ef095 100644
--- a/src/side.c
+++ b/src/side.c
@@ -146,7 +146,7 @@ print_half_line (char const *const *line, intmax_t indent, intmax_t out_bound)
                 if (in_position <= out_bound)
                   {
                     out_position = in_position;
-                    fwrite (tp0, 1, bytes, stdout);
+                    fwrite (tp0, 1, bytes, out);
                   }
                 text_pointer = tp0 + bytes;
                 break;
-- 
2.34.1