From 65379cce4f7ae822c68fead2769472434ba528f7 Mon Sep 17 00:00:00 2001 From: jbielman Date: Sun, 12 Jun 2005 16:25:16 +0800 Subject: [PATCH] Initialize foreign strings to empty in case the foreign function Initialize foreign strings to empty in case the foreign function calling mechanism doesn't work. Prevents the Lisp from running off trying to convert MOST-POSITIVE-FIXNUM bytes into a string. --- tests/funcall.lisp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/funcall.lisp b/tests/funcall.lisp index 70043f5..ce4cbf1 100644 --- a/tests/funcall.lisp +++ b/tests/funcall.lisp @@ -58,6 +58,7 @@ (deftest funcall.string.2 (with-foreign-ptr-as-string (s 100) + (setf (mem-ref s :char) 0) (foreign-funcall "strcpy" :pointer s string "Hello" :pointer) (foreign-funcall "strcat" :pointer s string ", world!" :pointer)) "Hello, world!") @@ -68,16 +69,19 @@ ;; to ints when passed as variable arguments. (deftest funcall.varargs.char (with-foreign-ptr-as-string (s 100) + (setf (mem-ref s :char) 0) (foreign-funcall "sprintf" :pointer s string "%c" :int 65 :void)) "A") (deftest funcall.varargs.int (with-foreign-ptr-as-string (s 100) + (setf (mem-ref s :char) 0) (foreign-funcall "sprintf" :pointer s string "%d" :int 1000 :void)) "1000") (deftest funcall.varargs.long (with-foreign-ptr-as-string (s 100) + (setf (mem-ref s :char) 0) (foreign-funcall "sprintf" :pointer s string "%ld" :long 131072 :void)) "131072") @@ -86,12 +90,14 @@ ;; and CMU CL on Darwin/ppc. (deftest funcall.varargs.double (with-foreign-ptr-as-string (s 100) + (setf (mem-ref s :char) 0) (foreign-funcall "sprintf" :pointer s string "%.2f" :double (coerce pi 'double-float) :void)) "3.14") (deftest funcall.varargs.string (with-foreign-ptr-as-string (s 100) + (setf (mem-ref s :char) 0) (foreign-funcall "sprintf" :pointer s string "%s, %s!" string "Hello" string "world" :void)) "Hello, world!") -- 2.11.4.GIT