X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=src%2Fstrings.lisp;h=4f2eae3c7e430456dd4355b8462fddedefe58eba;hb=refs%2Ftags%2Fv2.1.0;hp=f5b5634e411447429dc1ce37a187324fd03da778;hpb=1a33d3d010d00a5864402dfe5acde16cdddce02f;p=uffi.git diff --git a/src/strings.lisp b/src/strings.lisp index f5b5634..4f2eae3 100644 --- a/src/strings.lisp +++ b/src/strings.lisp @@ -144,7 +144,8 @@ that LW/CMU automatically converts strings from c-calls." (string (locally (declare (optimize (speed 3) (safety 0))) - (let* ((fe (or encoding *default-foreign-encoding*)) + (let* ((fe (or encoding *default-foreign-encoding* + sb-impl::*default-external-format*)) (ife (when fe (lookup-foreign-encoding fe)))) (if ife (let* ((octets (sb-ext:string-to-octets str :external-format ife)) @@ -154,7 +155,7 @@ that LW/CMU automatically converts strings from c-calls." (setq storage (sb-alien:cast storage (* (sb-alien:unsigned 8)))) (dotimes (i size) (declare (fixnum i)) - (setf (sb-alien:deref storage i) (svref octets i))) + (setf (sb-alien:deref storage i) (aref octets i))) ;; terminate with 2 nulls, maybe needed for some encodings (setf (sb-alien:deref storage size) 0) (setf (sb-alien:deref storage (1+ size)) 0) @@ -395,10 +396,10 @@ that LW/CMU automatically converts strings from c-calls." (defun foreign-string-length (foreign-string) #+allegro `(ff:foreign-strlen ,foreign-string) #-allegro - `(loop with size = 0 - until (char= (deref-array ,foreign-string '(:array :unsigned-char) size) #\Null) - do (incf size) - finally return size)) + `(loop + for size from 0 + until (char= (deref-array ,foreign-string '(:array :unsigned-char) size) #\Null) + finally (return size))) (defmacro with-foreign-string ((foreign-string lisp-string &optional encoding)