;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: strings.lisp,v 1.2 2002/10/14 01:51:15 kevin Exp $
+;;;; $Id: strings.lisp,v 1.3 2002/10/14 03:07:41 kevin Exp $
;;;;
;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
#+sbcl
(let ((array-def (gensym)))
`(let ((,array-def (list 'sb-alien:array 'char ,size)))
- (eval `(alien:cast (sb-alien:make-alien ,,array-def)
+ (eval `(sb-alien:cast (sb-alien:make-alien ,,array-def)
,(if ,unsigned
'(* (sb-alien:unsigned 8))
'(* (sb-alien:signed 8)))))))
;; Modified from CMUCL's source to handle non-null terminated strings
#+cmu
-(defun cmucl-naturalize-cstring (sap &key
- length
- (null-terminated-p t))
+(defun cmucl-naturalize-cstring (sap &key length (null-terminated-p t))
(declare (type system:system-area-pointer sap))
(locally
(declare (optimize (speed 3) (safety 0)))
result)))
#+sbcl
-(defun sbcl-naturalize-cstring (sap &key
- length
- (null-terminated-p t))
+(defun sbcl-naturalize-cstring (sap &key length (null-terminated-p t))
(declare (type sb-sys:system-area-pointer sap))
(locally
(declare (optimize (speed 3) (safety 0)))
(when null-terminated-p
(loop
for offset of-type fixnum upfrom 0
- until (zerop (system:sap-ref-8 sap offset))
+ until (zerop (sb-sys:sap-ref-8 sap offset))
finally (return offset)))))
(if length
(if (and null-terminated-length
(let ((result (make-string length)))
(sb-kernel:copy-from-system-area sap 0
result (* sb-vm:vector-data-offset
- sb-vm:word-bits)
- (* length sb-vm:byte-bits))
+ sb-vm:n-word-bits)
+ (* length sb-vm:n-byte-bits))
result)))