guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.0-219-ga42d7


From: Ludovic Courtès
Subject: [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.0-219-ga42d797
Date: Wed, 27 Apr 2011 18:35:31 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=a42d79711b2366861cf4e6fa884eae709617121d

The branch, stable-2.0 has been updated
       via  a42d79711b2366861cf4e6fa884eae709617121d (commit)
      from  d84783a80c186b0b13e3aeb206384bb198bf41e6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit a42d79711b2366861cf4e6fa884eae709617121d
Author: Ludovic Courtès <address@hidden>
Date:   Wed Apr 27 20:34:08 2011 +0200

    Gracefully handle unterminated UTF-8 sequences instead of hitting an 
`assert'.
    
    * libguile/ports.c (get_codepoint): Return EILSEQ when OUTPUT_SIZE == 0.
    
    * test-suite/tests/ports.test ("string ports"): Add 2 tests for
      unterminated sequences.

-----------------------------------------------------------------------

Summary of changes:
 libguile/ports.c            |   14 +++++++++-----
 test-suite/tests/ports.test |   14 ++++++++++++++
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/libguile/ports.c b/libguile/ports.c
index 6e0ae6c..b5ad95e 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -1174,6 +1174,10 @@ get_codepoint (SCM port, scm_t_wchar *codepoint,
        output_size = sizeof (utf8_buf) - output_left;
     }
 
+  if (SCM_UNLIKELY (output_size == 0))
+    /* An unterminated sequence.  */
+    err = EILSEQ;
+
   if (SCM_UNLIKELY (err != 0))
     {
       /* Reset the `iconv' state.  */
@@ -1190,11 +1194,11 @@ get_codepoint (SCM port, scm_t_wchar *codepoint,
         input encoding errors.)  */
     }
   else
-    /* Convert the UTF8_BUF sequence to a Unicode code point.  */
-    *codepoint = utf8_to_codepoint (utf8_buf, output_size);
-
-  if (SCM_LIKELY (err == 0))
-    update_port_lf (*codepoint, port);
+    {
+      /* Convert the UTF8_BUF sequence to a Unicode code point.  */
+      *codepoint = utf8_to_codepoint (utf8_buf, output_size);
+      update_port_lf (*codepoint, port);
+    }
 
   *len = bytes_consumed;
 
diff --git a/test-suite/tests/ports.test b/test-suite/tests/ports.test
index c933724..d4924fe 100644
--- a/test-suite/tests/ports.test
+++ b/test-suite/tests/ports.test
@@ -531,6 +531,20 @@
        (read-char -> #\μ)
        (read-char -> eof)))
 
+    (test-decoding-error (206 187 206) "UTF-8" 'error
+      ;; Unterminated sequence.
+      (tests
+       (read-char -> #\λ)
+       (read-char -> error)
+       (read-char -> eof)))
+
+    (test-decoding-error (206 187 206) "UTF-8" 'substitute
+      ;; Unterminated sequence.
+      (tests
+       (read-char -> #\λ)
+       (read-char -> #\?)
+       (read-char -> eof)))
+
     (test-decoding-error (255 65 66 67) "UTF-8" 'error
       (tests
        ;; `peek-char' should repeatedly raise an error.


hooks/post-receive
-- 
GNU Guile



reply via email to

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