Subject: bug#75084: closed (Re: bug#75084: bug report with patch 0003-Fix-make-custom-port-in-case-encoding-is-f.patch)

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 28 Feb 2025 20:29:02 +0000

Your bug report

#75084: bug report with patch 0003-Fix-make-custom-port-in-case-encoding-is-f.patch

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

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

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

Subject: Re: bug#75084: bug report with patch 0003-Fix-make-custom-port-in-case-encoding-is-f.patch
From: Ludovic Courtès <[email-masked]>
To: Hannes Müller <[email-masked]>
Cc: [email-masked]
Date: Fri, 28 Feb 2025 21:28:39 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

Hannes Müller <[email-masked]> skribis:

> From 72b85f8e6a369e6aef4c6bd6bb233c0cacb80b03 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Hannes=20M=C3=BCller?= <>
> Date: Sat, 21 Dec 2024 16:55:13 +0100
> Subject: [PATCH] Fix make-custom-port in case encoding is #f
>
> * module/ice-9/custom-ports.scm (make-custom-port): Code fails if
> (fluid-ref %default-port-encoding) returns #f. In fact this was the
> case why readline support on MSYS2 failed for guile 3.0.10, ref.
> https://github.com/msys2/MSYS2-packages/issues/5079
> But later used canonicalize-encoding is prepared to handle #f for
> encoding. So allow encoding to also handle this case.

Applied with the simplification below.

Thanks,
Ludo’.

diff --git a/module/ice-9/custom-ports.scm b/module/ice-9/custom-ports.scm
index bc9de8f64..c4376db7b 100644
--- a/module/ice-9/custom-ports.scm
+++ b/module/ice-9/custom-ports.scm
@@ -127,9 +127,7 @@
           (id "custom-port")
           (print (make-default-print #:id id))
           (truncate default-truncate)
-          (encoding (if (string? (fluid-ref %default-port-encoding))
-                        (string->symbol (fluid-ref %default-port-encoding))
-                        (fluid-ref %default-port-encoding)))
+          (encoding (and=> (fluid-ref %default-port-encoding) string->symbol))
           (conversion-strategy (fluid-ref %default-port-conversion-strategy))
           (close-on-gc? #f))
   "Create a custom port whose behavior is determined by the methods passed

Subject: bug report with patch 0003-Fix-make-custom-port-in-case-encoding-is-f.patch
From: Hannes Müller <[email-masked]>
To: [email-masked]
Date: Wed, 25 Dec 2024 12:50:13 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Dear All,

Please review the attached patch.

Thanks,

Hannes

From 72b85f8e6a369e6aef4c6bd6bb233c0cacb80b03 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hannes=20M=C3=BCller?= <>
Date: Sat, 21 Dec 2024 16:55:13 +0100
Subject: [PATCH] Fix make-custom-port in case encoding is #f

* module/ice-9/custom-ports.scm (make-custom-port): Code fails if
(fluid-ref %default-port-encoding) returns #f. In fact this was the
case why readline support on MSYS2 failed for guile 3.0.10, ref.
https://github.com/msys2/MSYS2-packages/issues/5079
But later used canonicalize-encoding is prepared to handle #f for
encoding. So allow encoding to also handle this case.
---
 module/ice-9/custom-ports.scm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/module/ice-9/custom-ports.scm b/module/ice-9/custom-ports.scm
index 6010fd94f..bc9de8f64 100644
--- a/module/ice-9/custom-ports.scm
+++ b/module/ice-9/custom-ports.scm
@@ -127,7 +127,9 @@
           (id "custom-port")
           (print (make-default-print #:id id))
           (truncate default-truncate)
-          (encoding (string->symbol (fluid-ref %default-port-encoding)))
+          (encoding (if (string? (fluid-ref %default-port-encoding))
+                        (string->symbol (fluid-ref %default-port-encoding))
+                        (fluid-ref %default-port-encoding)))
           (conversion-strategy (fluid-ref %default-port-conversion-strategy))
           (close-on-gc? #f))
   "Create a custom port whose behavior is determined by the methods passed
--
2.45.2