r9006: fix on allegro
[uffi.git] / src / strings.lisp
index 5fdbc89188037c2bc261cc60544e24289e1f2d88..4671925661c8b67298d5879a233524e08e9619f7 100644 (file)
@@ -223,6 +223,15 @@ that LW/CMU automatically converts strings from c-calls."
   `(new-ptr ,size)
   )
 
+(defun foreign-string-length (foreign-string)
+  #+allegro `(ff:foreign-strlen ,foreign-string)
+  #-allegro
+  `(loop with size = 0
+    until (char= (deref-array ,ptr '(:array :unsigned-char) size) #\Null)
+    do (incf size)
+    finally return size))
+
+
 (defmacro with-foreign-string ((foreign-string lisp-string) &body body)
   (let ((result (gensym)))
     `(let* ((,foreign-string (convert-to-foreign-string ,lisp-string))
@@ -329,4 +338,4 @@ that LW/CMU automatically converts strings from c-calls."
   (let* ((len (or len (strlen s)))
          (str (make-string len)))
       (dotimes (i len str)
-        (setf (aref str i) (uffi:deref-array s '(:array :char) i)))))
+        (setf (schar str i) (code-char (uffi:deref-array s '(:array :byte) i))))))