summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
e6419ce)
* 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-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
+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
(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))
#+allegro
(let ((fe (gensym "FE-"))
(ife (gensym "IFE-"))
#+allegro
(let ((fe (gensym "FE-"))
(ife (gensym "IFE-"))
+ (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)
+ (,nt ,null-terminate))
- (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-"))
+ (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)
+ (,nt ,null-terminate))
- (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))))
(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
+ (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/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)
(defsystem uffi
:name "uffi"
:author "Kevin Rosenberg <kevin@rosenberg.net>"
(defsystem uffi
:name "uffi"
:author "Kevin Rosenberg <kevin@rosenberg.net>"
: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"