Automated commit for upstream build of version 2.1.0
[uffi.git] / src / strings.lisp
index f5b5634e411447429dc1ce37a187324fd03da778..4f2eae3c7e430456dd4355b8462fddedefe58eba 100644 (file)
@@ -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)