From f49e847742f3b30b1a911c2a2e59e1adb1c3cc2f Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Mon, 5 May 2003 15:39:25 +0000 Subject: [PATCH] r4808: *** empty log message *** --- INSTALL | 6 + LICENSE | 20 +++ Makefile | 10 ++ README | 14 +++ TODO | 23 ++++ debian/.#changelog.1.27 | 162 +++++++++++++++++++++++++ debian/changelog | 263 ++++++++++++++++++++++++++++++++++++++++ debian/compat | 1 + debian/control | 15 +++ debian/copyright | 28 +++++ debian/docs | 2 + debian/postinst | 44 +++++++ debian/prerm | 40 ++++++ debian/rules | 81 +++++++++++++ libreadline-cl.c | 128 +++++++++++++++++++ libreadline.lisp | 46 +++++++ packages.lisp | 40 ++++++ readline.asd | 29 +++++ readline.lisp | 72 +++++++++++ 19 files changed, 1024 insertions(+) create mode 100644 INSTALL create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README create mode 100644 TODO create mode 100644 debian/.#changelog.1.27 create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/docs create mode 100755 debian/postinst create mode 100755 debian/prerm create mode 100755 debian/rules create mode 100644 libreadline-cl.c create mode 100644 libreadline.lisp create mode 100644 packages.lisp create mode 100644 readline.asd create mode 100644 readline.lisp diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..5690b1d --- /dev/null +++ b/INSTALL @@ -0,0 +1,6 @@ +Requirements: + + * GNU Readline (libreadline.so.4) + * UFFI + +Run make, and you are set. At least almost. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..90819a0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +;; Copyright (c) 2003 Nikodemus Siivola +;; +;; 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. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..826ad8a --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +VERSION=0.1 +NAME=cl-readline-$(VERSION) + +all: libreadline-cl.o + +all: + gcc -fPIC -DPIC -c libreadline-cl.c -o libreadline-cl.o + gcc -shared libreadline-cl.o -lreadline4 -o libreadline-cl.so + + diff --git a/README b/README new file mode 100644 index 0000000..1dbf41d --- /dev/null +++ b/README @@ -0,0 +1,14 @@ +CL-READLINE 0.1 + + CL-READLINE is a simple UFFI-based wrapper for the GNU Readline + library. + + CL-READLINE has been tested on Debian GNU/Linux under SBCl, SBCL-MT + and CMUCL. Other platforms and UFFI compatible implementations should + work, but may require tweaking. + + To use: + + (asdf:oos 'asdf:load-op 'readline) + (rl:readline :prompt "> ") + diff --git a/TODO b/TODO new file mode 100644 index 0000000..256debc --- /dev/null +++ b/TODO @@ -0,0 +1,23 @@ +- Keybindings + +- Maintain several concurrent completion lists, + with easy switch back and forth. + +- Keybinding to switch between completion lists. + +- File-based completion list. + +- Better history control + +- 8bit fix + +- REPL + +- Paren-matching settable despite .inputrc + +- Hidden characters. (Password-style) + +- Lightweight version based on alternate library with + more permissive license. + +- Samrter installation diff --git a/debian/.#changelog.1.27 b/debian/.#changelog.1.27 new file mode 100644 index 0000000..8bc6fd0 --- /dev/null +++ b/debian/.#changelog.1.27 @@ -0,0 +1,162 @@ +cl-kmrcl (1.22-1) unstable; urgency=low + + * Improve xml-utils when an expected tag is not found. + + -- Kevin M. Rosenberg Tue, 3 Dec 2002 02:32:37 -0700 + +cl-kmrcl (1.21-1) unstable; urgency=low + + * Remore allegroserve dependant modules + + -- Kevin M. Rosenberg Sun, 24 Nov 2002 13:13:05 -0700 + +cl-kmrcl (1.20.2-1) unstable; urgency=low + + * Remove 'load-compiled-op from .asd file + + -- Kevin M. Rosenberg Fri, 8 Nov 2002 09:41:22 -0700 + +cl-kmrcl (1.20.1-1) unstable; urgency=low + + * Add with-each-file-line & with-each-stream-line to export list, fix + bugs in those functions + + -- Kevin M. Rosenberg Wed, 7 Nov 2002 14:52:39 -0700 + +cl-kmrcl (1.20-1) unstable; urgency=low + + * Add with-each-stream-line, with-each-file-line + * Use gensyms in other functions to avoid variable capture + + -- Kevin M. Rosenberg Wed, 6 Nov 2002 13:33:39 -0700 + +cl-kmrcl (1.19.1-1) unstable; urgency=low + + * Made indent-spaces reslient to non-numeric parameter + + -- Kevin M. Rosenberg Mon, 4 Nov 2002 11:33:03 -0700 + +cl-kmrcl (1.19-1) unstable; urgency=low + + * New upstream + + -- Kevin M. Rosenberg Sun, 3 Nov 2002 13:08:44 -0700 + +cl-kmrcl (1.18-1) unstable; urgency=low + + * New upstream + + -- Kevin M. Rosenberg Mon, 21 Oct 2002 11:51:17 -0600 + +cl-kmrcl (1.17-1) unstable; urgency=low + + * Fix buggy kmrcl.asd file + + -- Kevin M. Rosenberg Mon, 21 Oct 2002 11:51:17 -0600 + +cl-kmrcl (1.16-1) unstable; urgency=low + + * Rework handling of aserve requirement + + -- Kevin M. Rosenberg Sun, 20 Oct 2002 20:37:01 -0600 + +cl-kmrcl (1.15-1) unstable; urgency=low + + * Add depends: for common-lisp-controller and cl-aserve + + -- Kevin M. Rosenberg Sat, 19 Oct 2002 19:59:02 -0600 + +cl-kmrcl (1.14-1) unstable; urgency=low + + * ml-class.lisp: Add XHTML format + * web-utils.lisp: Add standard headers for xml, html, xhtml, + added user-agent-ie-p + + -- Kevin M. Rosenberg Thu, 17 Oct 2002 16:25:31 -0600 + +cl-kmrcl (1.13-1) unstable; urgency=low + + * ml-class.lisp: Add ie-xmlrefformat for Internet Explorer's idea of + a link in XML. Add SCL compatibility. + + -- Kevin M. Rosenberg Tue, 15 Oct 2002 23:23:57 -0600 + +cl-kmrcl (1.12-1) unstable; urgency=low + + * Fix .asd file if CL-ASERVE is not installed + + -- Kevin M. Rosenberg Tue, 15 Oct 2002 16:46:47 -0600 + +cl-kmrcl (1.11-1) unstable; urgency=low + + * Change .asd file for ASERVE require + + -- Kevin M. Rosenberg Tue, 15 Oct 2002 16:38:28 -0600 + +cl-kmrcl (1.10-1) unstable; urgency=low + + * ml-class.lisp: Fix package name + + -- Kevin M. Rosenberg Mon, 14 Oct 2002 14:48:43 -0600 + +cl-kmrcl (1.9-1) unstable; urgency=low + + * ml-class.lisp: Get package name from object + + -- Kevin M. Rosenberg Mon, 14 Oct 2002 13:23:23 -0600 + +cl-kmrcl (1.8-1) unstable; urgency=low + + * ml-class.lisp: Add defgeneric for generic functions + + -- Kevin M. Rosenberg Mon, 14 Oct 2002 09:11:08 -0600 + +cl-kmrcl (1.7-1) unstable; urgency=low + + * Push :kmrcl onto features + + -- Kevin M. Rosenberg Sun, 13 Oct 2002 20:47:45 -0600 + +cl-kmrcl (1.6-1) unstable; urgency=low + + * ml-class.lisp: Fix CMUCL compatibility, add SBCL compatibility + + -- Kevin M. Rosenberg Sun, 13 Oct 2002 11:04:04 -0600 + +cl-kmrcl (1.5-1) unstable; urgency=low + + * ml-class.lisp: Change pcl package to sb-pcl for sbcl + * kmrcl.asd: remove sbcl from reader conditional for ml-class + + -- Kevin M. Rosenberg Sun, 13 Oct 2002 10:16:14 -0600 + +cl-kmrcl (1.4-1) unstable; urgency=low + + * Add pcl:validate-superclass for CMUCL/SBCL compatibility + + -- Kevin M. Rosenberg Sun, 13 Oct 2002 10:09:39 -0600 + +cl-kmrcl (1.3) unstable; urgency=low + + * Change .asd to fix problem with ml-class + + -- Kevin M. Rosenberg Sat, 12 Oct 2002 13:03:49 -0600 + +cl-kmrcl (1.2-1) unstable; urgency=low + + * Seperate string and equal functions into their own files + + -- Kevin M. Rosenberg Sat, 12 Oct 2002 00:03:18 -0600 + +cl-kmrcl (1.1-1) unstable; urgency=low + + * Re-arrange defclass order in ml-classes.lisp for cmucl compatibility + + -- Kevin M. Rosenberg Fri, 11 Oct 2002 20:00:29 -0600 + +cl-kmrcl (1.0-1) unstable; urgency=low + + * Initial Release (closes: 163955) + + -- Kevin M. Rosenberg Sat, 5 Oct 2002 13:19:33 -0600 + diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..05f0590 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,263 @@ +cl-kmrcl (1.38-1) unstable; urgency=low + + * New upstream + + -- Kevin M. Rosenberg Sun, 4 May 2003 08:43:14 -0600 + +cl-kmrcl (1.37-1) unstable; urgency=low + + * New upstream + + -- Kevin M. Rosenberg Fri, 2 May 2003 16:30:15 -0600 + +cl-kmrcl (1.36-1) unstable; urgency=low + + * New upstream + + -- Kevin M. Rosenberg Fri, 2 May 2003 01:28:00 -0600 + +cl-kmrcl (1.35-1) unstable; urgency=low + + * New upstream + + -- Kevin M. Rosenberg Tue, 29 Apr 2003 21:18:40 -0600 + +cl-kmrcl (1.34-1) unstable; urgency=low + + * New upstream + + -- Kevin M. Rosenberg Tue, 29 Apr 2003 20:14:55 -0600 + +cl-kmrcl (1.33-1) unstable; urgency=low + + * New upstream + + -- Kevin M. Rosenberg Tue, 29 Apr 2003 09:24:35 -0600 + +cl-kmrcl (1.32-1) unstable; urgency=low + + * Vary signature of DIRECT-SLOT-DEFINITION-CLASS depending on + implementation + + -- Kevin M. Rosenberg Mon, 28 Apr 2003 19:35:37 -0600 + +cl-kmrcl (1.31-1) unstable; urgency=low + + * New upstream + * Add kmr-mop package + * Add tests suite, add cl-rt to depends + * Use compat file rather than DH_COMPAT variable + + -- Kevin M. Rosenberg Mon, 28 Apr 2003 14:32:16 -0600 + +cl-kmrcl (1.30-1) unstable; urgency=low + + * Really fix typo + + -- Kevin M. Rosenberg Wed, 26 Mar 2003 14:11:09 -0700 + +cl-kmrcl (1.29-1) unstable; urgency=low + + * Fix typo in new sb-mop support + + -- Kevin M. Rosenberg Tue, 25 Mar 2003 06:42:15 -0700 + +cl-kmrcl (1.28-1) unstable; urgency=low + + * Fix sbcl for versions without sb-mop package + + -- Kevin M. Rosenberg Mon, 24 Mar 2003 22:19:49 -0700 + +cl-kmrcl (1.27-1) unstable; urgency=low + + * New upstream for sbcl 0.8pre MOP changes + + -- Kevin M. Rosenberg Mon, 24 Mar 2003 21:12:17 -0700 + +cl-kmrcl (1.26-1) unstable; urgency=low + + * Add nsubseq + * Rework list-to-delimited-sequence + + -- Kevin M. Rosenberg Fri, 7 Feb 2003 07:19:14 -0700 + +cl-kmrcl (1.25-1) unstable; urgency=low + + * strings.lisp: add new functions + + -- Kevin M. Rosenberg Mon, 13 Jan 2003 14:40:37 -0700 + +cl-kmrcl (1.24-1) unstable; urgency=low + + * strings.lisp: fix typo error + + -- Kevin M. Rosenberg Sat, 28 Dec 2002 00:58:18 -0700 + +cl-kmrcl (1.23-1) unstable; urgency=low + + * New upstream, add string functions + + -- Kevin M. Rosenberg Thu, 26 Dec 2002 04:46:15 -0700 + +cl-kmrcl (1.22-1) unstable; urgency=low + + * New upstream + + -- Kevin M. Rosenberg Mon, 2 Dec 2002 17:54:02 -0700 + +cl-kmrcl (1.21-1) unstable; urgency=low + + * Remore allegroserve dependant modules + + -- Kevin M. Rosenberg Sun, 24 Nov 2002 13:13:05 -0700 + +cl-kmrcl (1.20.2-1) unstable; urgency=low + + * Remove 'load-compiled-op from .asd file + + -- Kevin M. Rosenberg Fri, 8 Nov 2002 09:41:22 -0700 + +cl-kmrcl (1.20.1-1) unstable; urgency=low + + * Add with-each-file-line & with-each-stream-line to export list, fix + bugs in those functions + + -- Kevin M. Rosenberg Wed, 7 Nov 2002 14:52:39 -0700 + +cl-kmrcl (1.20-1) unstable; urgency=low + + * Add with-each-stream-line, with-each-file-line + * Use gensyms in other functions to avoid variable capture + + -- Kevin M. Rosenberg Wed, 6 Nov 2002 13:33:39 -0700 + +cl-kmrcl (1.19.1-1) unstable; urgency=low + + * Made indent-spaces reslient to non-numeric parameter + + -- Kevin M. Rosenberg Mon, 4 Nov 2002 11:33:03 -0700 + +cl-kmrcl (1.19-1) unstable; urgency=low + + * New upstream + + -- Kevin M. Rosenberg Sun, 3 Nov 2002 13:08:44 -0700 + +cl-kmrcl (1.18-1) unstable; urgency=low + + * New upstream + + -- Kevin M. Rosenberg Mon, 21 Oct 2002 11:51:17 -0600 + +cl-kmrcl (1.17-1) unstable; urgency=low + + * Fix buggy kmrcl.asd file + + -- Kevin M. Rosenberg Mon, 21 Oct 2002 11:51:17 -0600 + +cl-kmrcl (1.16-1) unstable; urgency=low + + * Rework handling of aserve requirement + + -- Kevin M. Rosenberg Sun, 20 Oct 2002 20:37:01 -0600 + +cl-kmrcl (1.15-1) unstable; urgency=low + + * Add depends: for common-lisp-controller and cl-aserve + + -- Kevin M. Rosenberg Sat, 19 Oct 2002 19:59:02 -0600 + +cl-kmrcl (1.14-1) unstable; urgency=low + + * ml-class.lisp: Add XHTML format + * web-utils.lisp: Add standard headers for xml, html, xhtml, + added user-agent-ie-p + + -- Kevin M. Rosenberg Thu, 17 Oct 2002 16:25:31 -0600 + +cl-kmrcl (1.13-1) unstable; urgency=low + + * ml-class.lisp: Add ie-xmlrefformat for Internet Explorer's idea of + a link in XML. Add SCL compatibility. + + -- Kevin M. Rosenberg Tue, 15 Oct 2002 23:23:57 -0600 + +cl-kmrcl (1.12-1) unstable; urgency=low + + * Fix .asd file if CL-ASERVE is not installed + + -- Kevin M. Rosenberg Tue, 15 Oct 2002 16:46:47 -0600 + +cl-kmrcl (1.11-1) unstable; urgency=low + + * Change .asd file for ASERVE require + + -- Kevin M. Rosenberg Tue, 15 Oct 2002 16:38:28 -0600 + +cl-kmrcl (1.10-1) unstable; urgency=low + + * ml-class.lisp: Fix package name + + -- Kevin M. Rosenberg Mon, 14 Oct 2002 14:48:43 -0600 + +cl-kmrcl (1.9-1) unstable; urgency=low + + * ml-class.lisp: Get package name from object + + -- Kevin M. Rosenberg Mon, 14 Oct 2002 13:23:23 -0600 + +cl-kmrcl (1.8-1) unstable; urgency=low + + * ml-class.lisp: Add defgeneric for generic functions + + -- Kevin M. Rosenberg Mon, 14 Oct 2002 09:11:08 -0600 + +cl-kmrcl (1.7-1) unstable; urgency=low + + * Push :kmrcl onto features + + -- Kevin M. Rosenberg Sun, 13 Oct 2002 20:47:45 -0600 + +cl-kmrcl (1.6-1) unstable; urgency=low + + * ml-class.lisp: Fix CMUCL compatibility, add SBCL compatibility + + -- Kevin M. Rosenberg Sun, 13 Oct 2002 11:04:04 -0600 + +cl-kmrcl (1.5-1) unstable; urgency=low + + * ml-class.lisp: Change pcl package to sb-pcl for sbcl + * kmrcl.asd: remove sbcl from reader conditional for ml-class + + -- Kevin M. Rosenberg Sun, 13 Oct 2002 10:16:14 -0600 + +cl-kmrcl (1.4-1) unstable; urgency=low + + * Add pcl:validate-superclass for CMUCL/SBCL compatibility + + -- Kevin M. Rosenberg Sun, 13 Oct 2002 10:09:39 -0600 + +cl-kmrcl (1.3) unstable; urgency=low + + * Change .asd to fix problem with ml-class + + -- Kevin M. Rosenberg Sat, 12 Oct 2002 13:03:49 -0600 + +cl-kmrcl (1.2-1) unstable; urgency=low + + * Seperate string and equal functions into their own files + + -- Kevin M. Rosenberg Sat, 12 Oct 2002 00:03:18 -0600 + +cl-kmrcl (1.1-1) unstable; urgency=low + + * Re-arrange defclass order in ml-classes.lisp for cmucl compatibility + + -- Kevin M. Rosenberg Fri, 11 Oct 2002 20:00:29 -0600 + +cl-kmrcl (1.0-1) unstable; urgency=low + + * Initial Release (closes: 163955) + + -- Kevin M. Rosenberg Sat, 5 Oct 2002 13:19:33 -0600 + diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +4 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..d6832cb --- /dev/null +++ b/debian/control @@ -0,0 +1,15 @@ +Source: cl-readline +Section: devel +Priority: optional +Maintainer: Kevin M. Rosenberg +Build-Depends: debhelper (>= 4.0.0), libreadline4-dev +Standards-Version: 3.5.9.0 + +Package: cl-readline +Architecture: any +Depends: ${shlibs:Depends}, common-lisp-controller, cl-uffi, libreadline4 +Description: Common Lisp interface to the GNU readline library + This package uses UFFI to provide an interface to the GNU readline + library for Common Lisp programs. + + diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..5159828 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,28 @@ +This package was debianized by Kevin M. Rosenberg in +May 2003. + +It was downloaded from http://www.cliki.org/cl-readline + +Upstream Author: Nikodemus Siivola + + +;; Copyright (c) 2003 Nikodemus Siivola +;; +;; 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. diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..724e084 --- /dev/null +++ b/debian/docs @@ -0,0 +1,2 @@ +README +TODO diff --git a/debian/postinst b/debian/postinst new file mode 100755 index 0000000..f45526c --- /dev/null +++ b/debian/postinst @@ -0,0 +1,44 @@ +#! /bin/sh + + +set -e + +# package name according to lisp +LISP_PKG=cl-readline + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package +# +# quoting from the policy: +# Any necessary prompting should almost always be confined to the +# post-installation script, and should be protected with a conditional +# so that unnecessary prompting doesn't happen if a package's +# installation fails and the `postinst' is called with `abort-upgrade', +# `abort-remove' or `abort-deconfigure'. + +case "$1" in + configure) + /usr/sbin/register-common-lisp-source ${LISP_PKG} + ;; + abort-upgrade|abort-remove|abort-deconfigure) + ;; + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/prerm b/debian/prerm new file mode 100755 index 0000000..df821a7 --- /dev/null +++ b/debian/prerm @@ -0,0 +1,40 @@ +#! /bin/sh + + +set -e + +# package name according to lisp +LISP_PKG=cl-readline + +# summary of how this script can be called: +# * `remove' +# * `upgrade' +# * `failed-upgrade' +# * `remove' `in-favour' +# * `deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + remove|upgrade|deconfigure) + /usr/sbin/unregister-common-lisp-source ${LISP_PKG} + ;; + failed-upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + + diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..5f9dab6 --- /dev/null +++ b/debian/rules @@ -0,0 +1,81 @@ +#!/usr/bin/make -f + +pkg := readline +debpkg := cl-$(pkg) + +clc-source := usr/share/common-lisp/source +clc-systems := usr/share/common-lisp/systems +clc-files := $(clc-source)/$(pkg) +doc-dir := usr/share/doc/$(debpkg) +lib-dir := usr/lib/cl-readline + +source-files := $(wildcard *.lisp) + +configure: configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + touch configure-stamp + + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + # Add here commands to compile the package. + $(MAKE) + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + # Add here commands to clean up after the build process. + rm -f debian/$(debpkg).postinst.* debian/$(debpkg).prerm.* + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + # Add here commands to install the package into debian/kmrcl. + dh_installdirs $(clc-systems) $(clc-files) $(clc-tests) + dh_install $(pkg).asd $(source-files) $(clc-files) + dh_link $(clc-files)/$(pkg).asd $(clc-systems)/$(pkg).asd + dh_install "libreadline-cl.so" $(lib-dir) + +# Build architecture-independent files here. +binary-indep: build install + + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot +# dh_installdebconf + dh_installdocs +# dh_installmenu +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_installinit +# dh_installcron +# dh_installman +# dh_installinfo +# dh_undocumented + dh_installchangelogs + dh_strip + dh_compress + dh_fixperms +# dh_makeshlibs + dh_installdeb +# dh_perl + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure + diff --git a/libreadline-cl.c b/libreadline-cl.c new file mode 100644 index 0000000..63874f6 --- /dev/null +++ b/libreadline-cl.c @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2003 Nikodemus Siivola + * + * 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. + */ + +#include +#include +#include + +typedef struct { + char * str; + void * next; +} +node_t; + +node_t * collection = NULL; + +int +add_completion (char * str) +{ + node_t * tmp = collection; + node_t * pre = NULL; + node_t * node; + while (tmp) + { + int cmp = strcmp (str, tmp->str); + if (0 == cmp) + return 1; + + if (0 < cmp) + break; + + /* printf ("-skip- (%s)\n", tmp->str);*/ + + pre = tmp; + tmp = tmp->next; + } + + node = malloc (sizeof (node_t)); + if (!node) + return 0; + + node->next = tmp; + node->str = strdup (str); + + if (! pre) + collection = node; + else + pre->next = node; + + return 1; +} + +node_t * root = NULL; + +char * +custom_completer (const char * str, int target) +{ + size_t len = strlen (str); + if (0 == target) + { + root = NULL; + node_t * tmp = collection; + while (len && tmp) + { + if (0 == strncmp (str, tmp->str, len)) + { + root = tmp; + return strdup (root->str); + } + else + tmp = tmp->next; + } + return (char *)NULL; + } + else if (root && (0 == strncmp (str, root->str, len))) + { + node_t * tmp = root; + root = root->next; + return strdup (tmp->str); + } + else + return (char *)NULL; +} + +void +clear_completions () +{ + node_t * tmp; + while (collection) + { + /* printf ("-del- (%s)\n", collection->str); */ + tmp = collection->next; + free (collection->str); + free (collection); + collection = tmp; + } +} + +void +use_custom_complete (void) +{ + rl_completion_entry_function = custom_completer; +} + +void +use_filename_complete (void) +{ + rl_completion_entry_function = rl_filename_completion_function; +} diff --git a/libreadline.lisp b/libreadline.lisp new file mode 100644 index 0000000..a127189 --- /dev/null +++ b/libreadline.lisp @@ -0,0 +1,46 @@ +;; Copyright (c) 2003 Nikodemus Siivola +;; +;; 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. + +(in-package libreadline) + +(def-function "readline" ((prompt :cstring)) + :module "readline" + :returning :cstring) + +(def-function "add_history" ((str :cstring)) + :module "readline" + :returning :void) + +(def-function "add_completion" ((str :cstring)) + :module "readline-cl" + :returning :int) + +(def-function "clear_completions" () + :module "readline-cl" + :returning :void) + +(def-function "use_custom_complete" () + :module "readline-cl" + :returning :void) + +(def-function "use_filename_complete" () + :module "readline-cl" + :returning :void) diff --git a/packages.lisp b/packages.lisp new file mode 100644 index 0000000..8b497e4 --- /dev/null +++ b/packages.lisp @@ -0,0 +1,40 @@ +;; Copyright (c) 2003 Nikodemus Siivola +;; +;; 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. + +(defpackage libreadline + (:use cl uffi)) + +(defpackage readline + (:nicknames rl) + (:use cl uffi) + (:export + add-completion + add-history + clear-completions + readline + use-cl-complete + use-custom-complete + use-filename-complete + )) + +(uffi:load-foreign-library "/usr/lib/cl-readline/libreadline-cl.so" + :module "readline-cl") + diff --git a/readline.asd b/readline.asd new file mode 100644 index 0000000..a4e3f9a --- /dev/null +++ b/readline.asd @@ -0,0 +1,29 @@ +;; -*- Lisp -*- +;; Copyright (c) 2003 Nikodemus Siivola +;; +;; 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. + +(asdf:defsystem readline + :depends-on (:uffi) + :components ((:file "packages") + (:file "libreadline" :depends-on ("packages")) + (:file "readline" :depends-on ("packages" "libreadline")))) + + diff --git a/readline.lisp b/readline.lisp new file mode 100644 index 0000000..2685c4b --- /dev/null +++ b/readline.lisp @@ -0,0 +1,72 @@ +;; Copyright (c) 2003 Nikodemus Siivola +;; +;; 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. + +(in-package readline) + +(defvar *whitespace* (list #\Space #\Tab)) + +(let (cl-complete) + + (defun add-completion (string) + "Add STRING as a custom-completion." + (setq cl-complete nil) + (with-cstring (c-str string) + (= 1 (libreadline::add-completion c-str)))) + + (defun clear-completions () + "Clear all custom-completions." + (setq cl-complete nil) + (libreadline::clear-completions)) + + (defun use-custom-complete () + "Use custom-competions." + (libreadline::use-custom-complete) + nil) + + (defun use-filename-complete () + "Use default completion system. (filename)" + (libreadline::use-filename-complete) + nil) + + (defun use-cl-complete () + "Load symbols in package CL-USER as custom-completions." + (unless cl-complete + (setq cl-complete t) + (clear-completions) + (do-symbols (sym (find-package :cl-user)) + (add-completion (string-downcase (string sym))))) + (use-custom-complete) + nil) + + (defun add-history (string) + "Add STRING to history." + (with-cstring (c-string string) + (libreadline::add-history c-string)) + string) + + (defun readline (&key (prompt "") (history t)) + "Read a line from current TTY with line-editing." + (with-cstring (c-prompt prompt) + (let ((str (string-trim + *whitespace* + (convert-from-cstring (libreadline::readline c-prompt))))) + (when (and history (not (string= "" str))) + (add-history str)))))) -- 2.34.1