[elephant-devel] Possible bug fix for the SBCL unicode problem..

Robert L. Read read at robertlread.net
Sun Dec 4 03:19:26 UTC 2005


Making the following change to the function buffer-read-ucs4-string (and
a similar one 
in ucs1-string makes all the tests green on a unicode-enabled SBCL 9.5.

I debugged it right down to this routine so I'm pretty sure I've got it
correct; and the 
tests are exhaustive.  But it is fairly mystifying to me how the
original code (that 
I have commented out) got in there in so VASTLY different a form.

Can someone tell me that either SBCL really, really change the call
interface of that 
the original code pasted from somewhere erroneously?  I would love to
have a fix
to this problem....but I'm a little befuddled.



#+(and sbcl sb-unicode)
(defun buffer-read-ucs4-string (bs byte-length)
  "Read a UCS4 string."
  (declare (optimize (speed 3) (safety 0))
	   (type buffer-stream bs)
	   (type fixnum byte-length))
  (let ((position (buffer-stream-position bs)))
    (setf (buffer-stream-position bs) (+ position byte-length))
    (let ((res (make-string (/ byte-length 4) :element-type
'character)))
;;       (format t "READ UCS4 STRING ABOUT TO do a copy-ub8-from-system-
aread ")
;;       (format t "Postion: ~A dest off ~A len ~A"        position
;; 	      ;; This is a nasty little bit of work; it means
;; 	      ;; that (obviously) depending on what we are writing into
we'll get different things...
;; 	      ;; but the str-copy is somehow doing the correct thing... I
don't think
;; 	      ;; the statement is matching the "make-string" statement
above!
;; 	      sb-vm:vector-data-offset 
;; 	      byte-length)
;; #+#.(sleepycat::new-style-copy-p)
;;       (sb-kernel:copy-ub8-from-system-area 
;;        (sb-alien:alien-sap (buffer-stream-buffer bs))
;;        (* position sb-vm:n-byte-bits)
;;        res 
;;        (* sb-vm:vector-data-offset sb-vm:n-word-bits)
;;        (* byte-length sb-vm:n-byte-bits))
#+#.(sleepycat::new-style-copy-p)
       (sb-kernel:copy-ub8-from-system-area 
        (sb-alien:alien-sap (buffer-stream-buffer bs))
        position 
        res 
;; This changing this to zero solves the problem; the real question
;; must be that the make-string above matches 
;;        sb-vm:vector-data-offset
	0
        byte-length)
#-#.(sleepycat::new-style-copy-p)
      (sb-kernel:copy-from-system-area 
       (sb-alien:alien-sap (buffer-stream-buffer bs))
       (* position sb-vm:n-byte-bits)
       res 
       (* sb-vm:vector-data-offset sb-vm:n-word-bits)
       (* byte-length sb-vm:n-byte-bits))
      res)))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/elephant-devel/attachments/20051203/efb2b1a0/attachment.html>


More information about the elephant-devel mailing list