1.0.45.14: fix handling of multibyte character encoding errors
authorNikodemus Siivola <nikodemus@random-state.net>
Fri, 11 Feb 2011 16:59:56 +0000 (16:59 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Fri, 11 Feb 2011 16:59:56 +0000 (16:59 +0000)
 In encodings defined using DEFINE-MULTIBYTE-ENCODING, if there is no
 translation for the character, report the size as 0 -- replacements
 get their size accounted for elsewhere.

 Fixes lp#713063.

NEWS
src/code/external-formats/mb-util.lisp
tests/external-format.impure.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index fd5dbc1..85c2bf7 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@
 changes relative to sbcl-1.0.45:
   * bug fix: local tail calls to DYNAMIC-EXTENT functions can no longer cause
     lifetime analysis to overwrite closed-over variables (lp#681092).
+  * bug fix: encoding errors from some multibyte external formats such as EUC-JP
+    were not handled correctly (lp#713063).
 
 changes in sbcl-1.0.45 relative to sbcl-1.0.44:
   * enhancement: ~/ and ~user/ are treated specially in pathnames.
index 9a82d45..5569a9f 100644 (file)
          ;; replacement character, so we hardcode the preferred
          ;; replacement here.
          #\?
-         (mb-char-len (or (,ucs-to-mb (char-code byte)) -1))
+         (block size
+           (mb-char-len (or (,ucs-to-mb (char-code byte))
+                            (return-from size 0))))
          (let ((mb (,ucs-to-mb bits)))
            (if (null mb)
                (external-format-encoding-error stream byte)
index 11586b9..bd521f8 100644 (file)
        (handler-case
            (octets-to-string octets :external-format :bad-format)
          (error (e) e))))))
+
+(with-test (:name :lp713063)
+  (with-open-file (f *test-path*
+                     :direction :output
+                     :external-format '(:euc-jp :replacement #\?)
+                     :if-exists :supersede)
+    (write-string (make-string 3 :initial-element #\horizontal_bar) f))
+  (assert (equal "???"
+                 (with-open-file (f *test-path*
+                                    :direction :input
+                                    :external-format :euc-jp)
+                   (read-line f))))
+  (delete-file *test-path*))
 \f
 ;;;; success
index f3c41e2..cc5e097 100644 (file)
@@ -20,4 +20,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.45.13"
+"1.0.45.14"