[cl-pdf-devel] patch for contrib/zlib-clisp.lisp
Yaroslav Kavenchuk
kavenchuk at jenty.by
Thu Nov 17 15:12:41 UTC 2005
Marc Battyani wrote:
> Thanks.
>
> Is this for windows only or portable on every clisp supported OS ?
>
Portable, but not work.
This work (all tests cl-typesettings passed) - sorry
--- zlib-clisp.lisp.orig Mon Oct 10 11:36:10 2005
+++ zlib-clisp.lisp Thu Nov 17 15:11:15 2005
@@ -35,6 +35,7 @@
#-CLISP (error "This code should be loaded in CLISP.")
+#-:zlib
(use-package "FFI")
#|
@@ -49,6 +50,7 @@
(:return-type ffi:int))
|#
+#-:zlib
(defvar *zlib-path*
(or #+WIN32 "zlib.dll"
;; TODO how to deal with cygwin (#+UNIX on MS-Windows)? -- it
wants zlib.dll
@@ -58,7 +60,9 @@
"Set this variable to point to the location of the zlib library
(libz.so or zlib.dll) on your system.")
+#-:zlib
(defvar *zlib*)
+#-:zlib
(unless (and (boundp '*zlib*)
(ffi:validp *zlib*))
(setq *zlib* (user::foreign-library *zlib-path*)))
@@ -73,6 +77,7 @@
;; ffi:c-string (or ffi:c-array-ptr character), since it receives the
;; buffer length as an extra argument.
+#-:zlib
(ffi:def-lib-call-out zlib-compress-string *zlib*
(:name "compress")
(:arguments (dest ffi:c-pointer :in)
@@ -82,6 +87,7 @@
(:return-type ffi:int)
(:language :stdc))
+#-:zlib
(defun compress-string (source)
"Compress the string SOURCE. Returns an array of bytes
representing the compressed data."
@@ -97,6 +103,13 @@
(ffi:offset dest 0 `(c-array uint8 ,actual))
(error "zlib error, code ~d" status))))))
+#+:zlib
+(defun compress-string (source)
+ (zlib:compress
+ (if (typep source 'string)
+ (ext:convert-string-to-bytes source
+ ext:*default-file-encoding*)
+ source)))
(defmethod write-object ((obj pdf-stream) &optional root-level &aux
compressed)
#+(or Lispworks allegro CMU CLISP)
Thanks!
--
WBR, Yaroslav Kavenchuk.
More information about the cl-pdf-devel
mailing list