<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.3.2">
</HEAD>
<BODY>
Making the following change to the function buffer-read-ucs4-string (and a similar one <BR>
in ucs1-string makes all the tests green on a unicode-enabled SBCL 9.5.<BR>
<BR>
I debugged it right down to this routine so I'm pretty sure I've got it correct; and the <BR>
tests are exhaustive. But it is fairly mystifying to me how the original code (that <BR>
I have commented out) got in there in so VASTLY different a form.<BR>
<BR>
Can someone tell me that either SBCL really, really change the call interface of that <BR>
the original code pasted from somewhere erroneously? I would love to have a fix<BR>
to this problem....but I'm a little befuddled.<BR>
<BR>
<BR>
<BR>
#+(and sbcl sb-unicode)<BR>
(defun buffer-read-ucs4-string (bs byte-length)<BR>
"Read a UCS4 string."<BR>
(declare (optimize (speed 3) (safety 0))<BR>
(type buffer-stream bs)<BR>
(type fixnum byte-length))<BR>
(let ((position (buffer-stream-position bs)))<BR>
(setf (buffer-stream-position bs) (+ position byte-length))<BR>
(let ((res (make-string (/ byte-length 4) :element-type 'character)))<BR>
;; (format t "READ UCS4 STRING ABOUT TO do a copy-ub8-from-system-aread ")<BR>
;; (format t "Postion: ~A dest off ~A len ~A" position<BR>
;; ;; This is a nasty little bit of work; it means<BR>
;; ;; that (obviously) depending on what we are writing into we'll get different things...<BR>
;; ;; but the str-copy is somehow doing the correct thing... I don't think<BR>
;; ;; the statement is matching the "make-string" statement above!<BR>
;; sb-vm:vector-data-offset <BR>
;; byte-length)<BR>
;; #+#.(sleepycat::new-style-copy-p)<BR>
;; (sb-kernel:copy-ub8-from-system-area <BR>
;; (sb-alien:alien-sap (buffer-stream-buffer bs))<BR>
;; (* position sb-vm:n-byte-bits)<BR>
;; res <BR>
;; (* sb-vm:vector-data-offset sb-vm:n-word-bits)<BR>
;; (* byte-length sb-vm:n-byte-bits))<BR>
#+#.(sleepycat::new-style-copy-p)<BR>
(sb-kernel:copy-ub8-from-system-area <BR>
(sb-alien:alien-sap (buffer-stream-buffer bs))<BR>
position <BR>
res <BR>
;; This changing this to zero solves the problem; the real question<BR>
;; must be that the make-string above matches <BR>
;; sb-vm:vector-data-offset<BR>
0<BR>
byte-length)<BR>
#-#.(sleepycat::new-style-copy-p)<BR>
(sb-kernel:copy-from-system-area <BR>
(sb-alien:alien-sap (buffer-stream-buffer bs))<BR>
(* position sb-vm:n-byte-bits)<BR>
res <BR>
(* sb-vm:vector-data-offset sb-vm:n-word-bits)<BR>
(* byte-length sb-vm:n-byte-bits))<BR>
res)))
</BODY>
</HTML>