r10123: fix for openmcl
[uffi.git] / src / strings.lisp
index dc42fa3f58fa26a462a2f6c0afba2fcc11ca73da..c63d943e2c8e3496fb89056de87df03bb722bab1 100644 (file)
@@ -157,10 +157,11 @@ that LW/CMU automatically converts strings from c-calls."
        nil
      (if (eq ,locale :none)
         (fast-native-to-string ,obj ,length)
-       (excl:native-to-string
-       ,obj 
-       ,@(when length (list :length length))
-       :truncate (not ,null-terminated-p))))
+       (values
+       (excl:native-to-string
+        ,obj 
+        ,@(when length (list :length length))
+        :truncate (not ,null-terminated-p)))))
   #+lispworks
   `(if (fli:null-pointer-p ,obj)
        nil
@@ -188,7 +189,10 @@ that LW/CMU automatically converts strings from c-calls."
   #+mcl
   `(if (ccl:%null-ptr-p ,obj)
      nil
-     (ccl:%get-cstring ,obj 0 ,@(if length (list length) nil)))
+    #+(and mcl (not openmcl)) (ccl:%get-cstring ,obj 0 ,@(if length (list length) nil))
+    #+openmcl ,@(if length
+                   `((ccl:%str-from-ptr ,obj ,length))
+                   `((ccl:%get-cstring ,obj))))
   )
 
 
@@ -344,4 +348,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 (schar str i) (code-char (uffi:deref-array s '(:array :byte) i))))))
+        (setf (schar str i) (code-char (uffi:deref-array s '(:array :unsigned-byte) i))))))