--- cl-plplot-0.6.0.orig/cl-plplot.asd
+++ cl-plplot-0.6.0/cl-plplot.asd
@@ -1,5 +1,5 @@
 ;;;;
-;;;; Copyright (c) 2010 Hazen P. Babcock
+;;;; Copyright (c) 2006 Hazen P. Babcock
 ;;;;
 ;;;; Permission is hereby granted, free of charge, to any person obtaining a copy 
 ;;;; of this software and associated documentation files (the "Software"), to 
@@ -23,7 +23,7 @@
 ;;;;
 ;;;; cl-plplot system declaration
 ;;;;
-;;;; hazen 6/10
+;;;; hazen 6/06
 ;;;;
 
 (in-package #:cl-user)
@@ -36,8 +36,8 @@
 
 (defsystem #:cl-plplot
   :name "cl-plplot"
-  :author "Hazen Babcock <hbabcock@mac.com>"
-  :version "0.5.0"
+  :author "Hazen Babcock <hbabcockos1@mac.com>"
+  :version "0.2.0"
   :licence "MIT"
   :description "Interface to the PLplot Scientific Plotting Library"
   :components 
@@ -69,48 +69,3 @@
 		 (:file "3D-window" :depends-on ("window")))
     :depends-on (:src/system)))
   :depends-on (:cffi))
-
-(defsystem #:plplot-examples
-  :name "plplot-examples"
-  :author "Hazen Babcock <hbabcock@mac.com>"
-  :version "0.1.0"
-  :licence "MIT"
-  :description "PLplot standard examples in Lisp"
-  :components 
-  ((:module
-    :src/examples
-    :components ((:file "plplot-examples")
-                 (:file "x01l" :depends-on ("plplot-examples"))
-                 (:file "x02l" :depends-on ("plplot-examples"))
-                 (:file "x03l" :depends-on ("plplot-examples"))
-                 (:file "x04l" :depends-on ("plplot-examples"))
-                 (:file "x05l" :depends-on ("plplot-examples"))
-                 (:file "x06l" :depends-on ("plplot-examples"))
-                 (:file "x07l" :depends-on ("plplot-examples"))
-                 (:file "x08l" :depends-on ("plplot-examples"))
-                 (:file "x09l" :depends-on ("plplot-examples"))
-                 (:file "x10l" :depends-on ("plplot-examples"))
-                 (:file "x11l" :depends-on ("plplot-examples"))
-                 (:file "x12l" :depends-on ("plplot-examples"))
-                 (:file "x13l" :depends-on ("plplot-examples"))
-                 (:file "x14l" :depends-on ("plplot-examples"))
-                 (:file "x15l" :depends-on ("plplot-examples"))
-                 (:file "x16l" :depends-on ("plplot-examples"))
-                 (:file "x17l" :depends-on ("plplot-examples"))
-                 (:file "x18l" :depends-on ("plplot-examples"))
-                 (:file "x19l" :depends-on ("plplot-examples"))
-;                 (:file "x20l" :depends-on ("plplot-examples")) ; Requires cl-png
-                 (:file "x21l" :depends-on ("plplot-examples")) ; SBCL specific NAN handling?
-                 (:file "x22l" :depends-on ("plplot-examples"))
-                 (:file "x23l" :depends-on ("plplot-examples"))
-                 (:file "x24l" :depends-on ("plplot-examples")) ; Requires unicode handling.
-                 (:file "x25l" :depends-on ("plplot-examples"))
-                 (:file "x26l" :depends-on ("plplot-examples"))
-                 (:file "x27l" :depends-on ("plplot-examples"))
-                 (:file "x28l" :depends-on ("plplot-examples"))
-                 (:file "x29l" :depends-on ("plplot-examples")) ; Can trigger floating point exceptions.
-                 (:file "x30l" :depends-on ("plplot-examples"))
-                 (:file "x31l" :depends-on ("plplot-examples"))
-                 (:file "x32l" :depends-on ("plplot-examples")))))
-  :depends-on (:cl-plplot))
-
--- cl-plplot-0.6.0.orig/README.txt
+++ cl-plplot-0.6.0/README.txt
@@ -2,20 +2,9 @@
 ; The Common Lisp / CFFI based interface to the PLplot Scientific Plotting 
 ; Library.
 ;
-; hazen 08/10
+; hazen 2/08
 ;
 
-;;; 08-08-10 
-
-Going forward from release 0.6.0 I'm simply going to be trying to keep the
-Lisp binding in sync with the PLplot library (cl-plplot-system). Due to time 
-constraints, and also because I do not actually use it myself enough to have 
-good ideas about what does and does not work, I'm not planning on any further
-updates to my attempt to make a more Lispish interface to PLplot (cl-plplot).
-
-
-;;; Older
-
 This is in fact two packages, one is a "low-level" package (cl-plplot-system) 
 that contains the interface to the large and hairy plplot API, and the other is
 a (hopefully) easy to use front end (cl-plplot). It was written and tested
@@ -65,8 +54,7 @@
 	be added as desired.
 
 The file system-examples.lisp contains some examples of how you might directly 
-use the functions in cl-plplot-system. Also, src/examples/ contains Lisp
-versions of all the standard PLplot examples. Other useful resources are the 
+use the functions in cl-plplot-system. Other useful resources are the 
 documentation that comes with plplot, the examples that come with plplot, the
 (admittedly somewhat sparse) comments in api.lisp & possibly plplot.h. You 
 should be aware the cl-plplot-system exports lots and lots of symbols 
--- cl-plplot-0.6.0.orig/debian/cl-plplot.doc-base
+++ cl-plplot-0.6.0/debian/cl-plplot.doc-base
@@ -0,0 +1,13 @@
+Document: cl-plplot
+Title: CL-PLplot User Manual
+Author: Hazen P. Babcock
+Abstract: User manual for the CL-PLplot library which
+ provides an interface for Common Lisp to the plplot library.
+Section: Science/Data Analysis
+
+Format: PDF
+Files: /usr/share/doc/cl-plplot/cl-plplot-manual.pdf.gz
+
+Format: HTML
+Index: /usr/share/doc/cl-plplot/cl-plplot-manual.html
+Files: /usr/share/doc/cl-plplot/cl-plplot-manual.html
--- cl-plplot-0.6.0.orig/debian/prerm
+++ cl-plplot-0.6.0/debian/prerm
@@ -0,0 +1,24 @@
+#!/bin/sh
+# prerm script for cl-plplot
+
+set -e
+
+case "$1" in
+    remove|upgrade|deconfigure)
+	unregister-common-lisp-source cl-plplot
+	;;
+
+    failed-upgrade)
+	;;
+
+    *)
+        echo "prerm called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+#DEBHELPER#
+
+exit 0
+
+
--- cl-plplot-0.6.0.orig/debian/test.lisp
+++ cl-plplot-0.6.0/debian/test.lisp
@@ -0,0 +1,66 @@
+;; tests for checking whether the cl-plplot interface works
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(require 'asdf)
+
+(pushnew "./" asdf:*central-registry* :test #'equal)
+(asdf:operate 'asdf:load-source-op :cl-plplot)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defpackage :cl-plplot-test
+  (:use :common-lisp :cl-plplot :cl-plplot-system)
+  (:export :plot-sys :plot-win))
+
+(in-package :cl-plplot-test)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defparameter gdev "null")
+
+(defun my-make-array (dims)
+  (make-array dims :initial-element 0.0 :element-type 'float))
+
+(defun my-make-vector (dim init-fn)
+  (let ((vec (make-array dim :initial-element 0.0 :element-type 'float)))
+    (dotimes (i dim)
+      (setf (aref vec i) (funcall init-fn i)))
+    vec))
+
+(defun plot-sys ()
+  (plsdev gdev)
+  (plinit)
+  (plcol0 1)
+  (plwid 2)
+  (plenv 0 6 0 36 0 0)
+  (plcol0 2)
+  (pllab "(x)" "(y)" "y = x#u2")
+  (let ((xs (my-make-array 6))
+        (ys (my-make-array 6))
+        (x (my-make-array 60))
+        (y (my-make-array 60)))
+    (dotimes (i 6)
+      (setf (aref xs i) i)
+      (setf (aref ys i) (* i i)))
+    (plcol0 4)
+    (plpoin xs ys 9)
+    (dotimes (i 60)
+      (let ((tmp (* 0.1 i)))
+        (setf (aref x i) tmp)
+        (setf (aref y i) (* tmp tmp))))
+    (plcol0 3)
+    (plline x y))
+  (plend))
+
+(defun plot-win ()
+  (let* ((x (my-make-vector 40 #'(lambda(x) (* 0.1 x))))
+         (y (my-make-vector 40 #'(lambda(x) (* (* 0.1 x) (* 0.1 x)))))
+         (p (new-x-y-plot x y))
+         (w (basic-window)))
+    (add-plot-to-window w p)
+    (render w gdev)))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(plot-sys)
+(plot-win)
--- cl-plplot-0.6.0.orig/debian/dirs
+++ cl-plplot-0.6.0/debian/dirs
@@ -0,0 +1,2 @@
+usr/share/common-lisp/source/cl-plplot/src/
+usr/share/common-lisp/systems/
--- cl-plplot-0.6.0.orig/debian/postinst
+++ cl-plplot-0.6.0/debian/postinst
@@ -0,0 +1,24 @@
+#!/bin/sh
+# postinst script for cl-plplot
+
+set -e
+
+case "$1" in
+    configure)
+	register-common-lisp-source cl-plplot
+	;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+	;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+#DEBHELPER#
+
+exit 0
+
+
--- cl-plplot-0.6.0.orig/debian/copyright
+++ cl-plplot-0.6.0/debian/copyright
@@ -0,0 +1,32 @@
+This package was downloaded from http://common-lisp.net/project/cl-plplot/
+
+Files: *
+Copyright: © 2006-2007 Hazen P. Babcock
+License: MIT
+ Permission is hereby granted, free of charge, to any person obtaining a copy 
+ of this software and associated documentation files (the "Software"), to 
+ deal in the Software without restriction, including without limitation the 
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 
+ sell copies of the Software, and to permit persons to whom the Software is 
+ furnished to do so, subject to the following conditions:
+ .
+ The above copyright notice and this permission notice shall be included in 
+ all copies or substantial portions of the Software.
+ .
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 
+ IN THE SOFTWARE.
+
+Files: debian/*
+Copyright: © 2007 Philipp Benner <philipp@debian.org>
+License: GPL-2+
+ The Debian packaging information is under the GPL, version 2 or later.
+
+On Debian GNU/Linux systems, the complete text of the GNU General
+Public License can be found in `/usr/share/common-licenses/GPL' and the
+complete text of the GNU Lesser General Public License can be found in
+`/usr/share/common-licenses/LGPL'.
--- cl-plplot-0.6.0.orig/debian/examples
+++ cl-plplot-0.6.0/debian/examples
@@ -0,0 +1 @@
+src/examples/*
--- cl-plplot-0.6.0.orig/debian/changelog
+++ cl-plplot-0.6.0/debian/changelog
@@ -0,0 +1,89 @@
+cl-plplot (0.6.0-3.4.201403170602) ucs4-0-0-0; urgency=low
+
+  * UCS auto build. No patches were applied to the original source package
+
+ -- Univention builddaemon <buildd@univention.de>  Mon, 17 Mar 2014 06:02:44 +0100
+
+cl-plplot (0.6.0-3) unstable; urgency=low
+
+  * Fixed override disparities.
+  * Standards version 3.9.2.
+
+ -- Philipp Benner <philipp@debian.org>  Wed, 08 Jun 2011 08:47:16 +0000
+
+cl-plplot (0.6.0-2) unstable; urgency=low
+
+  * Fixed test.pl (Closes: #628321).
+  * Omitting initial article in the description synopsis.
+
+ -- Philipp Benner <philipp@debian.org>  Tue, 07 Jun 2011 19:22:52 +0000
+
+cl-plplot (0.6.0-1) unstable; urgency=low
+
+  * New upstream release.
+  * Removed DM-Upload-Allowed.
+  * Standards version 3.9.1.
+
+ -- Philipp Benner <philipp@debian.org>  Sun, 06 Feb 2011 18:05:35 +0000
+
+cl-plplot (0.5.0-5) unstable; urgency=low
+
+  * Made package compatible with common-lisp-controller 7.0
+    (Closes: #569433).
+
+ -- Philipp Benner <philipp@debian.org>  Fri, 12 Feb 2010 21:48:25 +0000
+
+cl-plplot (0.5.0-4) unstable; urgency=low
+
+  * New maintainer e-mail address.
+  * Standards version 3.8.3.
+  * Using (clc:with-clc-active ...) to load cffi with the new
+    common-lisp-controller (Closes: #518744).
+  * Added README.Debian to show how to load this package
+    with common-lisp-controller >= 6.21.
+
+ -- Philipp Benner <philipp@debian.org>  Fri, 01 Jan 2010 19:08:15 +0000
+
+cl-plplot (0.5.0-3) unstable; urgency=low
+
+  * Fixed command-with-path-in-maintainer-script in prerm and postinst.
+  * Standards version 3.8.0.
+
+ -- Philipp Benner <pbenner@uni-osnabrueck.de>  Sun, 25 Jan 2009 11:50:35 +0000
+
+cl-plplot (0.5.0-2) unstable; urgency=low
+
+  * Changed the doc-base section according to the new policy.
+
+ -- Philipp Benner <pbenner@uni-osnabrueck.de>  Mon, 31 Mar 2008 10:30:33 +0200
+
+cl-plplot (0.5.0-1) unstable; urgency=low
+
+  * New Upstream Version.
+
+ -- Philipp Benner <pbenner@uni-osnabrueck.de>  Sat, 08 Mar 2008 10:11:41 +0100
+
+cl-plplot (0.4.0-3) unstable; urgency=low
+
+  * Now using makeinfo to generate html documentation.
+  * debian/control: Section optional.
+
+ -- Philipp Benner <pbenner@uni-osnabrueck.de>  Wed, 16 Jan 2008 18:56:59 +0100
+
+cl-plplot (0.4.0-2) unstable; urgency=low
+
+  * New maintainer e-mail address.
+  * New GIT repository.
+  * Changed maintainer to Debian Common Lisp Team.
+  * debian/copyright: UTF-8 encoding.
+  * debian/control: Standards version 3.7.3.
+  * debian/control: Added DM-Upload-Allowed: yes.
+  * debian/rules: Removed bashism (Closes: #459057).
+
+ -- Philipp Benner <pbenner@uni-osnabrueck.de>  Mon, 14 Jan 2008 19:04:13 +0100
+
+cl-plplot (0.4.0-1) unstable; urgency=low
+
+  * Initial release (Closes: #451975).
+
+ -- Philipp Benner <mail@philipp-benner.de>  Mon, 26 Nov 2007 11:56:33 +0100
--- cl-plplot-0.6.0.orig/debian/compat
+++ cl-plplot-0.6.0/debian/compat
@@ -0,0 +1 @@
+5
--- cl-plplot-0.6.0.orig/debian/rules
+++ cl-plplot-0.6.0/debian/rules
@@ -0,0 +1,72 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+
+clc-base=usr/share/common-lisp
+clc-src=$(clc-base)/source
+clc-systems=$(clc-base)/systems
+
+build: build-stamp
+build-stamp:
+	dh_testdir
+
+#	# build documentation
+	cd doc && texi2pdf cl-plplot-manual.texinfo
+	cd doc && makeinfo --html --no-split -o cl-plplot-manual.html cl-plplot-manual.texinfo
+
+#	# test the interface
+	@echo "[ Testing the cl-plplot interface... ]"
+	echo '(load "debian/test.lisp")' | sbcl --noinform --disable-debugger
+	@echo "[ Done ]"
+
+	touch $@
+
+clean:
+	dh_testdir
+	dh_testroot
+	rm -f build-stamp
+
+	$(RM) doc/*.aux
+	$(RM) doc/*.cp
+	$(RM) doc/*.cps
+	$(RM) doc/*.fn
+	$(RM) doc/*.html
+	$(RM) doc/*.ky
+	$(RM) doc/*.log
+	$(RM) doc/*.pdf
+	$(RM) doc/*.pg
+	$(RM) doc/*.toc
+	$(RM) doc/*.tp
+	$(RM) doc/*.vr
+
+	dh_clean
+
+install: build
+	dh_testdir
+	dh_testroot
+	dh_clean -k
+	dh_installdirs
+
+	dh_install src/system $(clc-src)/cl-plplot/src/
+	dh_install src/window $(clc-src)/cl-plplot/src/
+	dh_install cl-plplot.asd $(clc-src)/cl-plplot/
+	dh_link $(clc-src)/cl-plplot/cl-plplot.asd $(clc-systems)/cl-plplot.asd
+
+# Build architecture-independent files here.
+binary-indep: build install
+	dh_testdir
+	dh_testroot
+	dh_installchangelogs
+	dh_installdocs
+	dh_installexamples
+	dh_compress
+	dh_fixperms
+	dh_installdeb
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+# Build architecture-dependent files here.
+binary-arch: build install
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install
--- cl-plplot-0.6.0.orig/debian/control
+++ cl-plplot-0.6.0/debian/control
@@ -0,0 +1,25 @@
+Source: cl-plplot
+Section: lisp
+Priority: optional
+Maintainer: Debian Common Lisp Team <pkg-common-lisp-devel@lists.alioth.debian.org>
+Uploaders: Philipp Benner <philipp@debian.org>
+Build-Depends: debhelper (>= 5), texlive-latex-base, texinfo, texi2html,
+ sbcl, cl-cffi, libplplot-dev
+Standards-Version: 3.9.2
+Vcs-Browser: http://git.debian.org/?p=pkg-common-lisp/cl-plplot.git
+Vcs-Git: http://git.debian.org/git/pkg-common-lisp/cl-plplot.git/
+Homepage: http://common-lisp.net/project/cl-plplot/
+
+Package: cl-plplot
+Architecture: all
+Depends: ${misc:Depends}, common-lisp-controller (>= 7.0), cl-cffi, libplplot-dev
+Description: CFFI based interface to the PLplot scientific plotting library
+ Cl-plplot provides a CFFI based interface to the PLplot graphics 
+ library. The PLplot graphics library supports the drawing of many different 
+ types of 2D and 3D graphs using a large variety of output devices including
+ X11, postscript and png. PLplot can also be used to make scaled drawing,
+ or diagrams.
+ .
+ At present, cl-plplot consists of two packages, one is low-level interface 
+ to the PLplot library and the other is high-level plotting interface that 
+ attempts to make using PLplot with Lisp easier.
--- cl-plplot-0.6.0.orig/debian/docs
+++ cl-plplot-0.6.0/debian/docs
@@ -0,0 +1,3 @@
+README.txt
+doc/cl-plplot-manual.pdf
+doc/cl-plplot-manual.html
--- cl-plplot-0.6.0.orig/debian/watch
+++ cl-plplot-0.6.0/debian/watch
@@ -0,0 +1,3 @@
+version=3
+
+http://common-lisp.net/project/cl-plplot/ cl-plplot-(.*)\.tar\.gz
--- cl-plplot-0.6.0.orig/src/system/api.lisp
+++ cl-plplot-0.6.0/src/system/api.lisp
@@ -28,19 +28,6 @@
 (pl-defcfun ("c_pladv" pladv) :void 
 	    (page plint))
 
-(pl-defcfun ("c_plarc" plarc) :void
-	    (x plflt)
-	    (y plflt)
-	    (a plflt)
-	    (b plflt)
-	    (angle1 plflt)
-	    (angle2 plflt)
-	    (fill plbool))
-	    
-;;
-;; This function is deprecated and may dissappear at some point
-;;
-
 (pl-defcfun ("plarrows" plarrows) :void
 	    (u *plflt n)
 	    (v *plflt n)
@@ -52,8 +39,8 @@
 	    (dy plflt))
 
 (defun plvect (u v scale &optional (gridx nil) (gridy nil))
-  (with-plcgrid (plc-grid gridx gridy (array-dimension u 0) (array-dimension u 1))  ; this macro creates the variable plcgrid
-    (pl-plvect u v scale plc-grid)))
+  (with-plcgrid (gridx gridy (array-dimension u 0) (array-dimension u 1))  ; this macro creates the variable plcgrid
+    (pl-plvect u v scale plcgrid)))
 
 (export 'plvect (package-name *package*))
 
@@ -83,19 +70,10 @@
 	(nysub plint))
 
 (pl-defcfun ("c_plbin" plbin) :void 
-	    (nbin plint)
-	    (x *plflt nbin)
-	    (y *plflt nbin)
-	    (opt plint))
-
-(pl-defcfun ("c_plbtime" plbtime) :void
-	    (year *plint 1)
-	    (month *plint 1)
-	    (day *plint 1)
-	    (hour *plint 1)
-	    (min *plint 1)
-	    (sec *plflt 1)
-	    (ctime plflt))
+	(nbin plint)
+	(x *plflt nbin)
+	(y *plflt nbin)
+	(opt plint))
 
 (pl-defcfun ("c_plbop" plbop) :void)
 
@@ -136,19 +114,6 @@
 (pl-defcfun ("c_plcol1" plcol1) :void 
 	    (col1 plflt))
 
-(pl-defcfun ("c_plconfigtime" plconfigtime) :void
-	    (scale plflt)
-	    (offset1 plflt)
-	    (offset2 plflt)
-	    (ccontrol plint)
-	    (ifbtime-offset plbool)
-	    (year plint)
-	    (month plint)
-	    (day plint)
-	    (hour plint)
-	    (min plint)
-	    (sec plflt))
-
 
 ;;
 ;; Coming on this a couple months later I had a pretty hard time figuring
@@ -185,8 +150,8 @@
 ;;
 
 (defun plcont (f kx lx ky ly clevel &optional (gridx nil) (gridy nil))
-  (with-plcgrid (plc-grid gridx gridy (array-dimension f 0) (array-dimension f 1))
-    (pl-plcont f kx lx ky ly clevel plc-grid)))
+  (with-plcgrid (gridx gridy (array-dimension f 0) (array-dimension f 1))
+    (pl-plcont f kx lx ky ly clevel plcgrid)))
 
 (export 'plcont (package-name *package*))
 
@@ -223,8 +188,8 @@
 
 (defun plfcont (f2eval-data nx ny kx lx ky ly clevel &optional (gridx nil) (gridy nil))
   (let ((c-f2eval-data (init-f2eval-data f2eval-data nx ny)))
-    (with-plcgrid (plc-grid gridx gridy nx ny)
-      (pl-plfcont c-f2eval-data nx ny kx lx ky ly clevel plc-grid))
+    (with-plcgrid (gridx gridy nx ny)
+      (pl-plfcont c-f2eval-data nx ny kx lx ky ly clevel plcgrid))
     (free-f2eval-data f2eval-data nx ny)))
 
 (export 'plfcont (package-name *package*))
@@ -247,15 +212,6 @@
 	    (iplsr plint)
 	    (flags plint))
 
-(pl-defcfun ("c_plctime" plctime) :void
-	    (year plint)
-	    (month plint)
-	    (day plint)
-	    (hour plint)
-	    (min plint)
-	    (sec plflt)
-	    (ctime *plflt 1))
-
 (pl-defcfun ("pldid2pc" pldid2pc) :void 
 	(xmin *plflt :in-out)
 	(ymin *plflt :in-out)
@@ -336,24 +292,11 @@
 	    (g *plint 1)
 	    (b *plint 1))
 
-(pl-defcfun ("c_plgcol0a" plgcol0a) :void 
-	    (icol0 plint)
-	    (r *plint 1)
-	    (g *plint 1)
-	    (b *plint 1)
-	    (a *plflt 1))
-
 (pl-defcfun ("c_plgcolbg" plgcolbg) :void 
 	    (r *plint 1)
 	    (g *plint 1)
 	    (b *plint 1))
 
-(pl-defcfun ("c_plgcolbga" plgcolbga) :void 
-	    (r *plint 1)
-	    (g *plint 1)
-	    (b *plint 1)
-	    (a *plflt 1))
-
 (pl-defcfun ("c_plgcompression" plgcompression) :void 
 	    (compression *plint 1))
 
@@ -375,22 +318,17 @@
 	    (p_xmax *plflt 1)
 	    (p_ymax *plflt 1))
 
+(pl-defcfun ("c_plgfci" plgfci) :void 
+	    (pfci *plunicode 1))
+
 (pl-defcfun ("c_plgfam" plgfam) :void 
 	    (p_fam *plint 1)
 	    (p_num *plint 1)
 	    (p_bmax *plint 1))
 
-(pl-defcfun ("c_plgfci" plgfci) :void 
-	    (pfci *plunicode 1))
-
 (pl-defcfun ("c_plgfnam" plgfnam) :void 
 	    (fnam plstr 80))
 
-(pl-defcfun ("c_plgfont" plgfont) :void 
-	    (p_family *plint 1)
-	    (p_style *plint 1)
-	    (p_weight *plint 1))
-
 (pl-defcfun ("c_plglevel" plglevel) :void 
 	    (p_level *plint 1))
 
@@ -404,12 +342,6 @@
 
 (pl-defcfun ("c_plgra" plgra) :void)
 
-(pl-defcfun ("c_plgradient" plgradient) :void 
-	    (n plint)
-	    (x *plflt n)
-	    (y *plflt n)
-	    (angle plflt))
-
 (defun plgriddata (x y z xg yg type data)
   (let ((sx (length x))
 	(sy (length y))
@@ -484,7 +416,6 @@
 	    (nbin plint)
 	    (opt plint))
 
-;; deprecated
 (pl-defcfun ("c_plhls" plhls) :void 
 	    (h plflt)
 	    (l plflt)
@@ -569,7 +500,7 @@
 	    (nlevel plint))
 
 (pl-defcfun ("c_plmkstrm" plmkstrm) :void 
-	    (p_strm *plint 1))
+	    (p_strm plint :out))
 
 (pl-defcfun ("c_plmtex" plmtex) :void 
 	    (side plstr)
@@ -620,15 +551,8 @@
 
 (pl-defcfun ("c_plpat" plpat) :void 
 	    (nlin plint)
-	    (inc *plint n)
-	    (del *plint n))
-
-(pl-defcfun ("c_plpath" plpath) :void
-	    (n plint)
-	    (x1 plflt)
-	    (y1 plflt)
-	    (x2 plflt)
-	    (y2 plflt))
+	    (inc *plint nlin)
+	    (del *plint nlin))
 
 (pl-defcfun ("c_plpoin" plpoin) :void 
 	    (n plint)
@@ -679,18 +603,13 @@
 	    (just plflt)
 	    (text plstr))
 
-
-(pl-defcfun ("c_plrandd" plrandd) :double)
-
 (pl-defcfun ("c_plreplot" plreplot) :void)
 
-;; deprecated
 (pl-defcfun ("c_plrgb" plrgb) :void 
 	    (r plflt)
 	    (g plflt)
 	    (b plflt))
 
-;; deprecated
 (pl-defcfun ("c_plrgb1" plrgb1) :void 
 	    (r plint)
 	    (g plint)
@@ -714,13 +633,6 @@
 	    (b *plint ncol0)
 	    (ncol0 plint))
 
-(pl-defcfun ("c_plscmap0a" plscmap0a) :void 
-	    (r *plint ncol0)
-	    (g *plint ncol0)
-	    (b *plint ncol0)
-	    (a *plflt ncol0)
-	    (ncol0 plint))
-
 (pl-defcfun ("c_plscmap0n" plscmap0n) :void 
 	    (ncol0 plint))
 
@@ -730,13 +642,6 @@
 	    (b *plint ncol1)
 	    (ncol1 plint))
 
-(pl-defcfun ("c_plscmap1a" plscmap1a) :void 
-	    (r *plint ncol1)
-	    (g *plint ncol1)
-	    (b *plint ncol1)
-	    (a *plflt ncol1)
-	    (ncol1 plint))
-
 (pl-defcfun ("c_plscmap1l" plscmap1l) :void 
 	    (itype plbool)
 	    (npts plint)
@@ -744,16 +649,6 @@
 	    (coord1 *plflt npts)
 	    (coord2 *plflt npts)
 	    (coord3 *plflt npts)
-	    (rev *plbool n))
-
-(pl-defcfun ("c_plscmap1la" plscmap1la) :void 
-	    (itype plbool)
-	    (npts plint)
-	    (intensity *plflt npts)
-	    (coord1 *plflt npts)
-	    (coord2 *plflt npts)
-	    (coord3 *plflt npts)
-	    (coord4 *plflt npts)
 	    (rev *plbool npts))
 
 (pl-defcfun ("c_plscmap1n" plscmap1n) :void 
@@ -765,24 +660,11 @@
 	    (g plint)
 	    (b plint))
 
-(pl-defcfun ("c_plscol0a" plscol0a) :void 
-	    (icol0 plint)
-	    (r plint)
-	    (g plint)
-	    (b plint)
-	    (a plflt))
-
 (pl-defcfun ("c_plscolbg" plscolbg) :void 
 	    (r plint)
 	    (g plint)
 	    (b plint))
 
-(pl-defcfun ("c_plscolbga" plscolbga) :void 
-	    (r plint)
-	    (g plint)
-	    (b plint)
-	    (a plflt))
-
 (pl-defcfun ("c_plscolor" plscolor) :void 
 	    (color plint))
 
@@ -821,9 +703,6 @@
 	    (xmax plflt)
 	    (ymax plflt))
 
-(pl-defcfun ("c_plseed" plseed) :void 
-	    (seed plint))
-
 (pl-defcfun ("c_plsesc" plsesc) :void 
 	    (esc plchar))
 
@@ -839,6 +718,7 @@
 ;; is preserved until the next time this function is called
 
 (let ((c-fname nil))
+  
   (defun plsfnam (fname)
     (when c-fname
       (foreign-string-free c-fname))
@@ -850,30 +730,18 @@
 (defcfun ("c_plsfnam" c-plsfnam) :void 
   (fnam plstr))
 
-(pl-defcfun ("c_plsfont" plsfont) :void 
-	    (family plint)
-	    (style plint)
-	    (weight plint))
-
-;;
 ;; Note that for these functions you have no choice when it comes to the fill function,
 ;; as this is what the plplot docs suggest. You can set a user defined exclude function 
 ;; and a user defined contour function by setting my-defined-fn or my-pltr-fn inside
 ;; their respective closures.
-;;
-;; Note also that left, right, bottom and top are ignored as it is (as currently arranged)
-;; impossible to set the pltr-fn to null due to the fact that it is a callback.
-;;
 
 ;; use the no exclusion function or set your own with this closure
 
 (callback-closure defined-fn #'(lambda(x y) (declare (ignore x y)) 1) plint (x plflt) (y plflt))
 
 (defun plshade (a left right bottom top shade-min shade-max sh-cmap sh-color sh-width min-color min-width max-color max-width rectangular &optional (gridx nil) (gridy nil))
-  (if (and gridx gridy)
-      (with-plcgrid (plc-grid gridx gridy (array-dimension a 0) (array-dimension a 1))
-	(pl-plshade a left right bottom top shade-min shade-max sh-cmap sh-color sh-width min-color min-width max-color max-width rectangular plc-grid))
-      (pl-plshade-simple a left right bottom top shade-min shade-max sh-cmap sh-color sh-width min-color min-width max-color max-width rectangular (null-pointer) (null-pointer))))
+  (with-plcgrid (gridx gridy (array-dimension a 0) (array-dimension a 1))
+    (pl-plshade a left right bottom top shade-min shade-max sh-cmap sh-color sh-width min-color min-width max-color max-width rectangular plcgrid)))
 
 (export 'plshade (package-name *package*))
 
@@ -900,37 +768,12 @@
 	    (pltr-fn plfunc)
 	    (pltr-data plpointer))
 
-(pl-defcfun ("c_plshade" pl-plshade-simple) :void
-	    (a **plflt (nx ny))
-	    (nx plint)
-	    (ny plint)
-	    (defined-fn plfunc)
-	    (left plflt)
-	    (right plflt)
-	    (bottom plflt)
-	    (top plflt)
-	    (shade-min plflt)
-	    (shade-max plflt)
-	    (sh-cmap plint)
-	    (sh-color plflt)
-	    (sh-width plint)
-	    (min-color plint)
-	    (min-width plint)
-	    (max-color plint)
-	    (max-width plint)
-	    (plfill-fn plfunc)
-	    (rectangular plbool)
-	    (pltr-fn plpointer)
-	    (pltr-data plpointer))
-
 (defun plshades (a xmin xmax ymin ymax clevel fill-width cont-color cont-width rectangular &optional (gridx nil) (gridy nil))
-  (if (and gridx gridy)
-      (with-plcgrid (plc-grid gridx gridy (array-dimension a 0) (array-dimension a 1))
-	(pl-plshades a xmin xmax ymin ymax clevel fill-width cont-color cont-width rectangular plc-grid))
-      (pl-plshades-simple a xmin xmax ymin ymax clevel fill-width cont-color cont-width rectangular (null-pointer) (null-pointer))))
+  (with-plcgrid (gridx gridy (array-dimension a 0) (array-dimension a 1))
+    (pl-plshades a xmin xmax ymin ymax clevel fill-width cont-color cont-width rectangular plcgrid)))
 
 (export 'plshades (package-name *package*))
-
+    
 (pl-defcfun ("c_plshades" pl-plshades) :void
 	    (a **plflt (nx ny))
 	    (nx plint)
@@ -950,24 +793,6 @@
 	    (pltr-fn plfunc)
 	    (pltr-data plpointer))
 
-(pl-defcfun ("c_plshades" pl-plshades-simple) :void
-	    (a **plflt (nx ny))
-	    (nx plint)
-	    (ny plint)
-	    (defined-fn plfunc)
-	    (xmin plflt)
-	    (xmax plflt)
-	    (ymin plflt)
-	    (ymax plflt)
-	    (clevel *plflt nlevel)
-	    (nlevel plint)
-	    (fill-width plint)
-	    (cont-color plint)
-	    (cont-width plint)
-	    (plfill-fn plfunc)
-	    (rectangular plbool)
-	    (pltr-fn plpointer)
-	    (pltr-data plpointer))
 
 ;; The "friendly" form of this one was deemed to be adequately covered by the above 
 ;; functions, so only the "cffi" version of the function is provided.
@@ -1009,22 +834,11 @@
 ; PLINT max_color, PLINT max_width, 	 void (*fill) (PLINT, PLFLT *, PLFLT *), PLBOOL rectangular, 	 
 ; void (*pltr) (PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer), 	 PLPointer pltr_data
 
-;(pl-defcfun ("c_plsfam" plsfam) :void 
-
-(pl-defcfun ("c_plslabelfunc" plslabelfunc) :void 
-	    (label-fn plfunc)
-	    (label-data plpointer))
-
-(callback-closure label-fn #'(lambda(axis value label length data)
-			       (declare (ignore axis value data))
-			       (lisp-string-to-foreign "not set" label length))					
-		  :void 
-		  (axis plint) (value plflt) (label plstr) (length plint) (data plpointer))
-
-(pl-defcfun ("c_plsmaj" plsmaj) :void
+(pl-defcfun ("c_plsmaj" plsmaj) :void 
 	    (def plflt)
 	    (scale plflt))
 
+
 ;;
 ;; plsmem is broken into three parts:
 ;;
@@ -1087,13 +901,6 @@
 	    (xoff plint)
 	    (yoff plint))
 
-(pl-defcfun ("c_plspal0" plspal0) :void
-	    (filename plstr))
-
-(pl-defcfun ("c_plspal1" plspal1) :void
-	    (filename plstr)
-	    (interpolate plbool))
-
 (pl-defcfun ("c_plspause" plspause) :void 
 	    (pause plbool))
 
@@ -1117,24 +924,6 @@
 	    (nx plint)
 	    (ny plint))
 
-(pl-defcfun ("c_plstransform" plstransform) :void 
-	    (transform-fn plfunc)
-	    (data plpointer))
-
-(callback-closure transform-fn #'(lambda (x y tx ty pltr-data)
-				   (declare (ignore pltr-data))
-				   (setf (mem-aref tx :double) (coerce x 'double-float)
-					 (mem-aref ty :double) (coerce y 'double-float)))
-		  :void 
-		  (x plflt) (y plflt) (tx *plflt) (ty *plflt) (pltr-data plpointer))
-
-;; This is a lame hack to make it easier for the user to reset
-;; PLplots universal coordinate transform function.
-(defun pl-reset-transform ()
-  (c-plstransform (null-pointer) (null-pointer)))
-
-(export 'pl-reset-transform (package-name *package*))
-
 (pl-defcfun ("c_plstripa" plstripa) :void 
 	    (id plint)
 	    (pen plint)
@@ -1189,28 +978,7 @@
 (pl-defcfun ("c_plstripd" plstripd) :void 
 	    (id plint))
 
-(pl-defcfun ("c_plimagefr" pl-plimagefr) :void 
-	    (idata **plflt (nx ny))
-	    (nx plint)
-	    (ny plint)
-	    (xmin plflt)
-	    (xmax plflt)
-	    (ymin plflt)
-	    (ymax plflt)
-	    (zmin plflt)
-	    (zmax plflt)
-	    (valuemin plflt)
-	    (valuemax plflt)
-	    (pltr-fn plfunc)
-	    (pltr-data plpointer))
-
-(defun plimagefr (idata xmin xmax ymin ymax zmin zmax valuemin valuemax &optional (gridx nil) (gridy nil))
-  (with-plcgrid (plc-grid gridx gridy (array-dimension idata 0) (array-dimension idata 1))
-    (pl-plimagefr idata xmin xmax ymin ymax zmin zmax valuemin valuemax plc-grid)))
-
-(export 'plimagefr (package-name *package*))
-
-(pl-defcfun ("c_plimage" plimage) :void 
+(pl-defcfun ("plimage" plimage) :void 
 	    (data **plflt (nx ny))
 	    (nx plint)
 	    (ny plint)
@@ -1227,8 +995,8 @@
 
 (pl-defcfun ("c_plstyl" plstyl) :void 
 	    (nms plint)
-	    (mark *plint n)
-	    (space *plint n))
+	    (mark *plint nms)
+	    (space *plint nms))
 
 (pl-defcfun ("c_plsurf3d" plsurf3d) :void 
 	    (x *plflt nx)
@@ -1240,30 +1008,6 @@
 	    (clevel *plflt nlevel)
 	    (nlevel plint))
 
-;; See x08l.lisp for an example of how to use this function.
-(pl-defcfun ("plfsurf3d" plfsurf3d) :void
-	    (x *plflt nx)
-	    (y *plflt ny)
-	    (zops plpointer)
-	    (zp plpointer)
-	    (nx plint)
-	    (ny plint)
-	    (opt plint)
-	    (clevel *plflt nlevel)
-	    (nlevel plint))
-
-;; These are helper functions for plf... functions, they
-;; return a pointer to a "zops" function.
-(defcfun "plf2ops_c" :pointer)
-(defcfun "plf2ops_grid_c" :pointer)
-(defcfun "plf2ops_grid_row_major" :pointer)
-(defcfun "plf2ops_grid_col_major" :pointer)
-
-(export 'plf2ops-c (package-name *package*))
-(export 'plf2ops-grid-c (package-name *package*))
-(export 'plf2ops-grid-row-major (package-name *package*))
-(export 'plf2ops-grid-col-major (package-name *package*))
-
 (pl-defcfun ("c_plsurf3dl" plsurf3dl) :void 
 	    (x *plflt nx)
 	    (y *plflt ny)
@@ -1307,9 +1051,6 @@
 
 (pl-defcfun ("c_pltext" pltext) :void)
 
-(pl-defcfun ("c_pltimefmt" pltimefmt) :void
-	    (fmt plstr))
-			   
 (pl-defcfun ("c_plvasp" plvasp) :void 
 	    (aspect plflt))
 
@@ -1637,10 +1378,6 @@
 (pl-defcfun ("plgesc" plgesc) :void 
 	    (p_esc *plchar 1))
 
-(pl-defcfun ("pl_cmd" pl-cmd) :void
-	    (op plint)
-	    (ptr plpointer))
-
 ;(defcfun ("pl_cmd" pl-cmd) :void 
 ;	PLINT op, void *ptr
 ;
@@ -1677,8 +1414,12 @@
 	(nx plint)
 	(ny plint))
 
+
+;; Not sure about the utility of this one. f must be an appropriately 
+;; created foreign pointer, such as one created by make-matrix
+
 (pl-defcfun ("plMinMax2dGrid" plminmax2dgrid) :void 
-	    (f **plflt (nx ny))
+	    (f plpointer)
 	    (nx plint)
 	    (ny plint)
 	    (fmax *plflt 1)
--- cl-plplot-0.6.0.orig/src/system/misc.lisp
+++ cl-plplot-0.6.0/src/system/misc.lisp
@@ -43,16 +43,14 @@
 
 (defun check-size (a mx my)
   "checks that p-d has the right dimensions"
-  (and (or (= (array-dimension a 0) mx)
-	   (= (array-dimension a 0) (1+ mx)))
-       (or (= (array-dimension a 1) my)
-	   (= (array-dimension a 1) (1+ my)))))
+  (and (= (array-dimension a 0) mx)
+       (= (array-dimension a 0) my)))
 
 (defun init-plcgrid (pdx pdy mx my)
   "initializes plcgrid given user supplied pdx & pdy, if necessary"
   (cond 
     ((equal (pl-get-pltr-fn) #'pltr0)
-     (values (null-pointer) 'empty-p))
+     (null-pointer))
     ((equal (pl-get-pltr-fn) #'pltr1)
      (if (and (vectorp pdx)
 	      (vectorp pdy)
@@ -64,10 +62,8 @@
 	     (setf y (make-ptr pdy 'plflt #'(lambda(x) (coerce x 'double-float))))
 	     (setf nx (length pdx))
 	     (setf ny (length pdy)))
-	   (values tmp 'vector-p))
-	 (progn
-	   (format t "Array dimensions are wrong for pdx or pdy in init-plcgrid~%")
-	   (values nil nil))))
+	   tmp)
+	 (format t "Array dimensions are wrong for pdx or pdy in init-plcgrid~%")))
     ((equal (pl-get-pltr-fn) #'pltr2)
      (if (and (arrayp pdx)
 	      (arrayp pdy)
@@ -78,60 +74,36 @@
 	     (setf x (make-matrix pdx))
 	     (setf y (make-matrix pdy))
 	     (setf nx (array-dimension pdx 0))
-	     (setf ny (array-dimension pdx 1)))
-	   (values tmp 'matrix-p))
-	 (progn
-	   (format t "Matrix dimensions are wrong for pdx or pdy in init-plcgrid~%")
-	   (values nil nil))))
-    ; this has fewer safeguards...
-    (t (cond
-	 ((and (vectorp pdx)
-	       (vectorp pdy))
-	  (let ((tmp (foreign-alloc 'plcgrid)))
-	    (with-foreign-slots ((x y nx ny) tmp plcgrid)
-	      (setf x (make-ptr pdx 'plflt #'(lambda(x) (coerce x 'double-float))))
-	      (setf y (make-ptr pdy 'plflt #'(lambda(x) (coerce x 'double-float))))
-	      (setf nx (length pdx))
-	      (setf ny (length pdy)))
-	    (values tmp 'vector-p)))
-	 ((and (arrayp pdx)
-	       (arrayp pdy))
-	  (let ((tmp (foreign-alloc 'plcgrid)))
-	    (with-foreign-slots ((x y nx ny) tmp plcgrid)
-	      (setf x (make-matrix pdx))
-	      (setf y (make-matrix pdy))
-	      (setf nx (array-dimension pdx 0))
-	      (setf ny (array-dimension pdy 0)))
-	    (values tmp 'matrix-p)))
-	 ((not pdx)
-	  (values (null-pointer) 'empty-p))
-	 (t
-	  (values pdx 'user-p))))))
+	     (setf ny (array-dimension pdy 0)))
+	   tmp)
+	 (format t "Matrix dimensions are wrong for pdx or pdy in init-plcgrid~%")))
+    (t pdx)))  ; if the user has set the ptr-fn to something else we just pass this through
+               ; on the assumption that they know what they are doing
 
-(defun free-plcgrid (p-grid type)
+(defun free-plcgrid (p-grid)
   "frees the plcgrid structure, if necessary"
   (cond
-    ((equal type 'vector-p)
+    ((equal (pl-get-pltr-fn) #'pltr0)
+     (foreign-free p-grid))
+    ((equal (pl-get-pltr-fn) #'pltr1)
      (progn
        (with-foreign-slots ((x y) p-grid plcgrid)
 	 (foreign-free x)
 	 (foreign-free y))
        (foreign-free p-grid)))
-    ((equal type 'matrix-p)
+    ((equal (pl-get-pltr-fn) #'pltr2)
      (progn
        (with-foreign-slots ((x y nx ny) p-grid plcgrid)
 	 (let ((dims (list nx ny)))
 	   (free-matrix x dims)
 	   (free-matrix y dims)))
-       (foreign-free p-grid)))
-    (t nil)))
+       (foreign-free p-grid)))))
 
-(defmacro with-plcgrid ((plc-grid pdx pdy mx my) &body body)
-  (let ((type (gensym)))
-    `(multiple-value-bind (,plc-grid ,type) (init-plcgrid ,pdx ,pdy ,mx ,my)
-       (when ,plc-grid
-	 ,@body
-	 (free-plcgrid ,plc-grid ,type)))))
+(defmacro with-plcgrid ((pdx pdy mx my) &body body)
+  `(let ((plcgrid (init-plcgrid ,pdx ,pdy ,mx ,my)))
+     (when plcgrid
+       ,@body
+       (free-plcgrid plcgrid))))
 
 
 ;;;
@@ -168,61 +140,3 @@
 
 (export 'pl-null-pointer (package-name *package*))
 
-;;;
-;;; These are the structures for interfacing with the plf... functions
-;;; in PLplot. There are also some macros to make things a little
-;;; easier.
-;;;
-
-(defcstruct plfgrid
-  (f :pointer)
-  (nx :int)
-  (ny :int))
-
-(defcstruct plfgrid2
-  (f :pointer)
-  (nx :int)
-  (ny :int))
-
-(defun is-matrix-p (item)
-  (= (length (array-dimensions item)) 2))
-
-(defun lisp-data-to-foreign (lisp-data)
-  (if (is-matrix-p lisp-data)
-      (make-matrix lisp-data)
-      (make-ptr lisp-data 'plflt (lambda (x) (coerce x 'double-float)))))
-
-(defun create-grid (c-data size-x size-y)
-  (let ((ptr (foreign-alloc 'plfgrid2)))
-    (setf (foreign-slot-value ptr 'plfgrid2 'f) c-data
-	  (foreign-slot-value ptr 'plfgrid2 'nx) size-x
-	  (foreign-slot-value ptr 'plfgrid2 'ny) size-y)
-    ptr))
-  
-(export 'create-grid (package-name *package*))
-
-(defmacro with-foreign-grid ((grid lisp-data size-x size-y) &body body)
-  (let ((c-data (gensym)))
-    `(let* ((,c-data (lisp-data-to-foreign ,lisp-data))
-	    (,grid (create-grid ,c-data ,size-x ,size-y)))
-       (unwind-protect
-	    ,@body
-	 (progn
-	   (if (is-matrix-p ,lisp-data)
-	       (cl-plplot-system::free-matrix ,c-data
-					      (list
-					       (array-dimension ,lisp-data 0)
-					       (array-dimension ,lisp-data 1)))
-	       (foreign-free ,c-data))
-	   (foreign-free ,grid))))))
-
-(export 'with-foreign-grid (package-name *package*))
-
-(defmacro with-foreign-matrix ((lisp-matrix foreign-matrix) &body body)
-  `(let ((,foreign-matrix (make-matrix ,lisp-matrix)))
-     (unwind-protect
-	  ,@body
-       (free-matrix ,foreign-matrix (list (array-dimension ,lisp-matrix 0)
-					  (array-dimension ,lisp-matrix 1))))))
-
-(export 'with-foreign-matrix (package-name *package*))
--- cl-plplot-0.6.0.orig/src/system/defcfun.lisp
+++ cl-plplot-0.6.0/src/system/defcfun.lisp
@@ -166,16 +166,8 @@
 	     (multiple-value-bind (name dir) (ptr-name-dir args)
 	       (cond
 		 ((= dir p-in)
-		  `((,(elt args 2) (if (eq ,(elt args 0) 'null)
-				       0
-				       (length ,(elt args 0))))
-		    (,name (if (eq ,(elt args 0) 'null)
-			       (null-pointer)
-			       (make-ptr ,(elt args 0) ,cffi-type ,convf-in)))))
-
-;		  `((,(elt args 2) (length ,(elt args 0)))
-;		    (,name (make-ptr ,(elt args 0) ,cffi-type ,convf-in))))
-
+		  `((,(elt args 2) (length ,(elt args 0)))
+		    (,name (make-ptr ,(elt args 0) ,cffi-type ,convf-in))))
 		 ((= dir p-in-out)
 		  `(,name (make-ptr (vector ,(elt args 0)) ,cffi-type ,convf-in)))
 		 ((= dir p-out)
@@ -201,15 +193,7 @@
 
 (defun std-freeing (args)
   "Standard freeing-function"
-;  `(foreign-free ,(c-name args)))
-  (multiple-value-bind (name dir) (ptr-name-dir args)
-    (declare (ignore name))
-    (cond
-      ((= dir p-in)
-       `(unless (eq ,(elt args 0) 'null)
-	  (foreign-free ,(c-name args))))
-      (t
-       `(foreign-free ,(c-name args))))))
+  `(foreign-free ,(c-name args)))
 
 (defun ptr-name (x)
   "Returns name of pointer to type x (used for 'standard' types)"
--- cl-plplot-0.6.0.orig/src/window/window.lisp
+++ cl-plplot-0.6.0/src/window/window.lisp
@@ -194,15 +194,13 @@
 	(setf *current-extended-color-table* (default-extended-color-table))))
   (initialize-extended-color-table *current-extended-color-table*))
 
-(defun render-window (a-window device filename size-x size-y external-pointer &optional want-mouse?)
+(defun render-window (a-window device filename size-x size-y &optional want-mouse?)
   "This handles drawing the window & optionally returns the coordinates of a mouse click."
   ;; setup window
   (setup-window a-window device filename size-x size-y)
 
   ;; start plotting
   (plinit)
-  (when external-pointer
-    (pl-cmd 26 external-pointer))
   (unwind-protect
        (progn
 	 (pladv 0)
@@ -243,26 +241,23 @@
 (defmethod get-cursor ((a-window window) device &key (size-x 600) (size-y 500))
   "Get the location (in window coordinates) of the next mouse click. In
    order to do this the window must first be rendered so that the user has
-   something to click on. Note that this cannot be used with those drivers
-   that draw into a user supplied area such as ext-cairo."
-  (let ((mouse (render-window a-window device nil size-x size-y nil t)))
+   something to click on."
+  (let ((mouse (render-window a-window device nil size-x size-y t)))
     (when mouse
       (values (elt mouse 8) (elt mouse 9)))))
 
-(defgeneric render (window device &key filename size-x size-y external-pointer))
+(defgeneric render (window device &key filename size-x size-y))
 
-(defmethod render ((a-window window) device &key filename (size-x 600) (size-y 500) external-pointer)
+(defmethod render ((a-window window) device &key filename (size-x 600) (size-y 500))
   "Renders a window and it associated plots and labels using device.
     device: a string naming a plplot graphical device such as 'xwin'.
     filename: where to save the graph for file based devices.
     size-x: the size of the window in x (pixels).
     size-y: the size of the window in y (pixels).
-    external-pointer: if the plplot graphical device is one that will
-       plot into an external user supplied plotting area, then you can
-       pass info about that plotting area in using this variable.
    If you are using cl-plplot in a multi-threaded environment you should
-   thread lock prior to calling render."
-  (render-window a-window device filename size-x size-y external-pointer))
+   thread lock prior to calling render, as the PLplot library only handles
+   rendering one plot at a time."
+  (render-window a-window device filename size-x size-y))
 
 ;;;;
 ;;;; Copyright (c) 2006 Hazen P. Babcock
--- cl-plplot-0.6.0.orig/src/window/3D-window.lisp
+++ cl-plplot-0.6.0/src/window/3D-window.lisp
@@ -92,15 +92,13 @@
 		   :altitude altitude
 		   :azimuth azimuth)))
 
-(defun render-3D-window (a-window device filename size-x size-y external-pointer)
+(defun render-3D-window (a-window device filename size-x size-y)
   "This handles drawing a 3D window."
   ;; setup window
   (setup-window a-window device filename size-x size-y)
 
   ;; start plotting
   (plinit)
-  (when external-pointer
-    (pl-cmd 26 external-pointer))
   (unwind-protect
        (progn
 	 ; setup viewport
@@ -149,18 +147,16 @@
 	 (render-axis-labels (z-axis a-window)))
     (plend)))
 
-(defmethod render ((a-window 3D-window) device &key filename (size-x 600) (size-y 500) external-pointer)
+(defmethod render ((a-window 3D-window) device &key filename (size-x 600) (size-y 500))
   "Renders a 3D-window and it associated plots and labels using device.
     device: a string naming a plplot graphical device such as 'xwin'.
     filename: where to save the graph for file based devices.
     size-x: the size of the window in x (pixels).
     size-y: the size of the window in y (pixels).
-    external-pointer: if the plplot graphical device is one that will
-       plot into an external user supplied plotting area, then you can
-       pass info about that plotting area in using this variable.
    If you are using cl-plplot in a multi-threaded environment you should
-   thread lock prior to calling render."
-  (render-3D-window a-window device filename size-x size-y external-pointer))
+   thread lock prior to calling render, as the PLplot library only handles
+   rendering one plot at a time."
+  (render-3D-window a-window device filename size-x size-y))
 
 ;;;;
 ;;;; Copyright (c) 2006 Hazen P. Babcock
--- cl-plplot-0.6.0.orig/src/examples/system-examples.lisp
+++ cl-plplot-0.6.0/src/examples/system-examples.lisp
@@ -108,8 +108,7 @@
 (defun shade-plot ()
   (plsdev gdev)
   (plinit)
-;  (plenv -1 1 -1 1 0 0)
-  (plenv 0.0 35.0 0.0 45.0 0 0)
+  (plenv -1 1 -1 1 0 0)
   (plshades (example-matrix 35 45 #'example-func-1) -1 1 -1 1 (make-levels 20 -1.0 1.0) 2 1 1 nil)
   (plcol0 1)
   (plbox "bcnst" 0 0 "bcnstv" 0 0)
