[cl-typesetting-devel] Final zlib fix, and CLISP support

Klaus Weidner kw at w-m-p.com
Sat Apr 24 20:30:05 UTC 2004


Hello,

yet another attempt at fixing the annoying zlib issue...

My new approach is the following:

- in cl-pdf.asd, attempt to load the uffi library in an ignore-errors
  clause. If successful, add :uffi to *features*.

- conditionalize the zlib dependent code using #+uffi

- if uffi is not present or zlib is not loaded successfully,
  automatically set *compress-streams* to NIL.

I have verified that this works with CMUCL and SBCL.

But in addition, this change makes cl-pdf work on CLISP, and probably any
other common lisp as well.

cl-typesetting mostly works on CLISP, including my XHTML renderer. There
are still a few portability issues in the table code to resolve that I
haven't tracked down yet, nil values end up in max calls somehow. It's
also complaining about floating point contagion, which may be a useful
pointer towards potential optimizations for other platforms.

BTW, I also removed the #+(or ...) from cl-typesetting.asd, which I
haven't included in this patch. I think it is inappropriate anyway since
that code should run on any common lisp.

Marc, can you please verify if this patch breaks compatibility for
LispWorks? If it works, I strongly suggest adding it. I assume most
people would rather have a working system without compression rather than
obscure error messages...

-Klaus
-------------- next part --------------
diff -urN -x *.fas -x *.lib orig/cl-pdf/cl-pdf.asd cl-pdf/cl-pdf.asd
--- orig/cl-pdf/cl-pdf.asd	Tue Apr 13 08:44:12 2004
+++ cl-pdf/cl-pdf.asd	Sat Apr 24 14:45:11 2004
@@ -6,7 +6,13 @@
 
 (in-package asdf)
 
-#+(or allegro lispworks cmu sbcl openmcl mcl scl)
+#-uffi
+(ignore-errors
+  (print "Trying to load UFFI:")
+  (asdf:operate 'asdf:load-op :uffi)
+  (pushnew :uffi cl:*features*)
+  (print "UFFI loaded."))
+
 (defsystem :cl-pdf
   :name "cl-pdf"
   :author "Marc Battyani <marc.battyani at fractalconcept.com>"
@@ -32,5 +38,5 @@
 	       (:file "text" :depends-on ("pdf-base"))
 	       (:file "bar-codes" :depends-on ("pdf-geom"))
 	       (:file "chart" :depends-on ("text" "pdf-geom")))
-  :depends-on (:uffi)
   )
+
diff -urN -x *.fas -x *.lib orig/cl-pdf/init.lisp cl-pdf/init.lisp
--- orig/cl-pdf/init.lisp	Mon Feb  9 14:39:42 2004
+++ cl-pdf/init.lisp	Sat Apr 24 12:32:45 2004
@@ -6,6 +6,10 @@
 
 (defvar *zlib-loaded* nil)
 
+#-uffi
+(setf *compress-streams* nil)
+
+#+uffi
 (defun find-zlib-path ()
   (uffi:find-foreign-library
    "libz"
@@ -13,6 +17,7 @@
    :drive-letters '("C" "D" "E")
    :types '("so" "a" "dll" "dylib")))
 
+#+uffi
 (defun load-zlib (&optional force)
   (when force (setf *zlib-loaded* nil))
   (unless *zlib-loaded*
@@ -23,16 +28,10 @@
 	    (uffi:load-foreign-library zlib-path
 				       :module "zlib" 
 				       :supporting-libraries '("c"))
-	    (uffi:def-function ("compress" c-compress)
-		((dest (* :unsigned-char))
-		 (destlen (* :long))
-		 (source :cstring)
-		 (source-len :long))
-	      :returning :int
-	      :module "zlib")
 	    (setf *zlib-loaded* t *compress-streams* t))
 	  (progn
 	    (warn "Unable to load zlib. Disabling compression.")
 	    (setf *compress-streams* nil))))))
 
+#+uffi
 (load-zlib)
diff -urN -x *.fas -x *.lib orig/cl-pdf/zlib.lisp cl-pdf/zlib.lisp
--- orig/cl-pdf/zlib.lisp	Fri Jan 30 10:31:48 2004
+++ cl-pdf/zlib.lisp	Sat Apr 24 14:37:15 2004
@@ -6,6 +6,16 @@
 
 ;Adapted from an UFFI example
 
+#+uffi
+(uffi:def-function ("compress" c-compress)
+    ((dest (* :unsigned-char))
+     (destlen (* :long))
+     (source :cstring)
+     (source-len :long))
+  :returning :int
+  :module "zlib")
+
+#+uffi
 (defun compress-string (source)
   "Returns two values: array of bytes containing the compressed data
  and the numbe of compressed bytes"


More information about the cl-typesetting-devel mailing list