guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 02/07: Invalid charset at EOF does not cause decoding er


From: Andy Wingo
Subject: [Guile-commits] 02/07: Invalid charset at EOF does not cause decoding error
Date: Wed, 3 Mar 2021 11:09:27 -0500 (EST)

wingo pushed a commit to branch master
in repository guile.

commit 5ea8c69e9153a970952bf6f0b32c4fad6a28e839
Author: Andy Wingo <wingo@pobox.com>
AuthorDate: Wed Mar 3 16:05:07 2021 +0100

    Invalid charset at EOF does not cause decoding error
    
    * libguile/ports.c (peek_iconv_codepoint): If the input has no bytes,
    there's little point in raising a decoding error here.  Therefore remove
    the needless iconv acquisition, harmonising with suspendable-ports.
    * test-suite/tests/ports.test ("port-encoding"): Update test to include
    some input so that the exception gets raised.
---
 libguile/ports.c            | 11 ++---------
 test-suite/tests/ports.test |  2 +-
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/libguile/ports.c b/libguile/ports.c
index 65823f9..c25c207 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -1,4 +1,4 @@
-/* Copyright 1995-2001,2003-2004,2006-2019
+/* Copyright 1995-2001,2003-2004,2006-2019,2021
      Free Software Foundation, Inc.
 
    This file is part of Guile.
@@ -1948,14 +1948,7 @@ peek_iconv_codepoint (SCM port, SCM *buf, size_t *cur, 
size_t *len)
           *len = input_size;
           if (input_size == 0)
             /* Normal EOF.  */
-            {
-              /* Make sure iconv descriptors have been opened even if
-                 there were no bytes, to be sure that a decoding error
-                 is signalled if the encoding itself was invalid.  */
-              scm_port_acquire_iconv_descriptors (port, NULL, NULL);
-              scm_port_release_iconv_descriptors (port);
-              return EOF;
-            }
+            return EOF;
 
           /* EOF found in the middle of a multibyte character. */
           if (scm_is_eq (SCM_PORT (port)->conversion_strategy,
diff --git a/test-suite/tests/ports.test b/test-suite/tests/ports.test
index 9aa486e..cd87640 100644
--- a/test-suite/tests/ports.test
+++ b/test-suite/tests/ports.test
@@ -1314,7 +1314,7 @@
 
   (pass-if-exception "set-port-encoding!, wrong encoding"
     exception:miscellaneous-error
-    (let ((p (open-input-string "")))
+    (let ((p (open-input-string "q")))
       (set-port-encoding! p "does-not-exist")
       (read p)))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]