Version 2.0.0 for new API foreign encoding functions debian-2.0.0-1 v2.0.0
authorKevin Rosenberg <kevin@rosenberg.net>
Tue, 20 Apr 2010 18:31:37 +0000 (12:31 -0600)
committerKevin Rosenberg <kevin@rosenberg.net>
Tue, 20 Apr 2010 18:31:37 +0000 (12:31 -0600)
* uffi.asdf: Update version so libraries using UFFI
  can depend on verson 2.0 for new foreign encoding
  conversions.
* src/i18n.lisp: Add null-terminate to STRING-TO-OCTETS
* tests/i18n.lisp: Add new tests

ChangeLog
debian/changelog
debian/source/format [new file with mode: 0644]
src/i18n.lisp
tests/i18n.lisp
uffi.asd

index 109b61316a3caee48e471a9cecaf84163ba5927c..c138d54049188e4109e9bf0c23c9da764d362986 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-04-20 Kevin Rosenberg <kevin@rosenberg.net>
+       * Version 2.0.0
+       * uffi.asdf: Update version so libraries using UFFI
+       can depend on verson 2.0 for new foreign encoding
+       conversions.
+       * src/i18n.lisp: Add null-terminate to STRING-TO-OCTETS
+       * tests/i18n.lisp: Add new tests
+
 2010-02-11 Kevin Rosenberg <kevin@rosenberg.net>
        * Version 1.8.6
        * src/strings.lisp: Standards on :encoding keyword
 2010-02-11 Kevin Rosenberg <kevin@rosenberg.net>
        * Version 1.8.6
        * src/strings.lisp: Standards on :encoding keyword
index d503c7ebbf0e476276c3530192b244e84d31287a..6749dc3dbf69d0f83108a1d315e466dbe2617eb4 100644 (file)
@@ -1,3 +1,10 @@
+cl-uffi (2.0.0-1) unstable; urgency=low
+
+  * Update upstream version for ASDF version dependency checking
+  * Switch to dpkg-source 3.0 (quilt) format
+
+ -- Kevin M. Rosenberg <kmr@debian.org>  Tue, 20 Apr 2010 12:11:34 -0600
+
 cl-uffi (1.8.6-1) unstable; urgency=low
 
   * New upstream
 cl-uffi (1.8.6-1) unstable; urgency=low
 
   * New upstream
diff --git a/debian/source/format b/debian/source/format
new file mode 100644 (file)
index 0000000..163aaf8
--- /dev/null
@@ -0,0 +1 @@
+3.0 (quilt)
index ca2c1b439f392b176012041e730bbc7dce339689..2de8234f9f659cdef49de31608428368801caca9 100644 (file)
@@ -58,7 +58,7 @@ encoding.")
 (defun lookup-foreign-encoding (normalized)
   (cdr (assoc normalized *foreign-encoding-mapping* :test 'eql)))
 
 (defun lookup-foreign-encoding (normalized)
   (cdr (assoc normalized *foreign-encoding-mapping* :test 'eql)))
 
-(defmacro string-to-octets (str &key encoding)
+(defmacro string-to-octets (str &key encoding null-terminate)
   (declare (ignorable encoding))
   #-(or allegro lispworks openmcl sbcl)
   (map-into (make-array (length str) :element-type '(unsigned-byte 8))
   (declare (ignorable encoding))
   #-(or allegro lispworks openmcl sbcl)
   (map-into (make-array (length str) :element-type '(unsigned-byte 8))
@@ -67,31 +67,44 @@ encoding.")
   #+allegro
   (let ((fe (gensym "FE-"))
         (ife (gensym "IFE-"))
   #+allegro
   (let ((fe (gensym "FE-"))
         (ife (gensym "IFE-"))
-        (s (gensym "STR-")))
+        (s (gensym "STR-"))
+        (nt (gensym "NT-")))
     `(let* ((,fe (or ,encoding *default-foreign-encoding*))
             (,ife (when ,fe (lookup-foreign-encoding ,fe)))
     `(let* ((,fe (or ,encoding *default-foreign-encoding*))
             (,ife (when ,fe (lookup-foreign-encoding ,fe)))
-            (,s ,str))
+            (,s ,str)
+            (,nt ,null-terminate))
        (values
         (if ,ife
        (values
         (if ,ife
-            (excl:string-to-octets ,s :external-format ,ife :null-terminate nil)
-            (excl:string-to-octets ,s :null-terminate nil)))))
+            (excl:string-to-octets ,s :external-format ,ife :null-terminate ,nt)
+            (excl:string-to-octets ,s :null-terminate ,nt)))))
 
   #+(or lispworks openmcl)
   ;; simply reading each char-code from the LENGTH of string handles multibyte characters
   ;; just fine in testing LW 6.0 and CCL 1.4
 
   #+(or lispworks openmcl)
   ;; simply reading each char-code from the LENGTH of string handles multibyte characters
   ;; just fine in testing LW 6.0 and CCL 1.4
-  (map-into (make-array (length str) :element-type '(unsigned-byte 8))
-            #'char-code str)
+  (let ((len (gensym "LEN-"))
+        (out (gensym "OUT-")))
+    `(let ((,len (length ,str)))
+       (if (,null-terminate)
+           (progn
+             (let ((,out (map-into (make-array (1+ ,len) :element-type '(unsigned-byte 8))
+                                   #'char-code ,str)))
+               (setf (char ,out ,len) 0)
+               ,out))
+           (map-into (make-array len :element-type '(unsigned-byte 8))
+                     #'char-code str))))
 
   #+sbcl
   (let ((fe (gensym "FE-"))
         (ife (gensym "IFE-"))
 
   #+sbcl
   (let ((fe (gensym "FE-"))
         (ife (gensym "IFE-"))
-        (s (gensym "STR-")))
+        (s (gensym "STR-"))
+        (nt (gensym "NT-")))
     `(let* ((,fe (or ,encoding *default-foreign-encoding*))
             (,ife (when ,fe (lookup-foreign-encoding ,fe)))
     `(let* ((,fe (or ,encoding *default-foreign-encoding*))
             (,ife (when ,fe (lookup-foreign-encoding ,fe)))
-            (,s ,str))
+            (,s ,str)
+            (,nt ,null-terminate))
        (if ,ife
        (if ,ife
-           (sb-ext:string-to-octets ,s :external-format ,ife)
-           (sb-ext:string-to-octets ,s))))
+           (sb-ext:string-to-octets ,s :external-format ,ife :null-terminate ,nt)
+           (sb-ext:string-to-octets ,s :null-terminate ,nt))))
 
 )
 
 
 )
 
index 911e41fe9d65667c13b849892d086e5f0abcaa2e..af99be987a3679d1f839e1521e12370ce00f9aaf 100644 (file)
     (uffi:string-to-octets "abc")
   #(97 98 99))
 
     (uffi:string-to-octets "abc")
   #(97 98 99))
 
-;; Below is UTF-8 encoded, 27 octets / 20 lisp characters
 (deftest :i18n/sto/4
 (deftest :i18n/sto/4
+    (uffi:string-to-octets "abc" :null-terminate t)
+  #(97 98 99 0))
+
+;; Below is UTF-8 encoded, 27 octets / 20 lisp characters
+(deftest :i18n/sto/5
     (uffi:string-to-octets "Iñtërnâtiônàlizætiøn" :encoding :utf-8)
   #(73 195 177 116 195 171 114 110 195 162 116 105 195 180 110 195 160 108 105 122 195 166 116 105 195 184 110))
 
     (uffi:string-to-octets "Iñtërnâtiônàlizætiøn" :encoding :utf-8)
   #(73 195 177 116 195 171 114 110 195 162 116 105 195 180 110 195 160 108 105 122 195 166 116 105 195 184 110))
 
-(deftest :i18n/sto/5
+(deftest :i18n/sto/6
+    (uffi:string-to-octets "Iñtërnâtiônàlizætiøn" :encoding :utf-8 :null-terminate t)
+  #(73 195 177 116 195 171 114 110 195 162 116 105 195 180 110 195 160 108 105 122 195 166 116 105 195 184 110 0))
+
+(deftest :i18n/lsto/1
     (length (uffi:string-to-octets "Iñtërnâtiônàlizætiøn" :encoding :utf-8))
   27)
 
     (length (uffi:string-to-octets "Iñtërnâtiônàlizætiøn" :encoding :utf-8))
   27)
 
+(deftest :i18n/lsto/2
+    (length (uffi:string-to-octets "Iñtërnâtiônàlizætiøn" :encoding :utf-8 :null-terminate t))
+  28)
+
 (deftest :i18n/feoc/1
     (uffi:foreign-encoded-octet-count "")
   0)
 (deftest :i18n/feoc/1
     (uffi:foreign-encoded-octet-count "")
   0)
index d5bf7f700a4becf58e4641e058aa2af6567fb9b4..5eea1a8a47751792a9c61c8d93d96735e28d360f 100644 (file)
--- a/uffi.asd
+++ b/uffi.asd
@@ -18,7 +18,7 @@
 (defsystem uffi
   :name "uffi"
   :author "Kevin Rosenberg <kevin@rosenberg.net>"
 (defsystem uffi
   :name "uffi"
   :author "Kevin Rosenberg <kevin@rosenberg.net>"
-  :version "1.7.2"
+  :version "2.0.0"
   :maintainer "Kevin M. Rosenberg <kmr@debian.org>"
   :licence "Lessor Lisp General Public License"
   :description "Universal Foreign Function Library for Common Lisp"
   :maintainer "Kevin M. Rosenberg <kmr@debian.org>"
   :licence "Lessor Lisp General Public License"
   :description "Universal Foreign Function Library for Common Lisp"