Subject: bug#74428: closed (Re: bug#74428: tests/printf/printf-cov failure on macOS)

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 19 Nov 2024 18:33:02 +0000

Your bug report

#74428: tests/printf/printf-cov failure on macOS

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

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

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

Subject: Re: bug#74428: tests/printf/printf-cov failure on macOS
From: Pádraig Brady <[email-masked]>
To: Bruno Haible <[email-masked]>, [email-masked]
Cc: [email-masked], Grisha Levit <[email-masked]>
Date: Tue, 19 Nov 2024 18:31:31 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

On 19/11/2024 17:34, Bruno Haible wrote:
> Pádraig Brady wrote:
>> I would prefer to bypass the ASCII case if CODE >= 0 && CODE < 128.
>> However is that generally correct?
> 
> Yes, at least for CODE >= 32 && CODE < 128 it is correct.
> This can be seen from the list of supported locale encodings in
> gnulib/lib/localcharset.h.

OK I've adjusted our test to use \u00032 instead,
and tested the attached code, which I'll push later.

thanks,
Pádraig

From e3aa40bba3e1cabd6bcc781eaacc714a840fbc52 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email-masked]>
Date: Tue, 19 Nov 2024 18:11:21 +0000
Subject: [PATCH] unicodeio: avoid iconv issues for mose ASCII characters

* lib/unicodeio.c (print_unicode_char): Avoid unicode_to_mb()
for most ASCII characters, to avoid iconv() issues
which were seen on macOS.
Addresses https://bugs.gnu.org/74428
---
 ChangeLog       |  8 ++++++++
 lib/unicodeio.c | 18 +++++++++++++-----
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index bf5f6381c1..c4b2290d6c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-11-19  Pádraig Brady  <[email-masked]>
+
+	unicodeio: avoid iconv issues for most ASCII characters
+	* lib/unicodeio.c (print_unicode_char): Avoid unicode_to_mb()
+	for mose ASCII characters, to avoid iconv() issues
+	which were seen on macOS.
+	Addresses https://bugs.gnu.org/74428
+
 2024-11-19  Bruno Haible  <[email-masked]>
 
 	stdlib: Adjust warning about function 'free'.
diff --git a/lib/unicodeio.c b/lib/unicodeio.c
index e93f86ecba..ca23880f61 100644
--- a/lib/unicodeio.c
+++ b/lib/unicodeio.c
@@ -217,9 +217,17 @@ fallback_failure_callback (unsigned int code,
 void
 print_unicode_char (FILE *stream, unsigned int code, int exit_on_error)
 {
-  unicode_to_mb (code, fwrite_success_callback,
-                 exit_on_error
-                 ? exit_failure_callback
-                 : fallback_failure_callback,
-                 stream);
+  /* Simplifiy this subset to avoid potential iconv() issues
+     for that range at least.  */
+  if (32 <= code && code < 128)
+    {
+      char code_char = code;
+      fwrite_success_callback (&code_char, sizeof code_char, stream);
+    }
+  else
+    unicode_to_mb (code, fwrite_success_callback,
+                   exit_on_error
+                   ? exit_failure_callback
+                   : fallback_failure_callback,
+                   stream);
 }
-- 
2.47.0

Subject: tests/printf/printf-cov failure on macOS
From: Grisha Levit <[email-masked]>
To: [email-masked]
Date: Mon, 18 Nov 2024 23:41:46 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

The u4 and U8 tests in tests/printf/printf-cov.pl fail on macOS 15:

u4...
printf: test u4: stdout mismatch, comparing u4.1 (expected) and u4.O (actual)
*** u4.1	Mon Nov 18 23:30:03 2024
--- u4.O	Mon Nov 18 23:30:03 2024
***************
*** 1 ****
! 0
\ No newline at end of file
--- 1 ----
! \u0030
\ No newline at end of file
U8...
printf: test U8: stdout mismatch, comparing U8.1 (expected) and U8.O (actual)
*** U8.1	Mon Nov 18 23:30:03 2024
--- U8.O	Mon Nov 18 23:30:03 2024
***************
*** 1 ****
! 0
\ No newline at end of file
--- 1 ----
! \u0030
\ No newline at end of file