X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/clg/blobdiff_plain/d32ee07b551a7059bed097616bc4a8eac2c42700..4be970ba51e2527f3c2da82ef699b9104bf179f3:/gffi/basic-types.lisp diff --git a/gffi/basic-types.lisp b/gffi/basic-types.lisp index d1da957..b2b0a89 100644 --- a/gffi/basic-types.lisp +++ b/gffi/basic-types.lisp @@ -20,7 +20,7 @@ ;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -;; $Id: basic-types.lisp,v 1.2 2006-06-08 13:24:25 espen Exp $ +;; $Id: basic-types.lisp,v 1.3 2006-09-06 09:45:26 espen Exp $ (in-package "GFFI") @@ -580,7 +580,8 @@ (defun utf8-length (string) ((< char-code #x1FFFFF) 4))))) (defun encode-utf8-string (string &optional location) - (let ((location (or location (allocate-memory (utf8-length string))))) + (let* ((len (utf8-length string)) + (location (or location (allocate-memory len)))) (loop for char across string for i from 0 @@ -599,8 +600,8 @@ (defun encode-utf8-string (string &optional location) ((< char-code #x80) (setf (ref-byte location i) char-code)) ((< char-code #x800) (encode 11)) ((< char-code #x10000) (encode 16)) - ((< char-code #x200000) (encode 21)))) - finally (setf (ref-byte location (1+ i)) 0)) + ((< char-code #x200000) (encode 21))))) + (setf (ref-byte location len) 0) location)) (defun decode-utf8-string (c-string)