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

On MSYS2 readline support failed, ref.
https://github.com/msys2/MSYS2-packages/issues/5079

It turns out (fluid-ref %default-port-encoding) returns #f. The later code
is prepared to handle #f for encoding, but not the assignment to encoding.
---
 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

