From: Kevin M. Rosenberg Date: Tue, 13 Apr 2004 20:17:51 +0000 (+0000) Subject: r8999: add new function FOREIGN-STRING-LENGTH X-Git-Tag: v1.6.1~123 X-Git-Url: http://git.kpe.io/?p=uffi.git;a=commitdiff_plain;h=5ee29e2a72598eb6db2063510b2ea6046945b70c r8999: add new function FOREIGN-STRING-LENGTH --- diff --git a/ChangeLog b/ChangeLog index 0b99ac9..4c50f90 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2004-04-13 Kevin Rosenberg (kevin@rosenberg.net) + * str/string.lisp: Add new FOREIGN-STRING-LENGTH + 2003-08-15 Kevin Rosenberg (kevin@rosenberg.net) * Added with-cast-pointer and def-foreign-var (patches submitted by Edi Weitz). diff --git a/debian/changelog b/debian/changelog index d4f6e8a..111c267 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +cl-uffi (1.4.8-1) unstable; urgency=low + + * New upstream + + -- Kevin M. Rosenberg Tue, 13 Apr 2004 14:13:04 -0600 + cl-uffi (1.4.7-1) unstable; urgency=low * Fix fast-native-to-string on 16-bit wide char Allegro diff --git a/src/package.lisp b/src/package.lisp index 54af538..05f7e4f 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -62,6 +62,7 @@ #:convert-to-foreign-string #:allocate-foreign-string #:with-foreign-string + #:foreign-string-length ;; function call #:def-function diff --git a/src/strings.lisp b/src/strings.lisp index e4d6701..0585d43 100644 --- a/src/strings.lisp +++ b/src/strings.lisp @@ -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 ,ptr) + #-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))