[libreadline-java] 03/21: Imported Upstream version 0.8.0.1

Tony Mancill tmancill at moszumanska.debian.org
Sat Mar 22 16:49:33 UTC 2014


This is an automated email from the git hooks/post-receive script.

tmancill pushed a commit to branch master
in repository libreadline-java.

commit 5bc022c1f5086028d2e6917d9d284ab6fb0420bf
Author: tony mancill <tmancill at debian.org>
Date:   Fri Mar 21 06:40:16 2014 -0700

    Imported Upstream version 0.8.0.1
---
 ChangeLog                                     |  590 +++++++++--
 Makefile                                      |  183 ++--
 ChangeLog => NEWS                             |   22 +-
 README                                        |   29 +-
 VERSION                                       |    2 +-
 contrib/jscheme/SilkCompleter.java            |   64 ++
 contrib/win32/JavaGetline.dll                 |  Bin 0 -> 47622 bytes
 etc/Makefile                                  |   48 -
 etc/libreadline-java.spec                     |   38 +
 src/Makefile                                  |   45 +-
 src/mkrules.inc                               |   56 --
 src/native/Makefile                           |   89 +-
 src/native/getline.c                          | 1149 +++++++++++++++++++++
 src/native/getline.h                          |   44 +
 src/native/org_gnu_readline_Readline.c        |  581 ++++++++++-
 src/org/Makefile                              |   28 -
 src/org/gnu/Makefile                          |   28 -
 src/org/gnu/readline/Makefile                 |   30 -
 src/org/gnu/readline/Readline.java            | 1315 ++++++++++++++++++++++++-
 src/org/gnu/readline/ReadlineConstBase.java   |   85 ++
 src/org/gnu/readline/ReadlineConstInt.java    |   48 +
 src/org/gnu/readline/ReadlineConstString.java |   48 +
 src/org/gnu/readline/ReadlineLibrary.java     |   13 +-
 src/test/ReadlineTest.java                    |   35 +-
 24 files changed, 4098 insertions(+), 472 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 99c386b..cffe35a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,71 +1,521 @@
-For release 0.7.0:
-	- bugfix: setCompleter(null) crashed the virtual machine. Now, it sets
-	  the completer back to default behaviour (filename completion)
-	- native functions added:
-	  o cleanupReadlineImpl() does a reset of the readline lib and the
-	    terminal. Exported as 'void cleanup()' to the java user.
-	  o getLineBufferImpl() returns the current line buffer. This is
-	    usually needed within completers to access the _full_ line (the
-	    completer only gets the last word). Exported as
-	    'String getLineBuffer()' to the java user.
-	- documentation: complete example for ReadlineCompleter interface;
-	  better indented example for Readline. Added cleanup() in the example.
-	- declare the 'UnsatisfiedLinkError' in the load() method for
-	  documentation purposes.
-	(all changes provided by Henner Zeller)
-	- added note about Debian-packages in README
-	- new description on how to make Jython work with JavaReadline
-	(copied from a posting of Steve Cohen <SteveC at ignitesports.com> to
-	jython-users at lists.sourceforge.net)
-	
-For release 0.6.1:
-        - bugfix: fallback-solution did not throw EOFException
-	- bugfix: missing P ("ureJava") in method Readline.byName() 
-
-For release 0.6:
-	- added ReadlineLibrary
-	- implemented Editline-support
+2003-01-07  Bernhard Bablok  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/misc/release-checklist.txt:
+	added item '0. Change version numbers'
+
+	* /cvsroot/java-readline/java-readline/etc/libreadline-java.spec,
+	/cvsroot/java-readline/java-readline/web/index.html:
+	updated version number to 0.8.0
+
+2002-12-17  Bernhard Bablok  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/src/native/Makefile:
+	bugfix: only add -lcygwin if MSC=cygwin
+
+2002-11-24  Bernhard Bablok  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/contrib/jscheme/SilkCompleter.java,
+	/cvsroot/java-readline/java-readline/contrib/win32/JavaGetline.dll:
+	initial entry
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
+	minor code cleanups
+
+	* /cvsroot/java-readline/java-readline/src/native/getline.h:
+	bugfix: moved #defines outside #if __STDC__ > 0
+
+	* /cvsroot/java-readline/java-readline/src/native/Makefile,
+	/cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c:
+	added support for WIN32
+
+	* /cvsroot/java-readline/java-readline/NEWS: news for version 0.8.0
+
+	* /cvsroot/java-readline/java-readline/VERSION:
+	upgraded version number to 0.8.0
+
+	* /cvsroot/java-readline/java-readline/README: describe WIN32 support
+
+	* /cvsroot/java-readline/java-readline/Makefile:
+	added support for WIN32
+
+2002-11-02  Bernhard Bablok  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/etc/libreadline-java.spec,
+	/cvsroot/java-readline/java-readline/Makefile:
+	updated HOMEPAGE-Url
+
+	* /cvsroot/java-readline/java-readline/README: added note about Getline
+
+2002-10-28  Bernhard Bablok  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c:
+	fixed implementation of getHistoryImpl for Editline (patch from Ben Burton)
+
+2002-10-15  Bernhard Bablok  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
+	- enable history-methods for editline
+	- added javadoc-comments stating which method is supported by
+	  which backing implementation
+
+	* /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c:
+	fix typecast for java_completer (patch provided by Ben Burton)
+
+	* /cvsroot/java-readline/java-readline/Makefile:
+	group documentation into packages (patch provided by Ben Burton)
+
+2002-08-12  Bernhard Bablok  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/web/index.html:
+	added XNap as project using Java-Readline
+
+	* /cvsroot/java-readline/java-readline/web/index.html:
+	- changed address of henplus
+	- fixed relative URLs to absolute URLs for JYTHON and BeanShell
+
+2002-06-25  Bernhard Bablok  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/Makefile,
+	/cvsroot/java-readline/java-readline/src/native/Makefile,
+	/cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c,
+	/cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java,
+	/cvsroot/java-readline/java-readline/src/org/gnu/readline/ReadlineLibrary.java:
+	integrated getline
+
+	* /cvsroot/java-readline/java-readline/src/native/getline.c,
+	/cvsroot/java-readline/java-readline/src/native/getline.h:
+	initial entry
+
+	* /cvsroot/java-readline/java-readline/VERSION:
+	changed version to 0.7.4
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
+	bugfix: too many braces
+
+2002-06-07  Bernhard Bablok  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
+	integrated encoding-patch
+
+2002-05-27  Bernhard Bablok  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/misc/release-checklist.txt:
+	initial entry
+
+	* /cvsroot/java-readline/java-readline/etc/libreadline-java.spec:
+	added NEWS to %doc
+
+	* /cvsroot/java-readline/java-readline/NEWS,
+	/cvsroot/java-readline/java-readline/web/index.html:
+	prepared release 0.7.3
+
+2002-05-11  Bernhard Bablok  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c:
+	changed implementation of utf2ucs and ucs2utf
+
+	* /cvsroot/java-readline/java-readline/Makefile: added variable NEWS
+
+	* /cvsroot/java-readline/java-readline/README:
+	changed reference to ChangeLog to NEWS
+
+	* /cvsroot/java-readline/java-readline/ChangeLog: moved to NEWS
+
+	* /cvsroot/java-readline/java-readline/NEWS: initial entry
+
+2002-05-09  hzeller  <henner at freiheit.com>
+
+	* /cvsroot/java-readline/java-readline/etc/libreadline-java.spec, /cvsroot/java-readline/java-readline/Makefile:
+	o build RPM in own build directory. Don't need to be root to do so.
+
+2002-05-02  Bernhard Bablok  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/web/index.html:
+	added Sourceforge logo
+
+	* /cvsroot/java-readline/java-readline/web/index.html: initial entry
+
+2002-04-30  Bernhard Bablok  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
+	fixed bugs in Readline.readline(...) functions
+
+2002-04-24  hzeller  <henner at freiheit.com>
+
+	* /cvsroot/java-readline/java-readline/VERSION, /cvsroot/java-readline/java-readline/etc/libreadline-java.spec:
+	o bump version to 0.7.3 .. the future release.
+
+2002-04-15  hzeller  <henner at freiheit.com>
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java, /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c:
+	o don't add history automatically for each line. Provided by Brian Clapper.
+
+2002-03-11  hzeller  <henner at freiheit.com>
+
+	* /cvsroot/java-readline/java-readline/etc/libreadline-java.spec, /cvsroot/java-readline/java-readline/ChangeLog, /cvsroot/java-readline/java-readline/VERSION:
+	o 0.7.2 - first release for sourceforge.
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java, /cvsroot/java-readline/java-readline/etc/libreadline-java.spec, /cvsroot/java-readline/java-readline/Makefile:
+	o small modifications for first JavaReadline release on sourceforge.
+
+	* /cvsroot/java-readline/java-readline/etc/libreadline-java.spec:
+	o add spec file.
+
+2002-03-03  Bablokb  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/Makefile, /cvsroot/java-readline/java-readline/etc/Makefile, /cvsroot/java-readline/java-readline/src/Makefile, /cvsroot/java-readline/java-readline/src/mkrules.inc, /cvsroot/java-readline/java-readline/src/native/Makefile, /cvsroot/java-readline/java-readline/src/org/Makefile, /cvsroot/java-readline/java-readline/src/org/gnu/Makefile, /cvsroot/java-readline/java-readline/src/org/gnu/readline/Makefile:
+	switched to new build-system
+
+	* /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c:
+	- make cleanupReadlineImpl only for JavaReadline available
+	- added hasTerminalImpl
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
+	- added method hasTerminal()
+	- added method hasTerminalImpl()
+
+	* /cvsroot/java-readline/java-readline/ChangeLog:
+	release notes for 0.7.1
+
+	* /cvsroot/java-readline/java-readline/VERSION:
+	changed version to 0.7.1
+
+2002-01-19  Bablokb  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/VERSION:
+	changed version to 0.7.0
+
+	* /cvsroot/java-readline/java-readline/ChangeLog:
+	release notes for 0.7.0
+
+2002-01-01  Bablokb  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/TODO:
+	removed todo-item about JPython/Jython
+
+	* /cvsroot/java-readline/java-readline/contrib/jpython/jython-install.txt:
+	Initial entry
+
+	* /cvsroot/java-readline/java-readline/contrib/jpython/README:
+	updated the file to point to jython-install.txt
+
+2001-12-27  Bablokb  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
+	- bugfix: setCompleter(null) crashed the virtual machine
+	- added methods cleanup(), getLineBuffer() and the respective *Impl methods
 	- improved documentation
-	
-For release 0.5.2:
-	- added ReadlineReader (provided by Shane Celis <shane at terrapsring.com>)
-	- added contrib-directory with
-	  * bsh (provided by Shane Celis <shane at terrapsring.com>)
-	  * jpython (moved from my own website into this package)
-	- added section about LICENSING ISSUES in README
-	- updated TODO
-	
-For release 0.5.1:
-	- added word break patch (sets rl_completer_word_break_characters,
-	  provided by David Dribin <dave at dribin.org>)
-	
-For release 0.5:
-	- added code for reading/writing history files
-	  (provided by erik at skiinfo.fr)
-	- added code for setting a custom completer
-	  (provided by erik at skiinfo.fr)
-	- added a sample custom completer
-	- changed ReadlineTest to include new methods
-	
-For release 0.43:
-	- rewrote makefile(s)
-	- changed directory structure
-	- moved ReadlineTest to package test
-	- removed file INSTALL
-	
-For release 0.42:
-	- Moved native code to native subdirectory
-	- Reorganized makefiles
-
-For release 0.41:
-	- Changed package name to org.gnu.readline (to be SUN compliant)
-
-For release 0.4:
-	- Added the following methods: readInitFile() and parseAndBind()	
-
-For release 0.3:
-	- Added UTF-8 to UCS-1 conversion: characters with 8'th bit set are now
-	  supported
-
-For release 0.2:
-	- Initial public release
+
+	* /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c:
+	- added cleanupReadlineImpl and getLineBufferImpl (provided by Henner Zeller)
+	- minor code cleanup (provided by Henner Zeller)
+
+	* /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java:
+	- added Readline.cleanup() code
+	- minor changes to main input loop
+
+	* /cvsroot/java-readline/java-readline/README:
+	added note about Debian-packages
+
+	* /cvsroot/java-readline/java-readline/Makefile:
+	removed option -private from call to javadoc
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/ReadlineCompleter.java:
+	Initial entry
+
+2001-12-15  Bablokb  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/ChangeLog:
+	correct version is 0.6.1, not 0.61
+
+	* /cvsroot/java-readline/java-readline/VERSION:
+	changed version to 0.6.1
+
+	* /cvsroot/java-readline/java-readline/VERSION: changed version to 0.61
+
+	* /cvsroot/java-readline/java-readline/ChangeLog:
+	release notes for 0.61
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
+	bugfix: fallback-solution did not throw EOFException
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/ReadlineLibrary.java:
+	bugfix: missing P ("ureJava") in method byName
+
+2001-10-12  Bablokb  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/VERSION: changed version to 0.6
+
+	* /cvsroot/java-readline/java-readline/TODO:
+	removed all TODO-items finished for 0.6
+
+	* /cvsroot/java-readline/java-readline/contrib/bsh/Interpreter.java.diff:
+	added ReadlineLibrary argument to constructor of ReadlineReader
+
+	* /cvsroot/java-readline/java-readline/src/native/Makefile:
+	reorganized dependencies and rules
+
+	* /cvsroot/java-readline/java-readline/contrib/bsh/README:
+	added note about changes due to the new post 0.6-features
+
+	* /cvsroot/java-readline/java-readline/contrib/bsh/Interpreter.java:
+	added ReadlineLibrary argument to constructor of ReadlineReader
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/ReadlineReader.java:
+	added ReadlineLibrary argument to all constructors
+
+2001-09-08  Bablokb  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java:
+	implemented switching of backing libraries
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/ReadlineLibrary.java:
+	implemented byName() method
+
+	* /cvsroot/java-readline/java-readline/TODO: TODO-status as of 0.6pre1
+
+	* /cvsroot/java-readline/java-readline/VERSION:
+	changed version to 0.6pre1
+
+	* /cvsroot/java-readline/java-readline/ChangeLog: release notes for 0.6
+
+	* /cvsroot/java-readline/java-readline/Makefile: - added README.1st
+	- bugfix: use $(shell ls *.so) instead of $(wildcard *.so)
+	- reorganized BIN_ADD and SRC_ADD
+
+	* /cvsroot/java-readline/java-readline/README.1st: Initial entry
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
+	added EOFException explicitly to readline()
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
+	added more comments
+
+	* /cvsroot/java-readline/java-readline/README: updated to 0.6
+
+	* /cvsroot/java-readline/java-readline/contrib/jpython/ReadlineConsole.java:
+	updated to reflect new methods since 0.6
+
+	* /cvsroot/java-readline/java-readline/src/native/Makefile:
+	changed -D in compilation of org_gnu_readline_Readline.c
+	(just define library-name, don't define a value)
+
+	* /cvsroot/java-readline/java-readline/Makefile:
+	added support for Editline
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
+	readInitFile() and parseAndBind() are only support by GnuReadline
+
+	* /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c:
+	added #defines for JavaReadline/JavaEditline
+
+	* /cvsroot/java-readline/java-readline/src/native/Makefile:
+	generalized makefile to support various readline implementations
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
+	replaced UnsupportedMethodError with standard UnsupportedOperationException
+
+	* /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java:
+	method setThrowErrorOnUnsupportedMethod() changed to
+	setThrowExceptionOnUnsupportedMethod()
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Makefile:
+	removed dependency of Readline to UnsupportedMethodError
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/UnsupportedMethodError.java:
+	replaced with UnsupportedOperationException
+
+2001-09-07  Bablokb  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c:
+	added rl_initialize() to initReadlineImpl
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Makefile:
+	added dependency of Readline to UnsupportedMethodError
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
+	- bugfix: make [gs]etThrowErrorOnUnsupportedMethod() static
+	- throw error from all unsupported methods if throw-flag is true
+
+	* /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java:
+	added call to Readline.setThrowErrorOnUnsupportedMethod(true);
+
+	* /cvsroot/java-readline/java-readline/VERSION: upgraded version to 0.6
+
+	* /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java:
+	added call to Readline.load(ReadlineLibrary.GnuReadline)
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
+	added some comments to load()
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
+	- added field iThrowError
+	- added methods getThrowErrorOnUnsupportedMethod() and
+	  setThrowErrorOnUnsupportedMethod()
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/UnsupportedMethodError.java, /cvsroot/java-readline/java-readline/src/org/gnu/readline/ReadlineLibrary.java:
+	Initial entry
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
+	- made all native methods private and renamed to *Impl
+	- implemented simple fallback solution
+
+	* /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java:
+	catch IOException instead of EOFException
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Makefile:
+	added dependency of Readline to ReadlineLibrary
+
+	* /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c:
+	renamed installCompleterImpl to setCompleterImpl
+
+	* /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c:
+	added Impl to all native methods
+
+2001-09-02  Bablokb  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/Makefile:
+	added contrib to SRC_ADD
+
+	* /cvsroot/java-readline/java-readline/Makefile:
+	changed to tar.bz2 archives
+
+2001-08-27  Bablokb  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/ChangeLog:
+	added author of word break patch
+
+2001-08-26  Bablokb  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/VERSION: added ReadlineReader
+
+	* /cvsroot/java-readline/java-readline/ChangeLog:
+	release notes for 0.5.2
+
+	* /cvsroot/java-readline/java-readline/TODO: added a few todo-items
+
+	* /cvsroot/java-readline/java-readline/README:
+	added section about LICENSING ISSUES
+
+	* /cvsroot/java-readline/java-readline/contrib/jpython/README:
+	added a note about JPython <-> Jython
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/ReadlineReader.java:
+	Initial entry
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
+	added javadoc comments to getWordBreakCharacters() and setWordBreakCharacters()
+
+	* /cvsroot/java-readline/java-readline/contrib/bsh/BshCompleter.java, /cvsroot/java-readline/java-readline/contrib/bsh/Interpreter.java, /cvsroot/java-readline/java-readline/contrib/bsh/Interpreter.java.diff, /cvsroot/java-readline/java-readline/contrib/bsh/README:
+	Initial entry
+
+	* /cvsroot/java-readline/java-readline/ChangeLog: log entry for 0.5.1
+
+	* /cvsroot/java-readline/java-readline/VERSION, /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c, /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java, /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java:
+	added word break patch
+
+2001-03-18  Bablokb  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Makefile, /cvsroot/java-readline/java-readline/src/org/gnu/Makefile, /cvsroot/java-readline/java-readline/src/org/Makefile, /cvsroot/java-readline/java-readline/src/test/Makefile:
+	added copyright header
+
+	* /cvsroot/java-readline/java-readline/etc/Makefile:
+	removed reference to RRSystem
+
+	* /cvsroot/java-readline/java-readline/ChangeLog: release notes for 0.5
+
+	* /cvsroot/java-readline/java-readline/README: upgraded text to 0.5
+
+	* /cvsroot/java-readline/java-readline/TODO:
+	removed custom completers from TODO list
+
+	* /cvsroot/java-readline/java-readline/Makefile:
+	- added $(APIDIR) to BIN_ADD
+	- added $(BIN_ADD) to target bin-dist
+	- updated target clean
+
+	* /cvsroot/java-readline/java-readline/VERSION:
+	upgraded version number to 0.5
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
+	added additional methods: readHistoryFile(), writeHistoryFile(),
+	setCompleter(), getCompleter(), installCompleter()
+
+	* /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java:
+	added code for new functions
+
+	* /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c:
+	added code for readHistoryFile, writeHistoryFile and installCompleter
+
+	* /cvsroot/java-readline/java-readline/src/test/TestCompleter.java:
+	Initial entry
+
+	* /cvsroot/java-readline/java-readline/src/test/Makefile:
+	added dependency TestCompleter of ReadlineTest
+
+2001-03-17  Bablokb  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/VERSION: Initial entry
+
+	* /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c, /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java:
+	changed copyright
+
+	* /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java, /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
+	changed mail adress
+
+	* /cvsroot/java-readline/java-readline/README: - merged INSTALL
+	- minor changes in wording
+
+	* /cvsroot/java-readline/java-readline/ChangeLog:
+	added release notes for release 0.4.3
+
+	* /cvsroot/java-readline/java-readline/Makefile:
+	rewrote makefile for new structure
+
+	* /cvsroot/java-readline/java-readline/INSTALL: merged with README
+
+	* /cvsroot/java-readline/java-readline/src/native/Makefile:
+	added $(SO) to rm statement in target clean
+
+	* /cvsroot/java-readline/java-readline/etc/Makefile, /cvsroot/java-readline/java-readline/etc/manifest.stub:
+	Initial entry
+
+	* /cvsroot/java-readline/java-readline/src/native/Makefile:
+	changed target directory for shared library
+
+	* /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java:
+	- moved import-statements before class definition
+	- added javadoc comments about main-method
+
+	* /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java:
+	made init-file an argument
+
+	* /cvsroot/java-readline/java-readline/src/native/Makefile:
+	ignore error from rm in target clean
+
+	* /cvsroot/java-readline/java-readline/src/native/Makefile:
+	new structure
+
+	* /cvsroot/java-readline/java-readline/src/Makefile, /cvsroot/java-readline/java-readline/src/mkrules.inc:
+	added target clean
+
+	* /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java:
+	added package statement
+
+	* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Makefile, /cvsroot/java-readline/java-readline/src/org/gnu/Makefile, /cvsroot/java-readline/java-readline/src/org/Makefile, /cvsroot/java-readline/java-readline/src/test/Makefile, /cvsroot/java-readline/java-readline/src/Makefile, /cvsroot/java-readline/java-readline/src/mkrules.inc, /cvsroot/java-readline/java-readline/COPYING.LIB:
+	Initial entry
+
+2001-03-04  Bablokb  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/contrib/jpython/ReadlineConsole.java:
+	bugfix: deal with prompt==null in raw_input()
+
+2000-09-18  Bablokb  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/contrib/jpython/README, /cvsroot/java-readline/java-readline/contrib/jpython/ReadlineConsole.java, /cvsroot/java-readline/java-readline/contrib/jpython/jpython.java, /cvsroot/java-readline/java-readline/contrib/jpython/jpython.diff:
+	Initial entry
+
+2000-05-01  Bablokb  <mail at bablokb.de>
+
+	* /cvsroot/java-readline/java-readline/src/native/Makefile:
+	changed JAVANATINC to jdk 1.2 standard
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 412ef74..cdeb098 100644
--- a/Makefile
+++ b/Makefile
@@ -23,92 +23,105 @@
 #
 # Toplevel Makefile for Java-Readline
 #
-# $Author: Bablokb $
-# $Revision: 1.10 $
+# $Author: bablokb $
+# $Revision: 1.18 $
 #
 
-TARGET    := java_readline
-README    := README README.1st
-CHANGELOG := ChangeLog
-LICENSE   := COPYING.LIB
-TODO      := TODO
-NAME      := The Java-Readline Library
-HOMEPAGE  := http://www.bablokb.de/java/readline.html
-COPYRIGHT := Released under the LGPL, (c) Bernhard Bablok 1998-2001
-WTITLE    := "$(NAME)"
-DTITLE     = "$(NAME), Version $(VERSION)"
-DBOTTOM   := "$(COPYRIGHT)<br>Homepage: <a href="$(HOMEPAGE)">$(HOMEPAGE)</a>"
-DHEADER    = "<strong>$(NAME), Version $(VERSION)</strong>"
-DFOOTER    = "<strong>$(NAME), Version $(VERSION)</strong>"
-PACKROOT  := 
-SUBDIRS   := src etc
-PACKAGES  := test org.gnu.readline
-BIN_ADD    = $(README) $(TODO) $(CHANGELOG) $(LICENSE) \
-             $(JAR) $(shell ls *.so) $(APIDIR)
-SRC_ADD   := $(README) $(TODO) $(CHANGELOG) $(LICENSE) \
-             Makefile VERSION $(SUBDIRS) contrib
-MF_STUB   := etc/manifest.stub
-
-# native stuff
-
-export JAVAINCLUDE       := $(JAVA_HOME)/include
-export JAVANATINC        := $(JAVA_HOME)/include/linux
-export INCLUDES          := -I $(JAVAINCLUDE) -I $(JAVANATINC)
-export LIBPATH           := -L/usr/lib/termcap
-export T_LIBS            := JavaReadline JavaEditline
-export JavaReadline_LIBS := -lreadline -ltermcap -lhistory
-export JavaEditline_LIBS := -ledit -ltermcap
-
-VERSION         := $(shell cat VERSION)
-export ROOTDIR  := $(shell pwd)
-export BUILDDIR := $(shell pwd)/build
-export METADIR  := $(BUILDDIR)/META-INF
-export CLASSDIR := $(BUILDDIR)
-export JAR      := $(TARGET).jar
-APIDIR          := ./api
-
-export JAVAC := jikes
-export CLASSPATH := $(BUILDDIR):$(JAVA_HOME)/jre/lib/rt.jar
-export JAVAC_OPT := -O +E
-
-.PHONY: src-dist bin-dist test apidoc jar subdirs $(SUBDIRS)
-
-jar: subdirs
-	$(MAKE) $(JAR)
-
-$(JAR): $(MF_STUB) $(shell find build -type f)
-ifeq ($(strip $(MF_STUB)),) 
-	jar -cvf $(JAR) -C $(BUILDDIR)/ .
-else
-	jar -cvfm $(JAR) $(MF_STUB) -C $(BUILDDIR)/ .
+TARGET    = libreadline-java
+README    = README README.1st
+NEWS      = NEWS
+CHANGELOG = ChangeLog
+LICENSE   = COPYING.LIB
+TODO      = TODO
+NAME      = The Java-Readline Library
+HOMEPAGE  = http://java-readline.sourceforge.net/
+COPYRIGHT = Released under the LGPL, (c) Bernhard Bablok, Henner Zeller 1998-2002
+WTITLE    = "$(NAME)"
+DTITLE    = "$(NAME), Version $(VERSION)"
+DBOTTOM   = "$(COPYRIGHT)<br>Homepage: <a href="$(HOMEPAGE)">$(HOMEPAGE)</a>"
+DHEADER   = "<strong>$(NAME), Version $(VERSION)</strong>"
+DFOOTER   = "<strong>$(NAME), Version $(VERSION)</strong>"
+BIN_ADD   = $(README) $(NEWS) $(TODO) $(CHANGELOG) $(LICENSE) \
+             $(JAR) *.so $(APIDIR)
+SRC_ADD   = $(README) $(NEWS) $(TODO) $(CHANGELOG) $(LICENSE) \
+             Makefile VERSION $(SUBDIRS) contrib src etc
+MF_STUB   = etc/manifest.stub
+
+# installation procedure
+PREFIX    = /usr
+BINLIBDIR = $(PREFIX)/lib
+DOCDIR    = $(PREFIX)/doc
+JAVALIBDIR= $(PREFIX)/share/java
+
+# libraries to build
+T_LIBS    = JavaReadline
+
+# Operating system dependent
+JAVAINCLUDE       = $(JAVA_HOME)/include
+JAVANATINC        = $(JAVA_HOME)/include/linux
+
+ifeq (MSC,$(WIN32))
+JAVA_HOME := c:/j2sdk1.4.0
+JAVANATINC = $(JAVA_HOME)/include/win32
+export PATH:=/cygdrive/$(subst :,,$(JAVA_HOME))/bin:/cygdrive/c/Programme/DevStudio/VC/bin:/cygdrive/c/Programme/DevStudio/SharedIDE/bin/:$(PATH)
+T_LIBS    = JavaGetline
+ARGS      = Getline
 endif
 
+## normal javac
+JAVAC = javac
+JC_FLAGS = 
+
+## with jikes
+#JAVAC = jikes
+#JC_FLAGS = -O +E
+
+VERSION         = `cat VERSION`
+JAR             = $(TARGET).jar
+APIDIR          = ./api
+BUILDDIR        = ./build
+# we build the rpm relative to our build..
+RPM_BASE        = `pwd`/$(BUILDDIR)/
+
+world : jar build-native
+
+jar: build-java
+	cd $(BUILDDIR) ; jar -cvmf ../$(MF_STUB) ../$(JAR) *
+
+$(JAR):
+	cd $(BUILDDIR) ; jar -cvmf ../$(MF_STUB) ../$(JAR) *
+
+build-java: $(BUILDDIR)
+	cd src ; $(MAKE) JAVAC="$(JAVAC)" JC_FLAGS="$(JC_FLAGS)" java
+
+build-native: 
+	cd src; $(MAKE) T_LIBS="$(T_LIBS)" JAVAINCLUDE="$(JAVAINCLUDE)" \
+		        JAVANATINC="$(JAVANATINC)" native
+
 apidoc: $(APIDIR)
 	javadoc -sourcepath src -d $(APIDIR) -windowtitle $(WTITLE) \
                 -doctitle $(DTITLE) -footer $(DFOOTER) -header $(DHEADER) \
                 -bottom $(DBOTTOM) \
-                -version -author $(patsubst %,$(PACKROOT)%,$(PACKAGES))
-
-bin-dist: jar apidoc
-	tar -czf $(TARGET)-$(VERSION)-bin.tgz --exclude "CVS" $(BIN_ADD)
-	-rm -fr $(TARGET)-$(VERSION)
-	mkdir $(TARGET)-$(VERSION)
-	(cd $(TARGET)-$(VERSION); tar -xzf ../$(TARGET)-$(VERSION)-bin.tgz)
-	tar -cjf $(TARGET)-$(VERSION)-bin.tar.bz2 $(TARGET)-$(VERSION)
-	-rm -fr $(TARGET)-$(VERSION) $(TARGET)-$(VERSION)-bin.tgz 
+                -version -author org.gnu.readline test
 
-src-dist: clean
-	tar -czf $(TARGET)-$(VERSION)-src.tgz --exclude "CVS" $(SRC_ADD)
-	-rm -fr $(TARGET)-$(VERSION)
-	mkdir $(TARGET)-$(VERSION)
-	(cd $(TARGET)-$(VERSION); tar -xzf ../$(TARGET)-$(VERSION)-src.tgz)
-	tar -cjf $(TARGET)-$(VERSION)-src.tar.bz2 $(TARGET)-$(VERSION)
-	rm -fr $(TARGET)-$(VERSION) $(TARGET)-$(VERSION)-src.tgz 
+install: jar build-native apidoc
+	install -D $(JAR)    $(DESTDIR)$(JAVALIBDIR)/$(JAR)
+	install -d $(DESTDIR)$(BINLIBDIR)
+	install  *.so        $(DESTDIR)$(BINLIBDIR)
+	install -d $(DESTDIR)$(DOCDIR)/$(TARGET)-$(VERSION)
+	cp -r api $(DESTDIR)$(DOCDIR)/$(TARGET)-$(VERSION)
 
-subdirs: $(BUILDDIR) $(METADIR) $(SUBDIRS)
+bin-dist: jar build-native apidoc
+	mkdir -p "$(TARGET)-$(VERSION)"
+	-cp -r $(BIN_ADD) "$(TARGET)-$(VERSION)"
+	tar -czf $(TARGET)-$(VERSION)-bin.tar.gz --exclude "CVS" "$(TARGET)-$(VERSION)"
+	rm -rf "$(TARGET)-$(VERSION)"
 
-$(SUBDIRS):
-	$(MAKE) -C $@
+src-dist: clean
+	mkdir -p "$(TARGET)-$(VERSION)"
+	-cp -r $(SRC_ADD) "$(TARGET)-$(VERSION)"
+	tar -czf $(TARGET)-$(VERSION)-src.tar.gz --exclude "CVS" "$(TARGET)-$(VERSION)"
+	rm -rf "$(TARGET)-$(VERSION)"
 
 $(APIDIR):
 	mkdir $(APIDIR)
@@ -119,10 +132,18 @@ $(BUILDDIR):
 $(METADIR): 
 	mkdir $(METADIR)
 
-test: jar
-	LD_LIBRARY_PATH=$(ROOTDIR) java -jar $(JAR) src/test/tinputrc
+rpm: src-dist
+	mkdir -p $(RPM_BASE)/SPECS $(RPM_BASE)/SOURCES $(RPM_BASE)/BUILD \
+	      $(RPM_BASE)/SRPMS $(RPM_BASE)/RPMS
+	cp etc/libreadline-java.spec $(RPM_BASE)/SPECS
+	cp $(TARGET)-$(VERSION)-src.tar.gz $(RPM_BASE)/SOURCES
+	rpm --define _topdir$(RPM_BASE) -ba $(RPM_BASE)/SPECS/libreadline-java.spec
+
+test: $(JAR) build-native
+	LD_LIBRARY_PATH=. java -jar $(JAR) src/test/tinputrc $(ARGS)
+
 clean:
-	-rm -fr $(JAR) $(TARGET)-*.tar.bz2 $(APIDIR) $(BUILDDIR) .rltest_history
-	for dir in $(SUBDIRS); do \
-		$(MAKE) -C $$dir clean; \
-	done
+	$(MAKE) -C src/native clean
+	-rm -fr `find . -name "*.o" -o -name "*~"` \
+		$(JAR) $(TARGET)-*.tar.*z* $(APIDIR) \
+		$(BUILDDIR) *.so .rltest_history
diff --git a/ChangeLog b/NEWS
similarity index 76%
copy from ChangeLog
copy to NEWS
index 99c386b..db1b6ba 100644
--- a/ChangeLog
+++ b/NEWS
@@ -1,3 +1,23 @@
+For release 0.8.0:
+        - added JScheme completer. Provided by Samer Abdallah
+	- added support for Getline (Bernhard)
+        - added support for WIN32	
+
+For release 0.7.3:
+	- don't add history automatically for each line. Provided by Brian Clapper
+	- removed 1024-byte limitation (useful for long multiline input)
+
+For release 0.7.2:
+	- no functionality changes; only modified build process a bit
+ 	  for first libreadline-java release on sourceforge (Henner)
+
+For release 0.7.1:
+       (provided by Henner Zeller <H.Zeller at acm.org>)
+	- provide method hasTerminal() to check, if we are run from a terminal
+          (calls isatty())
+        - make build process work on Solaris
+        - provide RPM-spec file
+
 For release 0.7.0:
 	- bugfix: setCompleter(null) crashed the virtual machine. Now, it sets
 	  the completer back to default behaviour (filename completion)
@@ -12,7 +32,7 @@ For release 0.7.0:
 	  better indented example for Readline. Added cleanup() in the example.
 	- declare the 'UnsatisfiedLinkError' in the load() method for
 	  documentation purposes.
-	(all changes provided by Henner Zeller)
+	(all changes provided by Henner Zeller <H.Zeller at acm.org>)
 	- added note about Debian-packages in README
 	- new description on how to make Jython work with JavaReadline
 	(copied from a posting of Steve Cohen <SteveC at ignitesports.com> to
diff --git a/README b/README
index 2593168..7ba30f3 100644
--- a/README
+++ b/README
@@ -12,13 +12,12 @@ This version implements basic readline functionality like line editing and
 filename completion, which should be just enough for normal use. Not all
 functionality is available with all implementations.
 
-Various people contributed code (see the file ChangeLog for details).
+Various people contributed code (see the file NEWS for details).
 Since I changed some of the code, all bugs are my fault and bugreports
 should be adressed to me.
 
 The binary distribution contains the API documentation, a JAR with the
-Readline class and the shared libraries libJavaReadline.so and 
-libJavaEditline.so. It was compiled running Linux 2.2.18 with glibc 2.2.
+Readline class and the shared library libJavaReadline.so.
 
 The source distribution contains all the source (I hope this doesn't surprise
 you ;-) and a system of makefiles. You need the JDK to compile it.
@@ -40,6 +39,11 @@ need libedit2 and libedit-dev. Source code is also available, although
 I must admit I did not succeed in compiling it on my non-BSD and
 non-Debian system :-(
 
+A second Readline replacement is called Getline. This is a very minimal
+Readline-clone with a liberal license, and the source-code is provided
+in the java-readline distribution. It has the advantage that it
+compiles natively on Windows.
+
 
 COMPILATION
 ===========
@@ -49,10 +53,23 @@ variable JAVA_HOME (or edit the makefile). Also, if you don't use jikes,
 you should change the variables JAVAC and JAVAC_OPT in the makefile. A better
 alternative is to install jikes, it will speed up your development by
 a factor of 2-3.
+JAVAC and JAVAC_OPT can also be set in the environment or from the
+make commandline.
+
+If you want Editline support, use "make T_LIBS=JavaEditline". Getline support
+is selected with "make T_LIBS=JavaGetline".
+
+Getline support is also available for (native) WIN32. To build it from
+source, you need the cygwin-environment (only necessary because we still
+use GNU-make) and a native C-compiler. All necessary variables are configured
+in the toplevel Makefile. Before running make, set the WIN32-variable to MSC:
+
+> WIN32=MSC make
 
-If you don't have the Editline libraries installed, use 
-"make T_LIBS=JavaReadline" (the default creates both JavaReadline and
-JavaEditline).
+A ready-to-use DLL is in the contrib/win32 directory. Since this feature
+is experimental, your feedback is appreciated. If you figure out how to
+link JavaReadline with cygwin, please let me know as well (some stubs
+are already built into the makefiles).
 
 
 INSTALLATION
diff --git a/VERSION b/VERSION
index faef31a..a3df0a6 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.7.0
+0.8.0
diff --git a/contrib/jscheme/SilkCompleter.java b/contrib/jscheme/SilkCompleter.java
new file mode 100644
index 0000000..a03eb7b
--- /dev/null
+++ b/contrib/jscheme/SilkCompleter.java
@@ -0,0 +1,64 @@
+package samer.silk;
+import java.util.*;
+import org.gnu.readline.*;
+import jsint.*;
+
+/**
+	This completer works with the JScheme scheme
+	interpreter by looking up symbols in the global
+	namespace. You can register it with the Java
+	Readline library either in Java or in scheme. Something
+	like the following should do it:
+
+	<pre>
+	;;; Switches JScheme's input port to a new one that uses
+	;;; a ReadlineReader with a ">" prompt.
+	;;; (Note that on some systems, you might get a double
+	;;; prompt "> >" because JScheme's main loop also prints
+	;;; a prompt. If this bugs you a lot, you can just write your
+	;;; own main loop to replace jsint.Scheme.readEvalWriteLoop().)
+	(set! jsint.Scheme.input$ (jsint.InputPort.
+		(org.gnu.readline.ReadlineReader. "> "
+			org.gnu.readline.ReadlineLibrary.GnuReadline$)))
+
+   	;;; not sure that this helps a lot, but I suppose it's good practice...
+	(.addShutdownHook (Runtime.getRuntime)
+		(Thread. (lambda ()
+			(display "cleaning up readline.\n")
+			(org.gnu.readline.Readline.cleanup))))
+
+   	;;; set Readline's completer to a new Scheme-aware one
+	(org.gnu.readline.Readline.setCompleter (samer.silk.SilkCompleter.))
+	</pre>
+
+	Author:  Samer Abdallah (samer.abdallah at elec.qmul.ac.uk)
+	November 2002
+ */
+
+public class SilkCompleter implements ReadlineCompleter {
+	Iterator	it;	// iterates over symbols in JScheme hashtable
+
+	/** Implementation of abstract function. Finds
+		possible completions of the given text. */
+
+	public String completer(String text, int state)
+	{
+		if (state == 0) { // first call to completer(): initialize iterator
+			// it=Symbol.symbolTable.entrySet().iterator();
+			it=Symbol.symbolTable.values().iterator();
+		}
+		while (it.hasNext()) { // subsequent calls
+			// Map.Entry entry = (Map.Entry)it.next();
+			// Symbol symbol=(Symbol)entry.getValue();
+			// String	name=(String)entry.getKey();
+			Symbol symbol=(Symbol)it.next();
+			String name=(String)symbol.toString();
+
+			// Jscheme seems to keep a lot of undefined symbols
+			// in the table---pretty much anything you type, actually.
+			// so we check and only return defined symbols.
+			if (name.startsWith(text) && symbol.isDefined()) return name;
+		}
+		return null; // we reached the last choice.
+	}
+}
\ No newline at end of file
diff --git a/contrib/win32/JavaGetline.dll b/contrib/win32/JavaGetline.dll
new file mode 100644
index 0000000..ccdc02e
Binary files /dev/null and b/contrib/win32/JavaGetline.dll differ
diff --git a/etc/Makefile b/etc/Makefile
deleted file mode 100644
index 4c532b4..0000000
--- a/etc/Makefile
+++ /dev/null
@@ -1,48 +0,0 @@
-#**************************************************************************
-#* Makefile for libJavaReadline.so -- load library for JNI wrapper
-#* of GNU readline
-#*
-#* Copyright (c) 1987-1998 Free Software Foundation, Inc.
-#* Java Wrapper Copyright (c) 1998-2001 by Bernhard Bablok (mail at bablokb.de)
-#*
-#* This program is free software; you can redistribute it and/or modify
-#* it under the terms of the GNU Library General Public License as published
-#* by  the Free Software Foundation; either version 2 of the License or
-#* (at your option) any later version.
-#*
-#* This program is distributed in the hope that it will be useful, but
-#* WITHOUT ANY WARRANTY; without even the implied warranty of
-#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#* GNU Library General Public License for more details.
-#*
-#* You should have received a copy of the GNU Library General Public License
-#* along with this program; see the file COPYING.LIB.  If not, write to
-#* the Free Software Foundation Inc., 59 Temple Place - Suite 330,
-#* Boston, MA  02111-1307 USA
-#***************************************************************************
-#
-# $Author: Bablokb $
-# $Revision: 1.2 $
-#
-
-SUBDIRS := $(shell find . -type d -not -name "." -not -name "CVS" -maxdepth 1)
-.PHONY: all clean subdirs $(SUBDIRS)
-
-META-FILES :=
-META_TARGETS := $(META-FILES:%=$(METADIR)/%)
-
-all: subdirs $(META_TARGETS)
-
-subdirs: $(SUBDIRS)
-
-$(SUBDIRS):
-	-mkdir $(METADIR)/$@
-	$(MAKE) -C $@ METADIR=$(METADIR)/$@
-
-$(METADIR)/%: %
-	cp -vu $< $(METADIR)
-
-clean:
-#	for dir in $(SUBDIRS); do \
-#		$(MAKE) -C $$dir clean; \
-#	done 
\ No newline at end of file
diff --git a/etc/libreadline-java.spec b/etc/libreadline-java.spec
new file mode 100644
index 0000000..7e9e5ee
--- /dev/null
+++ b/etc/libreadline-java.spec
@@ -0,0 +1,38 @@
+%define version 0.8.0
+
+Summary: java wrapper for the GNU-readline library
+Copyright: GNU Lesser General Public License
+Group: Development/Java
+Name: libreadline-java
+Prefix: /usr
+Provides: java_readline
+Packager: Henner Zeller <H.Zeller at acm.org>
+Release: 1
+Source: %{name}-%{version}-src.tar.gz
+URL: http://java-readline.sourceforge.net/
+Version: %{version}
+Buildroot: /tmp/javareadline-build
+BuildRequires: readline-devel
+
+%description
+This is a Java-wrapper for the GNU-Readline using the 
+Java Native Interface (JNI). It allows to write console Java applications
+that provide commandline editing functions like history and TAB-completion.
+
+%prep
+%setup -q
+
+%build
+
+%install
+rm -fr $RPM_BUILD_ROOT
+make DESTDIR=$RPM_BUILD_ROOT T_LIBS="JavaReadline" install
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root)
+%{prefix}/lib/libJavaReadline.so
+%{prefix}/share/java/%{name}.jar
+%doc NEWS ChangeLog README README.1st VERSION api
diff --git a/src/Makefile b/src/Makefile
index f7c1228..acb73df 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,41 +1,18 @@
-#**************************************************************************
-#* Makefile for libJavaReadline.so -- load library for JNI wrapper
-#* of GNU readline
-#*
-#* Copyright (c) 1987-1998 Free Software Foundation, Inc.
-#* Java Wrapper Copyright (c) 1998-2001 by Bernhard Bablok (mail at bablokb.de)
-#*
-#* This program is free software; you can redistribute it and#or modify
-#* it under the terms of the GNU Library General Public License as published
-#* by  the Free Software Foundation; either version 2 of the License or
-#* (at your option) any later version.
-#*
-#* This program is distributed in the hope that it will be useful, but
-#* WITHOUT ANY WARRANTY; without even the implied warranty of
-#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#* GNU Library General Public License for more details.
-#*
-#* You should have received a copy of the GNU Library General Public License
-#* along with this program; see the file COPYING.LIB.  If not, write to
-#* the Free Software Foundation Inc., 59 Temple Place - Suite 330,
-#* Boston, MA  02111-1307 USA
-#***************************************************************************
 #
-# $Author: Bablokb $
-# $Revision: 1.2 $
 #
 
-SUBDIRS := $(shell find . -type d -not -name "." -not -name "CVS" -maxdepth 1)
-export SRCROOT := $(shell pwd)
+BUILD=../build
 
-.PHONY: subdirs $(SUBDIRS) clean
+all : java native
 
-subdirs: $(SUBDIRS)
+java: always $(BUILD)
+	$(JAVAC) $(JC_FLAGS) -d $(BUILD) `find . -name "*.java"`
 
-$(SUBDIRS):
-	$(MAKE) -C $@
+native: always
+	cd native ; $(MAKE) T_LIBS="$(T_LIBS)" JAVAINCLUDE="$(JAVAINCLUDE)" \
+                            JAVANATINC="$(JAVANATINC)" all
 
-clean:
-	for dir in $(SUBDIRS); do \
-		$(MAKE) -C $$dir clean; \
-	done
+$(BUILD):
+	mkdir $@
+
+always:
diff --git a/src/mkrules.inc b/src/mkrules.inc
deleted file mode 100644
index 596f610..0000000
--- a/src/mkrules.inc
+++ /dev/null
@@ -1,56 +0,0 @@
-#**************************************************************************
-#* Makefile for libJavaReadline.so -- load library for JNI wrapper
-#* of GNU readline
-#*
-#* Copyright (c) 1987-1998 Free Software Foundation, Inc.
-#* Java Wrapper Copyright (c) 1998-2001 by Bernhard Bablok (mail at bablokb.de)
-#*
-#* This program is free software; you can redistribute it and#or modify
-#* it under the terms of the GNU Library General Public License as published
-#* by  the Free Software Foundation; either version 2 of the License or
-#* (at your option) any later version.
-#*
-#* This program is distributed in the hope that it will be useful, but
-#* WITHOUT ANY WARRANTY; without even the implied warranty of
-#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#* GNU Library General Public License for more details.
-#*
-#* You should have received a copy of the GNU Library General Public License
-#* along with this program; see the file COPYING.LIB.  If not, write to
-#* the Free Software Foundation Inc., 59 Temple Place - Suite 330,
-#* Boston, MA  02111-1307 USA
-#***************************************************************************
-#
-# $Author: Bablokb $
-# $Revision: 1.2 $
-#
-
-SUBDIRS := $(shell find . -type d -not -name "." -not -name "CVS" -maxdepth 1)
-PACKDIR := $(CLASSDIR)/$(shell echo `pwd` | sed -e's!.*/src/!!')
-
-.PHONY: all classes subdirs clean $(SUBDIRS)
-
-JAVA_SOURCES := $(wildcard *.java)
-JAVA_TARGETS := $(JAVA_SOURCES:%.java=$(PACKDIR)/%.class)
-
-GIF_SOURCES := $(wildcard *.gif)
-GIF_TARGETS := $(GIF_SOURCES:%=$(PACKDIR)/%)
-
-all: $(PACKDIR) subdirs $(JAVA_TARGETS) $(GIF_TARGETS)
-
-subdirs: $(SUBDIRS)
-
-$(PACKDIR):
-	mkdir $(PACKDIR)
-
-$(SUBDIRS):
-	$(MAKE) -C $@
-
-
-$(PACKDIR)/%.class: %.java
-	$(JAVAC) $(JAVAC_OPT) $< -d $(CLASSDIR)
-
-$(PACKDIR)/%.gif: %.gif
-	cp -vu $< $(PACKDIR)
-
-clean:
diff --git a/src/native/Makefile b/src/native/Makefile
index 14c176f..679adb7 100644
--- a/src/native/Makefile
+++ b/src/native/Makefile
@@ -23,29 +23,96 @@
 #
 # Makefile for JNI-library libJava*.so
 #
-# $Author: Bablokb $
-# $Revision: 1.9 $
+# $Author: bablokb $
+# $Revision: 1.13 $
 #
 
-.PHONY: all lib clean
+export 
 
-SO := $(patsubst %,$(ROOTDIR)/lib%.so,$(T_LIBS))
+.PHONY: org_gnu_readline_Readline.o
+
+ROOTDIR=../..
+BUILDDIR=$(ROOTDIR)/build
+
+ifeq (MSC,$(WIN32))
+INCLUDES = -I "c:/Programme/DevStudio/VC/include" \
+			-I $(JAVAINCLUDE) -I $(JAVANATINC)
+LIB = "c:/Programme/DevStudio/VC/lib"
+CC = cl
+OBJ_EXT := obj
+LIB_PRE := 
+LIB_EXT := dll
+CFLAGS=-DWIN32=$(WIN32) -D__IBMC__
+else
+INCLUDES          = -I $(JAVAINCLUDE) -I $(JAVANATINC)
+LIBPATH           = -L/usr/lib/termcap 
+JavaReadline_LIBS = -lreadline -ltermcap -lhistory
+JavaEditline_LIBS = -ledit -ltermcap
+ifeq (cygwin,$(WIN32))
+JavaGetline_LIBS = -lcygwin
+endif
+CC = gcc
+OBJ_EXT := o
+LIB_PRE := lib
+LIB_EXT := so
+CFLAGS=-fPIC -DPOSIX
+endif
+
+
+OBJECTS := org_gnu_readline_Readline.$(OBJ_EXT)
+ifeq ($(TG),JavaGetline)
+OBJECTS += getline.$(OBJ_EXT)
+endif
 
 all: $(T_LIBS) 
 
-lib: $(ROOTDIR)/lib$(TG).so  
+lib: $(ROOTDIR)/$(LIB_PRE)$(TG).$(LIB_EXT)
+
+JavaReadline:
+	make TG=$@ lib
+
+JavaEditline:
+	make TG=$@ lib
 
-Java%:
+JavaGetline:
 	make TG=$@ lib
 
-$(ROOTDIR)/lib%.so: org_gnu_readline_Readline.c org_gnu_readline_Readline.h
+$(ROOTDIR)/$(LIB_PRE)$(TG).$(LIB_EXT): $(OBJECTS)
+ifeq (MSC,$(WIN32))
+	$(CC) $(INCLUDES) -LD $(OBJECTS) -Fe$@
+else
+ifeq (CYGWIN,$(WIN32))
+	$(CC) -s -W1,--base-file,$(ROOTDIR)/lib$(TG).base -o $@ \
+		$(OBJECTS) -W1,-e,_readline_init at 12
+	dlltool --base-file $(ROOTDIR)/lib$(TG).base \
+		--def $(ROOTDIR)/lib$(TG).def \
+		--output-exp $(ROOTDIR)/lib$(TG).exp \
+		--dllname $(ROOTDIR)/lib$(TG).dll
+	$(CC) -s -W1,--base-file $(ROOTDIR)/lib$(TG).base,$(ROOTDIR)/lib$(TG).exp \
+		-o $@ $(OBJECTS) -W1,-e,_readline_init at 12
+	dlltool --base-file $(ROOTDIR)/lib$(TG).base \
+		--def $(ROOTDIR)/lib$(TG).def \
+		--output-exp $(ROOTDIR)/lib$(TG).exp \
+		--dllname $(ROOTDIR)/lib$(TG).dll
+	$(CC) -W1,$(ROOTDIR)/lib$(TG).exp -o $@ \
+		$(OBJECTS) -W1,-e,_readline_init at 12
+else
+	$(CC) -shared $(OBJECTS) $(LIBPATH) $($(TG)_LIBS) -o $@
+endif
+endif
+
+getline.$(OBJ_EXT): getline.c
+	$(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -D$(TG) -c getline.c
+
+org_gnu_readline_Readline.$(OBJ_EXT): org_gnu_readline_Readline.h \
+	                                      org_gnu_readline_Readline.c
 	$(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -D$(TG) \
-	-c org_gnu_readline_Readline.c
-	gcc -shared $(LIBPATH) $($(TG)_LIBS) org_gnu_readline_Readline.o -o $@
+	                                   -c org_gnu_readline_Readline.c
 
 org_gnu_readline_Readline.h: $(BUILDDIR)/org/gnu/readline/Readline.class
-	javah -jni org.gnu.readline.Readline
+	javah -classpath $(BUILDDIR) -jni org.gnu.readline.Readline
 	touch org_gnu_readline_Readline.h
 
 clean:
-	-rm -f $(SO) org_gnu_readline_Readline.h org_gnu_readline_Readline.o
\ No newline at end of file
+	-rm -f org_gnu_readline_Readline.h \
+		org_gnu_readline_Readline.$(OBJ_EXT) getline.$(OBJ_EXT)
diff --git a/src/native/getline.c b/src/native/getline.c
new file mode 100644
index 0000000..54b1432
--- /dev/null
+++ b/src/native/getline.c
@@ -0,0 +1,1149 @@
+#ifndef lint
+static char     rcsid[] =
+"$Id: getline.c,v 1.1 2002/06/25 15:24:26 bablokb Exp $";
+static char    *copyright = "Copyright (C) 1991-1994, Chris Thewalt";
+#endif
+
+/*
+ * Copyright (C) 1991-1994 by Chris Thewalt (thewalt at ce.berkeley.edu)
+ *
+ * Permission to use, copy, modify, and distribute this software 
+ * for any purpose and without fee is hereby granted, provided
+ * that the above copyright notices appear in all copies and that both the
+ * copyright notice and this permission notice appear in supporting
+ * documentation.  This software is provided "as is" without express or
+ * implied warranty.
+ *
+ * Thanks to the following people who have provided enhancements and fixes:
+ *   Ron Ueberschaer, Christoph Keller, Scott Schwartz, Steven List,
+ *   DaviD W. Sanderson, Goran Bostrom, Michael Gleason, Glenn Kasten,
+ *   Edin Hodzic, Eric J Bivona, Kai Uwe Rommel, Danny Quah, Ulrich Betzler,
+ *   V. Phaniraj.
+ */
+
+#include       "getline.h"
+static int      gl_tab();  /* forward reference needed for gl_tab_hook */
+
+/******************** imported interface *********************************/
+
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+#include <signal.h>
+
+extern int      isatty();	
+extern void    *malloc();
+extern void     free();
+
+/********************* readline compatibility ****************************/
+
+char* rl_readline_name;
+
+/********************* exported interface ********************************/
+
+char           *getline();		/* read a line of input */
+void            gl_setwidth();		/* specify width of screen */
+void            gl_histadd();		/* adds entries to hist */
+void		gl_strwidth();		/* to bind gl_strlen */
+
+int 		(*gl_in_hook)() = 0;
+int 		(*gl_out_hook)() = 0;
+int 		(*gl_tab_hook)() = gl_tab;
+
+/******************** internal interface *********************************/
+
+#define BUF_SIZE 1024
+
+static int      gl_init_done = -1;	/* terminal mode flag  */
+static int      gl_termw = 80;		/* actual terminal width */
+static int      gl_scroll = 27;		/* width of EOL scrolling region */
+static int      gl_width = 0;		/* net size available for input */
+static int      gl_extent = 0;		/* how far to redraw, 0 means all */
+static int      gl_overwrite = 0;	/* overwrite mode */
+static int      gl_pos, gl_cnt = 0;     /* position and size of input */
+static char     gl_buf[BUF_SIZE];       /* input buffer */
+static char     gl_killbuf[BUF_SIZE]=""; /* killed text */
+static char    *gl_prompt;		/* to save the prompt string */
+static char     gl_intrc = 0;		/* keyboard SIGINT char */
+static char     gl_quitc = 0;		/* keyboard SIGQUIT char */
+static char     gl_suspc = 0;		/* keyboard SIGTSTP char */
+static char     gl_dsuspc = 0;		/* delayed SIGTSTP char */
+static int      gl_search_mode = 0;	/* search mode flag */
+
+static void     gl_init();		/* prepare to edit a line */
+static void     gl_cleanup();		/* to undo gl_init */
+static void     gl_char_init();		/* get ready for no echo input */
+static void     gl_char_cleanup();	/* undo gl_char_init */
+static size_t 	(*gl_strlen)() = (size_t(*)())strlen; 
+					/* returns printable prompt width */
+
+static void     gl_addchar();		/* install specified char */
+static void     gl_del();		/* del, either left (-1) or cur (0) */
+static void     gl_error();		/* write error msg and die */
+static void     gl_fixup();		/* fixup state variables and screen */
+static int      gl_getc();		/* read one char from terminal */
+static void     gl_kill();		/* delete to EOL */
+static void     gl_newline();		/* handle \n or \r */
+static void     gl_putc();		/* write one char to terminal */
+static void     gl_puts();		/* write a line to terminal */
+static void     gl_redraw();		/* issue \n and redraw all */
+static void     gl_transpose();		/* transpose two chars */
+static void     gl_yank();		/* yank killed text */
+static void     gl_word();		/* move a word */
+
+       void     hist_init();	/* initializes hist pointers */
+static char    *hist_next();	/* return ptr to next item */
+static char    *hist_prev();	/* return ptr to prev item */
+static char    *hist_save();	/* makes copy of a string, without NL */
+
+static void     search_addchar();	/* increment search string */
+static void     search_term();		/* reset with current contents */
+static void     search_back();		/* look back for current string */
+static void     search_forw();		/* look forw for current string */
+
+/************************ nonportable part *********************************/
+
+extern int      write();
+extern void     exit();
+
+#ifdef unix
+#ifndef __unix__
+#define __unix__
+#endif /* not __unix__ */
+#endif /* unix */
+
+#ifdef _IBMR2
+#ifndef __unix__
+#define __unix__
+#endif
+#endif
+
+#ifdef __IBMC__
+#include <io.h>
+#endif
+
+#ifdef __GO32__
+#include <pc.h>
+#undef MSDOS
+#undef __unix__
+#endif
+
+#ifdef MSDOS
+#include <bios.h>
+#endif
+
+#ifdef __unix__
+#ifndef __convexc__
+extern int      read();
+extern int      kill();
+extern int      ioctl();
+#endif /* not __convexc__ */
+#ifdef POSIX		/* use POSIX interface */
+#include <termios.h>
+struct termios  new_termios, old_termios;
+#else /* not POSIX */
+#include <sys/ioctl.h>
+#ifdef M_XENIX	/* does not really use bsd terminal interface */
+#undef TIOCSETN
+#endif /* M_XENIX */
+#ifdef TIOCSETN		/* use BSD interface */
+#include <sgtty.h>
+struct sgttyb   new_tty, old_tty;
+struct tchars   tch;
+struct ltchars  ltch;
+#else			/* use SYSV interface */
+#include <termio.h>
+struct termio   new_termio, old_termio;
+#endif /* TIOCSETN */
+#endif /* POSIX */
+#endif	/* __unix__ */
+
+#ifdef vms
+#include <descrip.h>
+#include <ttdef.h>
+#include <iodef.h>
+#include unixio
+   
+static int   setbuff[2];             /* buffer to set terminal attributes */
+static short chan = -1;              /* channel to terminal */
+struct dsc$descriptor_s descrip;     /* VMS descriptor */
+#endif
+
+static void
+gl_char_init()			/* turn off input echo */
+{
+#ifdef __unix__
+#ifdef POSIX
+    tcgetattr(0, &old_termios);
+    gl_intrc = old_termios.c_cc[VINTR];
+    gl_quitc = old_termios.c_cc[VQUIT];
+#ifdef VSUSP
+    gl_suspc = old_termios.c_cc[VSUSP];
+#endif
+#ifdef VDSUSP
+    gl_dsuspc = old_termios.c_cc[VDSUSP];
+#endif
+    new_termios = old_termios;
+    new_termios.c_iflag &= ~(BRKINT|ISTRIP|IXON|IXOFF);
+    new_termios.c_iflag |= (IGNBRK|IGNPAR);
+    new_termios.c_lflag &= ~(ICANON|ISIG|IEXTEN|ECHO);
+    new_termios.c_cc[VMIN] = 1;
+    new_termios.c_cc[VTIME] = 0;
+    tcsetattr(0, TCSANOW, &new_termios);
+#else				/* not POSIX */
+#ifdef TIOCSETN			/* BSD */
+    ioctl(0, TIOCGETC, &tch);
+    ioctl(0, TIOCGLTC, &ltch);
+    gl_intrc = tch.t_intrc;
+    gl_quitc = tch.t_quitc;
+    gl_suspc = ltch.t_suspc;
+    gl_dsuspc = ltch.t_dsuspc;
+    ioctl(0, TIOCGETP, &old_tty);
+    new_tty = old_tty;
+    new_tty.sg_flags |= RAW;
+    new_tty.sg_flags &= ~ECHO;
+    ioctl(0, TIOCSETN, &new_tty);
+#else				/* SYSV */
+    ioctl(0, TCGETA, &old_termio);
+    gl_intrc = old_termio.c_cc[VINTR];
+    gl_quitc = old_termio.c_cc[VQUIT];
+    new_termio = old_termio;
+    new_termio.c_iflag &= ~(BRKINT|ISTRIP|IXON|IXOFF);
+    new_termio.c_iflag |= (IGNBRK|IGNPAR);
+    new_termio.c_lflag &= ~(ICANON|ISIG|ECHO);
+    new_termio.c_cc[VMIN] = 1;
+    new_termio.c_cc[VTIME] = 0;
+    ioctl(0, TCSETA, &new_termio);
+#endif /* TIOCSETN */
+#endif /* POSIX */
+#endif /* __unix__ */
+
+#ifdef vms
+    descrip.dsc$w_length  = strlen("tt:");
+    descrip.dsc$b_dtype   = DSC$K_DTYPE_T;
+    descrip.dsc$b_class   = DSC$K_CLASS_S;
+    descrip.dsc$a_pointer = "tt:";
+    (void)sys$assign(&descrip,&chan,0,0);
+    (void)sys$qiow(0,chan,IO$_SENSEMODE,0,0,0,setbuff,8,0,0,0,0);
+    setbuff[1] |= TT$M_NOECHO;
+    (void)sys$qiow(0,chan,IO$_SETMODE,0,0,0,setbuff,8,0,0,0,0);
+#endif /* vms */
+}
+
+static void
+gl_char_cleanup()		/* undo effects of gl_char_init */
+{
+#ifdef __unix__
+#ifdef POSIX 
+    tcsetattr(0, TCSANOW, &old_termios);
+#else 			/* not POSIX */
+#ifdef TIOCSETN		/* BSD */
+    ioctl(0, TIOCSETN, &old_tty);
+#else			/* SYSV */
+    ioctl(0, TCSETA, &old_termio);
+#endif /* TIOCSETN */
+#endif /* POSIX */
+#endif /* __unix__ */
+
+#ifdef vms
+    setbuff[1] &= ~TT$M_NOECHO;
+    (void)sys$qiow(0,chan,IO$_SETMODE,0,0,0,setbuff,8,0,0,0,0);
+    sys$dassgn(chan);
+    chan = -1;
+#endif 
+}
+
+#if MSDOS || __EMX__ || __GO32__ || __IBMC__
+int pc_keymap(c)
+int c;
+{
+    switch (c) {
+    case 72: c = 16;   /* up -> ^P */
+        break;
+    case 80: c = 14;   /* down -> ^N */
+        break;
+    case 75: c = 2;    /* left -> ^B */
+        break;
+    case 77: c = 6;    /* right -> ^F */
+        break;
+    case 83: c = 4;    /* delete -> ^D */
+        break;
+    case 71: c = 1;    /* home -> ^A */
+        break;
+    case 79: c = 5;    /* end -> ^E */
+        break;
+    case 82: c =15;    /* insert -> ^O */
+        break;
+    default: c = 0;    /* make it garbage */
+    }
+    return c;
+}
+#endif /* MSDOS || __EMX__ || __GO32__ || __IBMC__ */
+
+static int
+gl_getc()
+/* get a character without echoing it to screen */
+{
+    int             c;
+#ifdef __unix__
+    char            ch;
+#endif
+
+#ifdef __unix__
+    while ((c = read(0, &ch, 1)) == -1) {
+	if (errno != EINTR)
+	    break;
+    }
+    c = (c <= 0)? -1 : ch;
+#endif	/* __unix__ */
+#ifdef MSDOS
+    c = _bios_keybrd(_NKEYBRD_READ);
+#endif  /* MSDOS */
+#ifdef __GO32__
+    c = getkey () ;
+    if (c > 255) c = pc_keymap(c & 0377);
+#endif /* __GO32__ */
+#ifdef __TURBOC__
+    while(!bioskey(1))
+	;
+    c = bioskey(0);
+#endif
+#if MSDOS || __TURBOC__
+    if ((c & 0377) == 224) {
+	c = pc_keymap((c >> 8) & 0377);
+    } else {
+	c &= 0377;
+    }
+#endif /* MSDOS || __TURBOC__ */
+#ifdef __EMX__
+    c = _read_kbd(0, 1, 0);
+    if (c == 224 || c == 0) {
+        c = pc_keymap(_read_kbd(0, 1, 0));
+    } else {
+        c &= 0377;
+    }
+#endif
+#ifdef __IBMC__
+    c=_getch();
+    if (c == 224 || c == 0) {
+        c = pc_keymap(_getch());
+    } else {
+        c &= 0377;
+    }
+#endif
+#ifdef vms
+    if(chan < 0) {
+       c='\0';
+    }
+    (void)sys$qiow(0,chan,IO$_TTYREADALL,0,0,0,&c,1,0,0,0,0);
+    c &= 0177;                        /* get a char */
+#endif
+    return c;
+}
+
+static void
+gl_putc(c)
+int     c;
+{
+    char   ch = c;
+
+    write(1, &ch, 1);
+    if (ch == '\n') {
+	ch = '\r';
+        write(1, &ch, 1);	/* RAW mode needs '\r', does not hurt */
+    }
+}
+
+/******************** fairly portable part *********************************/
+
+static void
+gl_puts(buf)
+char *buf;
+{
+    int len; 
+    
+    if (buf) {
+        len = strlen(buf);
+        write(1, buf, len);
+    }
+}
+
+static void
+gl_error(buf)
+char *buf;
+{
+    int len = strlen(buf);
+
+    gl_cleanup();
+    write(2, buf, len);
+    exit(1);
+}
+
+static void
+gl_init()
+/* set up variables and terminal */
+{
+    if (gl_init_done < 0) {		/* -1 only on startup */
+        hist_init();
+    }
+    if (isatty(0) == 0 || isatty(1) == 0)
+	gl_error("\n*** Error: getline(): not interactive, use stdio.\n");
+    gl_char_init();
+    gl_init_done = 1;
+}
+
+static void
+gl_cleanup()
+/* undo effects of gl_init, as necessary */
+{
+    if (gl_init_done > 0)
+        gl_char_cleanup();
+    gl_init_done = 0;
+}
+
+void
+gl_setwidth(w)
+int  w;
+{
+    if (w > 20) {
+	gl_termw = w;
+	gl_scroll = w / 3;
+    } else {
+	gl_error("\n*** Error: minimum screen width is 21\n");
+    }
+}
+
+char *
+getline(prompt)
+char *prompt;
+{
+    int             c, loc, tmp;
+
+#ifdef __unix__
+    int	            sig;
+#endif
+
+    gl_init();	
+    gl_prompt = (prompt)? prompt : "";
+    gl_buf[0] = 0;
+    if (gl_in_hook)
+	gl_in_hook(gl_buf);
+    gl_fixup(gl_prompt, -2, BUF_SIZE);
+    while ((c = gl_getc()) >= 0) {
+	gl_extent = 0;  	/* reset to full extent */
+	if (isprint(c)) {
+	    if (gl_search_mode)
+	       search_addchar(c);
+	    else
+	       gl_addchar(c);
+	} else {
+	    if (gl_search_mode) {
+	        if (c == '\033' || c == '\016' || c == '\020') {
+	            search_term();
+	            c = 0;     		/* ignore the character */
+		} else if (c == '\010' || c == '\177') {
+		    search_addchar(-1); /* unwind search string */
+		    c = 0;
+		} else if (c != '\022' && c != '\023') {
+		    search_term();	/* terminate and handle char */
+		}
+	    }
+	    switch (c) {
+	      case '\n': case '\r': 			/* newline */
+		gl_newline();
+		gl_cleanup();
+		return gl_buf;
+		/*NOTREACHED*/
+		break; 
+	      case '\001': gl_fixup(gl_prompt, -1, 0);		/* ^A */
+		break;
+	      case '\002': gl_fixup(gl_prompt, -1, gl_pos-1);	/* ^B */
+		break;
+	      case '\004':					/* ^D */
+		if (gl_cnt == 0) {
+		    gl_buf[0] = 0;
+		    gl_cleanup();
+		    gl_putc('\n');
+		    return NULL;
+		} else {
+		    gl_del(0);
+		}
+		break;
+	      case '\005': gl_fixup(gl_prompt, -1, gl_cnt);	/* ^E */
+		break;
+	      case '\006': gl_fixup(gl_prompt, -1, gl_pos+1);	/* ^F */
+		break;
+	      case '\010': case '\177': gl_del(-1);	/* ^H and DEL */
+		break;
+	      case '\t':        				/* TAB */
+                if (gl_tab_hook) {
+		    tmp = gl_pos;
+	            loc = gl_tab_hook(gl_buf, gl_strlen(gl_prompt), &tmp);
+	            if (loc >= 0 || tmp != gl_pos)
+	                gl_fixup(gl_prompt, loc, tmp);
+                }
+		break;
+	      case '\013': gl_kill(gl_pos);			/* ^K */
+		break;
+	      case '\014': gl_redraw();				/* ^L */
+		break;
+	      case '\016': 					/* ^N */
+		strcpy(gl_buf, hist_next());
+                if (gl_in_hook)
+	            gl_in_hook(gl_buf);
+		gl_fixup(gl_prompt, 0, BUF_SIZE);
+		break;
+	      case '\017': gl_overwrite = !gl_overwrite;       	/* ^O */
+		break;
+	      case '\020': 					/* ^P */
+		strcpy(gl_buf, hist_prev());
+                if (gl_in_hook)
+	            gl_in_hook(gl_buf);
+		gl_fixup(gl_prompt, 0, BUF_SIZE);
+		break;
+	      case '\022': search_back(1);			/* ^R */
+		break;
+	      case '\023': search_forw(1);			/* ^S */
+		break;
+	      case '\024': gl_transpose();			/* ^T */
+		break;
+              case '\025': gl_kill(0);				/* ^U */
+		break;
+	      case '\031': gl_yank();				/* ^Y */
+		break;
+	      case '\033':				/* ansi arrow keys */
+		c = gl_getc();
+		if (c == '[') {
+		    switch(c = gl_getc()) {
+		      case 'A':             			/* up */
+		        strcpy(gl_buf, hist_prev());
+                        if (gl_in_hook)
+	                    gl_in_hook(gl_buf);
+		        gl_fixup(gl_prompt, 0, BUF_SIZE);
+		        break;
+		      case 'B':                         	/* down */
+		        strcpy(gl_buf, hist_next());
+                        if (gl_in_hook)
+	                    gl_in_hook(gl_buf);
+		        gl_fixup(gl_prompt, 0, BUF_SIZE);
+		        break;
+		      case 'C': gl_fixup(gl_prompt, -1, gl_pos+1); /* right */
+		        break;
+		      case 'D': gl_fixup(gl_prompt, -1, gl_pos-1); /* left */
+		        break;
+		      default: gl_putc('\007');         /* who knows */
+		        break;
+		    }
+		} else if (c == 'f' || c == 'F') {
+		    gl_word(1);
+		} else if (c == 'b' || c == 'B') {
+		    gl_word(-1);
+		} else
+		    gl_putc('\007');
+		break;
+	      default:		/* check for a terminal signal */
+#ifdef __unix__
+	        if (c > 0) {	/* ignore 0 (reset above) */
+	            sig = 0;
+#ifdef SIGINT
+	            if (c == gl_intrc)
+	                sig = SIGINT;
+#endif
+#ifdef SIGQUIT
+	            if (c == gl_quitc)
+	                sig = SIGQUIT;
+#endif
+#ifdef SIGTSTP
+	            if (c == gl_suspc || c == gl_dsuspc)
+	                sig = SIGTSTP;
+#endif
+                    if (sig != 0) {
+	                gl_cleanup();
+	                kill(0, sig);
+	                gl_init();
+	                gl_redraw();
+			c = 0;
+		    } 
+		}
+#endif /* __unix__ */
+                if (c > 0)
+		    gl_putc('\007');
+		break;
+	    }
+	}
+    }
+    gl_cleanup();
+    gl_buf[0] = 0;
+    return gl_buf;
+}
+
+static void
+gl_addchar(c)
+int c;
+/* adds the character c to the input buffer at current location */
+{
+    int  i;
+
+    if (gl_cnt >= BUF_SIZE - 1)
+	gl_error("\n*** Error: getline(): input buffer overflow\n");
+    if (gl_overwrite == 0 || gl_pos == gl_cnt) {
+        for (i=gl_cnt; i >= gl_pos; i--)
+            gl_buf[i+1] = gl_buf[i];
+        gl_buf[gl_pos] = c;
+        gl_fixup(gl_prompt, gl_pos, gl_pos+1);
+    } else {
+	gl_buf[gl_pos] = c;
+	gl_extent = 1;
+        gl_fixup(gl_prompt, gl_pos, gl_pos+1);
+    }
+}
+
+static void
+gl_yank()
+/* adds the kill buffer to the input buffer at current location */
+{
+    int  i, len;
+
+    len = strlen(gl_killbuf);
+    if (len > 0) {
+	if (gl_overwrite == 0) {
+            if (gl_cnt + len >= BUF_SIZE - 1) 
+	        gl_error("\n*** Error: getline(): input buffer overflow\n");
+            for (i=gl_cnt; i >= gl_pos; i--)
+                gl_buf[i+len] = gl_buf[i];
+	    for (i=0; i < len; i++)
+                gl_buf[gl_pos+i] = gl_killbuf[i];
+            gl_fixup(gl_prompt, gl_pos, gl_pos+len);
+	} else {
+	    if (gl_pos + len > gl_cnt) {
+                if (gl_pos + len >= BUF_SIZE - 1) 
+	            gl_error("\n*** Error: getline(): input buffer overflow\n");
+		gl_buf[gl_pos + len] = 0;
+            }
+	    for (i=0; i < len; i++)
+                gl_buf[gl_pos+i] = gl_killbuf[i];
+	    gl_extent = len;
+            gl_fixup(gl_prompt, gl_pos, gl_pos+len);
+	}
+    } else
+	gl_putc('\007');
+}
+
+static void
+gl_transpose()
+/* switch character under cursor and to left of cursor */
+{
+    int    c;
+
+    if (gl_pos > 0 && gl_cnt > gl_pos) {
+	c = gl_buf[gl_pos-1];
+	gl_buf[gl_pos-1] = gl_buf[gl_pos];
+	gl_buf[gl_pos] = c;
+	gl_extent = 2;
+	gl_fixup(gl_prompt, gl_pos-1, gl_pos);
+    } else
+	gl_putc('\007');
+}
+
+static void
+gl_newline()
+/*
+ * Cleans up entire line before returning to caller. A \n is appended.
+ * If line longer than screen, we redraw starting at beginning
+ */
+{
+    int change = gl_cnt;
+    int len = gl_cnt;
+    int loc = gl_width - 5;	/* shifts line back to start position */
+
+    if (gl_cnt >= BUF_SIZE - 1) 
+        gl_error("\n*** Error: getline(): input buffer overflow\n");
+    if (gl_out_hook) {
+	change = gl_out_hook(gl_buf);
+        len = strlen(gl_buf);
+    } 
+    if (loc > len)
+	loc = len;
+    gl_fixup(gl_prompt, change, loc);	/* must do this before appending \n */
+    gl_buf[len] = '\0';
+/*     gl_buf[len] = '\n'; */
+/*     gl_buf[len+1] = '\0'; */
+    gl_putc('\n');
+}
+
+static void
+gl_del(loc)
+int loc;
+/*
+ * Delete a character.  The loc variable can be:
+ *    -1 : delete character to left of cursor
+ *     0 : delete character under cursor
+ */
+{
+    int i;
+
+    if ((loc == -1 && gl_pos > 0) || (loc == 0 && gl_pos < gl_cnt)) {
+        for (i=gl_pos+loc; i < gl_cnt; i++)
+	    gl_buf[i] = gl_buf[i+1];
+	gl_fixup(gl_prompt, gl_pos+loc, gl_pos+loc);
+    } else
+	gl_putc('\007');
+}
+
+static void
+gl_kill(pos)
+int pos;
+/* delete from pos to the end of line */
+{
+    if (pos < gl_cnt) {
+	strcpy(gl_killbuf, gl_buf + pos);
+	gl_buf[pos] = '\0';
+	gl_fixup(gl_prompt, pos, pos);
+    } else
+	gl_putc('\007');
+}
+
+static void
+gl_word(direction)
+int direction;
+/* move forward or backword one word */
+{
+    int pos = gl_pos;
+
+    if (direction > 0) {		/* forward */
+        while (!isspace(gl_buf[pos]) && pos < gl_cnt) 
+	    pos++;
+	while (isspace(gl_buf[pos]) && pos < gl_cnt)
+	    pos++;
+    } else {				/* backword */
+	if (pos > 0)
+	    pos--;
+	while (isspace(gl_buf[pos]) && pos > 0)
+	    pos--;
+        while (!isspace(gl_buf[pos]) && pos > 0) 
+	    pos--;
+	if (pos < gl_cnt && isspace(gl_buf[pos]))   /* move onto word */
+	    pos++;
+    }
+    gl_fixup(gl_prompt, -1, pos);
+}
+
+static void
+gl_redraw()
+/* emit a newline, reset and redraw prompt and current input line */
+{
+    if (gl_init_done > 0) {
+        gl_putc('\n');
+        gl_fixup(gl_prompt, -2, gl_pos);
+    }
+}
+
+static void
+gl_fixup(prompt, change, cursor)
+char  *prompt;
+int    change, cursor;
+/*
+ * This function is used both for redrawing when input changes or for
+ * moving within the input line.  The parameters are:
+ *   prompt:  compared to last_prompt[] for changes;
+ *   change : the index of the start of changes in the input buffer,
+ *            with -1 indicating no changes, -2 indicating we're on
+ *            a new line, redraw everything.
+ *   cursor : the desired location of the cursor after the call.
+ *            A value of BUF_SIZE can be used  to indicate the cursor should
+ *            move just past the end of the input line.
+ */
+{
+    static int   gl_shift;	/* index of first on screen character */
+    static int   off_right;	/* true if more text right of screen */
+    static int   off_left;	/* true if more text left of screen */
+    static char  last_prompt[80] = "";
+    int          left = 0, right = -1;		/* bounds for redraw */
+    int          pad;		/* how much to erase at end of line */
+    int          backup;        /* how far to backup before fixing */
+    int          new_shift;     /* value of shift based on cursor */
+    int          extra;         /* adjusts when shift (scroll) happens */
+    int          i;
+    int          new_right = -1; /* alternate right bound, using gl_extent */
+    int          l1, l2;
+
+    if (change == -2) {   /* reset */
+	gl_pos = gl_cnt = gl_shift = off_right = off_left = 0;
+	gl_putc('\r');
+	gl_puts(prompt);
+	strcpy(last_prompt, prompt);
+	change = 0;
+        gl_width = gl_termw - gl_strlen(prompt);
+    } else if (strcmp(prompt, last_prompt) != 0) {
+	l1 = gl_strlen(last_prompt);
+	l2 = gl_strlen(prompt);
+	gl_cnt = gl_cnt + l1 - l2;
+	strcpy(last_prompt, prompt);
+	gl_putc('\r');
+	gl_puts(prompt);
+	gl_pos = gl_shift;
+        gl_width = gl_termw - l2;
+	change = 0;
+    }
+    pad = (off_right)? gl_width - 1 : gl_cnt - gl_shift;   /* old length */
+    backup = gl_pos - gl_shift;
+    if (change >= 0) {
+        gl_cnt = strlen(gl_buf);
+        if (change > gl_cnt)
+	    change = gl_cnt;
+    }
+    if (cursor > gl_cnt) {
+	if (cursor != BUF_SIZE)		/* BUF_SIZE means end of line */
+	    gl_putc('\007');
+	cursor = gl_cnt;
+    }
+    if (cursor < 0) {
+	gl_putc('\007');
+	cursor = 0;
+    }
+    if (off_right || (off_left && cursor < gl_shift + gl_width - gl_scroll / 2))
+	extra = 2;			/* shift the scrolling boundary */
+    else 
+	extra = 0;
+    new_shift = cursor + extra + gl_scroll - gl_width;
+    if (new_shift > 0) {
+	new_shift /= gl_scroll;
+	new_shift *= gl_scroll;
+    } else
+	new_shift = 0;
+    if (new_shift != gl_shift) {	/* scroll occurs */
+	gl_shift = new_shift;
+	off_left = (gl_shift)? 1 : 0;
+	off_right = (gl_cnt > gl_shift + gl_width - 1)? 1 : 0;
+        left = gl_shift;
+	new_right = right = (off_right)? gl_shift + gl_width - 2 : gl_cnt;
+    } else if (change >= 0) {		/* no scroll, but text changed */
+	if (change < gl_shift + off_left) {
+	    left = gl_shift;
+	} else {
+	    left = change;
+	    backup = gl_pos - change;
+	}
+	off_right = (gl_cnt > gl_shift + gl_width - 1)? 1 : 0;
+	right = (off_right)? gl_shift + gl_width - 2 : gl_cnt;
+	new_right = (gl_extent && (right > left + gl_extent))? 
+	             left + gl_extent : right;
+    }
+    pad -= (off_right)? gl_width - 1 : gl_cnt - gl_shift;
+    pad = (pad < 0)? 0 : pad;
+    if (left <= right) {		/* clean up screen */
+	for (i=0; i < backup; i++)
+	    gl_putc('\b');
+	if (left == gl_shift && off_left) {
+	    gl_putc('$');
+	    left++;
+        }
+	for (i=left; i < new_right; i++)
+	    gl_putc(gl_buf[i]);
+	gl_pos = new_right;
+	if (off_right && new_right == right) {
+	    gl_putc('$');
+	    gl_pos++;
+	} else { 
+	    for (i=0; i < pad; i++)	/* erase remains of prev line */
+		gl_putc(' ');
+	    gl_pos += pad;
+	}
+    }
+    i = gl_pos - cursor;		/* move to final cursor location */
+    if (i > 0) {
+	while (i--)
+	   gl_putc('\b');
+    } else {
+	for (i=gl_pos; i < cursor; i++)
+	    gl_putc(gl_buf[i]);
+    }
+    gl_pos = cursor;
+}
+
+static int
+gl_tab(buf, offset, loc)
+char  *buf;
+int    offset;
+int   *loc;
+/* default tab handler, acts like tabstops every 8 cols */
+{
+    int i, count, len;
+
+    len = strlen(buf);
+    count = 8 - (offset + *loc) % 8;
+    for (i=len; i >= *loc; i--)
+        buf[i+count] = buf[i];
+    for (i=0; i < count; i++)
+        buf[*loc+i] = ' ';
+    i = *loc;
+    *loc = i + count;
+    return i;
+}
+
+/******************* strlen stuff **************************************/
+
+void gl_strwidth(func)
+size_t (*func)();
+{
+    if (func != 0) {
+	gl_strlen = func;
+    }
+}
+
+/******************* History stuff **************************************/
+
+#ifndef HIST_SIZE
+#define HIST_SIZE 100
+#endif
+
+static int      hist_pos = 0, hist_last = 0;
+static char    *hist_buf[HIST_SIZE];
+
+void hist_init() {
+    int i;
+
+    hist_buf[0] = "";
+    for (i=1; i < HIST_SIZE; i++)
+	hist_buf[i] = (char *)0;
+}
+
+void
+gl_histadd(buf)
+char *buf;
+{
+    static char *prev = 0;
+    char *p = buf;
+    int len;
+
+    /* in case we call gl_histadd() before we call getline() */
+    if (gl_init_done < 0) {		/* -1 only on startup */
+        hist_init();
+        gl_init_done = 0;
+    }
+    while (*p == ' ' || *p == '\t' || *p == '\n') 
+	p++;
+    if (*p) {
+	len = strlen(buf);
+	if (strchr(p, '\n')) 	/* previously line already has NL stripped */
+	    len--;
+	if (prev == 0 || strlen(prev) != len || 
+			    strncmp(prev, buf, len) != 0) {
+            hist_buf[hist_last] = hist_save(buf);
+	    prev = hist_buf[hist_last];
+            hist_last = (hist_last + 1) % HIST_SIZE;
+            if (hist_buf[hist_last] && *hist_buf[hist_last]) {
+	        free(hist_buf[hist_last]);
+            }
+	    hist_buf[hist_last] = "";
+	}
+    }
+    hist_pos = hist_last;
+}
+
+static char *
+hist_prev()
+/* loads previous hist entry into input buffer, sticks on first */
+{
+    char *p = 0;
+    int   next = (hist_pos - 1 + HIST_SIZE) % HIST_SIZE;
+
+    if (hist_buf[hist_pos] != 0 && next != hist_last) {
+        hist_pos = next;
+        p = hist_buf[hist_pos];
+    } 
+    if (p == 0) {
+	p = "";
+	gl_putc('\007');
+    }
+    return p;
+}
+
+static char *
+hist_next()
+/* loads next hist entry into input buffer, clears on last */
+{
+    char *p = 0;
+
+    if (hist_pos != hist_last) {
+        hist_pos = (hist_pos+1) % HIST_SIZE;
+	p = hist_buf[hist_pos];
+    } 
+    if (p == 0) {
+	p = "";
+	gl_putc('\007');
+    }
+    return p;
+}
+
+static char *
+hist_save(p)
+char *p;
+/* makes a copy of the string */
+{
+    char *s = 0;
+    int   len = strlen(p);
+    char *nl = strchr(p, '\n');
+
+    if (nl) {
+        if ((s = malloc(len)) != 0) {
+            strncpy(s, p, len-1);
+	    s[len-1] = 0;
+	}
+    } else {
+        if ((s = malloc(len+1)) != 0) {
+            strcpy(s, p);
+        }
+    }
+    if (s == 0) 
+	gl_error("\n*** Error: hist_save() failed on malloc\n");
+    return s;
+}
+
+/******************* Search stuff **************************************/
+
+static char  search_prompt[101];  /* prompt includes search string */
+static char  search_string[100];
+static int   search_pos = 0;      /* current location in search_string */
+static int   search_forw_flg = 0; /* search direction flag */
+static int   search_last = 0;	  /* last match found */
+
+static void  
+search_update(c)
+int c;
+{
+    if (c == 0) {
+	search_pos = 0;
+        search_string[0] = 0;
+        search_prompt[0] = '?';
+        search_prompt[1] = ' ';
+        search_prompt[2] = 0;
+    } else if (c > 0) {
+        search_string[search_pos] = c;
+        search_string[search_pos+1] = 0;
+        search_prompt[search_pos] = c;
+        search_prompt[search_pos+1] = '?';
+        search_prompt[search_pos+2] = ' ';
+        search_prompt[search_pos+3] = 0;
+	search_pos++;
+    } else {
+	if (search_pos > 0) {
+	    search_pos--;
+            search_string[search_pos] = 0;
+            search_prompt[search_pos] = '?';
+            search_prompt[search_pos+1] = ' ';
+            search_prompt[search_pos+2] = 0;
+	} else {
+	    gl_putc('\007');
+	    hist_pos = hist_last;
+	}
+    }
+}
+
+static void 
+search_addchar(c)
+int  c;
+{
+    char *loc;
+
+    search_update(c);
+    if (c < 0) {
+	if (search_pos > 0) {
+	    hist_pos = search_last;
+	} else {
+	    gl_buf[0] = 0;
+	    hist_pos = hist_last;
+	}
+	strcpy(gl_buf, hist_buf[hist_pos]);
+    }
+    if ((loc = strstr(gl_buf, search_string)) != 0) {
+	gl_fixup(search_prompt, 0, loc - gl_buf);
+    } else if (search_pos > 0) {
+        if (search_forw_flg) {
+	    search_forw(0);
+        } else {
+	    search_back(0);
+        }
+    } else {
+	gl_fixup(search_prompt, 0, 0);
+    }
+}
+
+static void     
+search_term()
+{
+    gl_search_mode = 0;
+    if (gl_buf[0] == 0)		/* not found, reset hist list */
+        hist_pos = hist_last;
+    if (gl_in_hook)
+	gl_in_hook(gl_buf);
+    gl_fixup(gl_prompt, 0, gl_pos);
+}
+
+static void     
+search_back(new_search)
+int new_search;
+{
+    int    found = 0;
+    char  *p, *loc;
+
+    search_forw_flg = 0;
+    if (gl_search_mode == 0) {
+	search_last = hist_pos = hist_last;	
+	search_update(0);	
+	gl_search_mode = 1;
+        gl_buf[0] = 0;
+	gl_fixup(search_prompt, 0, 0);
+    } else if (search_pos > 0) {
+	while (!found) {
+	    p = hist_prev();
+	    if (*p == 0) {		/* not found, done looking */
+	       gl_buf[0] = 0;
+	       gl_fixup(search_prompt, 0, 0);
+	       found = 1;
+	    } else if ((loc = strstr(p, search_string)) != 0) {
+	       strcpy(gl_buf, p);
+	       gl_fixup(search_prompt, 0, loc - p);
+	       if (new_search)
+		   search_last = hist_pos;
+	       found = 1;
+	    } 
+	}
+    } else {
+        gl_putc('\007');
+    }
+}
+
+static void     
+search_forw(new_search)
+int new_search;
+{
+    int    found = 0;
+    char  *p, *loc;
+
+    search_forw_flg = 1;
+    if (gl_search_mode == 0) {
+	search_last = hist_pos = hist_last;	
+	search_update(0);	
+	gl_search_mode = 1;
+        gl_buf[0] = 0;
+	gl_fixup(search_prompt, 0, 0);
+    } else if (search_pos > 0) {
+	while (!found) {
+	    p = hist_next();
+	    if (*p == 0) {		/* not found, done looking */
+	       gl_buf[0] = 0;
+	       gl_fixup(search_prompt, 0, 0);
+	       found = 1;
+	    } else if ((loc = strstr(p, search_string)) != 0) {
+	       strcpy(gl_buf, p);
+	       gl_fixup(search_prompt, 0, loc - p);
+	       if (new_search)
+		   search_last = hist_pos;
+	       found = 1;
+	    } 
+	}
+    } else {
+        gl_putc('\007');
+    }
+}
diff --git a/src/native/getline.h b/src/native/getline.h
new file mode 100644
index 0000000..a10bb47
--- /dev/null
+++ b/src/native/getline.h
@@ -0,0 +1,44 @@
+#ifndef GETLINE_H
+#define GETLINE_H
+
+/* unix systems can #define POSIX to use termios, otherwise 
+ * the bsd or sysv interface will be used 
+ */
+
+/* readline compatibility stuff */
+
+extern char* rl_readline_name;                  /* unused by getline   */
+#define add_history(buffer) gl_histadd(buffer)
+#define readline(buffer)    getline(buffer)
+#define clear_history()     hist_init()
+#define using_history()     hist_init()
+
+#if __STDC__ > 0
+#include <stddef.h>
+
+typedef size_t (*gl_strwidth_proc)(char *);
+
+char           *getline(char *);		/* read a line of input */
+void            gl_setwidth(int);		/* specify width of screen */
+void            gl_histadd(char *);		/* adds entries to hist */
+void		gl_strwidth(gl_strwidth_proc);	/* to bind gl_strlen */
+void            hist_init();
+
+extern int 	(*gl_in_hook)(char *);
+extern int 	(*gl_out_hook)(char *);
+extern int	(*gl_tab_hook)(char *, int, int *);
+
+#else	/* not __STDC__ */
+
+char           *getline();	
+void            gl_setwidth();
+void            gl_histadd();
+void		gl_strwidth();
+
+extern int 	(*gl_in_hook)();
+extern int 	(*gl_out_hook)();
+extern int	(*gl_tab_hook)();
+
+#endif /* __STDC__ */
+
+#endif /* GETLINE_H */
diff --git a/src/native/org_gnu_readline_Readline.c b/src/native/org_gnu_readline_Readline.c
index 3277054..dccc834 100644
--- a/src/native/org_gnu_readline_Readline.c
+++ b/src/native/org_gnu_readline_Readline.c
@@ -24,10 +24,13 @@
  * This file implements the native method interface for class
  * gnu.readline.Readline
  *
- * $Revision: 1.9 $
- * $Author: Bablokb $
+ * $Revision: 1.17 $
+ * $Author: bablokb $
  */
 
+#ifdef WIN32
+#include <windows.h>
+#endif
 #include "org_gnu_readline_Readline.h"
 
 #ifdef JavaReadline
@@ -39,13 +42,253 @@
 #include <editline/readline.h>
 #endif
 
+#ifdef JavaGetline
+#include "getline.h"
+#endif
+
+#include <stdlib.h>
+#include <assert.h>
 #include <string.h>
 #include <errno.h>
+#ifndef WIN32
+#include <unistd.h>
+#endif
 
-#define BUF_LENGTH  1024
+/* -------------------------------------------------------------------------- */
+/* Internal status variables of the backing implementation. The functions     */
+/* [sg]etVar\(String\|Int\)Impl() use these arrays. Since the functions use   */
+/* index-based access, it is important that the variables are in sync with    */
+/* the constants in Readline.java.                                            */
+/* Also, some of the variables are actually read-only. You should check the   */
+/* documentation/source before using setVar                                   */
+/*                                                                            */
+/* TODO: redirect all variables marked as const in globalStringInternals to   */
+/* static buffers, so that free() works in setVarStringImpl                   */
+/* -------------------------------------------------------------------------- */
 
-static char* utf2ucs(const char *utf8, char *ucs, size_t n);
-static char* ucs2utf(const char *ucs, char *utf8, size_t n);
+static int undefinedInternalInt = 0;
+static char* undefinedInternalString = NULL;
+static char undefinedInternalChar = '0';
+
+#ifdef JavaReadline
+static int* globalIntegerInternals[] = {
+  &rl_readline_version,
+  &rl_gnu_readline_p,
+  &rl_readline_state,
+  &rl_editing_mode,
+  &rl_insert_mode,
+  &rl_point,
+  &rl_end,
+  &rl_mark,
+  &rl_done,
+  &rl_pending_input,
+  &rl_dispatching,
+  &rl_explicit_arg,
+  &rl_numeric_arg,
+  &rl_erase_empty_line,
+  &rl_already_prompted,
+  &rl_num_chars_to_read,
+  &rl_catch_signals,
+  &rl_catch_sigwinch,
+  &rl_filename_completion_desired,
+  &rl_filename_quoting_desired,
+  &rl_attempted_completion_over,
+  &rl_completion_type,
+  &rl_completion_append_character,
+  &rl_completion_suppress_append,
+  &rl_completion_query_items,
+  &rl_completion_mark_symlink_dirs,
+  &rl_ignore_completion_duplicates,
+  &rl_inhibit_completion,
+
+  &history_base,
+  &history_length,
+  &history_max_entries,
+  &history_quotes_inhibit_expansion,        /* index: 31 */
+  NULL
+};
+
+static char** globalStringInternals[] = {
+ /* const */ &rl_library_version,
+ /* const */ &rl_readline_name,
+ &rl_prompt,
+ &rl_line_buffer,
+ /* const */ &rl_terminal_name,
+ &rl_executing_macro,
+ /* const */ &rl_basic_word_break_characters,
+ /* const */ &rl_completer_word_break_characters,
+ /* const */ &rl_completer_quote_characters,
+ /* const */ &rl_basic_quote_characters,
+ /* const */ &rl_filename_quote_characters,
+ /* const */ &rl_special_prefixes,
+
+ &history_word_delimiters,
+ &history_no_expand_chars,
+ &history_search_delimiter_chars,        /* index: 14 */
+ NULL
+};
+
+/* unused: needs [sg]etVarCharImpl */
+
+static char* globalCharInternals[] = {
+ &history_expansion_char,
+ &history_subst_char,
+ &history_comment_char,
+ NULL
+};
+#endif
+
+#ifdef JavaEditline
+static int* globalIntegerInternals[] = {
+  &undefinedInternalInt, /*  &rl_readline_version, */
+  &undefinedInternalInt, /*  &rl_gnu_readline_p, */
+  &undefinedInternalInt, /*  &rl_readline_state, */
+  &undefinedInternalInt, /*  &rl_editing_mode, */
+  &undefinedInternalInt, /*  &rl_insert_mode, */
+  &undefinedInternalInt, /*  &rl_point, */
+  &undefinedInternalInt, /*  &rl_end, */
+  &undefinedInternalInt, /*  &rl_mark, */
+  &undefinedInternalInt, /*  &rl_done, */
+  &undefinedInternalInt, /*  &rl_pending_input, */
+  &undefinedInternalInt, /*  &rl_dispatching, */
+  &undefinedInternalInt, /*  &rl_explicit_arg, */
+  &undefinedInternalInt, /*  &rl_numeric_arg, */
+  &undefinedInternalInt, /*  &rl_erase_empty_line, */
+  &undefinedInternalInt, /*  &rl_already_prompted, */
+  &undefinedInternalInt, /*  &rl_num_chars_to_read, */
+  &undefinedInternalInt, /*  &rl_catch_signals, */
+  &undefinedInternalInt, /*  &rl_catch_sigwinch, */
+  &undefinedInternalInt, /*  &rl_filename_completion_desired, */
+  &undefinedInternalInt, /*  &rl_filename_quoting_desired, */
+  &undefinedInternalInt, /*  &rl_attempted_completion_over, */
+  &undefinedInternalInt, /*  &rl_completion_type, */
+  &undefinedInternalInt, /*  &rl_completion_append_character, */
+  &undefinedInternalInt, /*  &rl_completion_suppress_append, */
+  &undefinedInternalInt, /*  &rl_completion_query_items, */
+  &undefinedInternalInt, /*  &rl_completion_mark_symlink_dirs, */
+  &undefinedInternalInt, /*  &rl_ignore_completion_duplicates, */
+  &undefinedInternalInt, /*  &rl_inhibit_completion, */
+
+  &undefinedInternalInt, /*  &history_base, */
+  &undefinedInternalInt, /*  &history_length, */
+  &undefinedInternalInt, /*  &history_max_entries, */
+  &undefinedInternalInt, /*  &history_quotes_inhibit_expansion, */
+  NULL
+};
+
+static char** globalStringInternals[] = {
+  &undefinedInternalString, /* const  &rl_library_version, */
+  &undefinedInternalString, /* const  &rl_readline_name, */
+  &undefinedInternalString, /*  &rl_prompt, */
+  &undefinedInternalString, /*  &rl_line_buffer, */
+  &undefinedInternalString, /* const  &rl_terminal_name, */
+  &undefinedInternalString, /*  &rl_executing_macro, */
+  &undefinedInternalString, /* const  &rl_basic_word_break_characters, */
+  &undefinedInternalString, /* const  &rl_completer_word_break_characters, */
+  &undefinedInternalString, /* const  &rl_completer_quote_characters, */
+  &undefinedInternalString, /* const  &rl_basic_quote_characters, */
+  &undefinedInternalString, /* const  &rl_filename_quote_characters, */
+  &undefinedInternalString, /* const  &rl_special_prefixes, */
+
+  &undefinedInternalString, /*  &history_word_delimiters, */
+  &undefinedInternalString, /*  &history_no_expand_chars, */
+  &undefinedInternalString, /*  &history_search_delimiter_chars */
+};
+
+/* unused: needs [sg]etVarCharImpl */
+
+static char* globalCharInternals[] = {
+  &undefinedInternalChar, /*  &history_expansion_char, */
+  &undefinedInternalChar, /*  &history_subst_char, */
+  &undefinedInternalChar, /*  &history_comment_char */
+};
+#endif
+
+#ifdef JavaGetline
+static int* globalIntegerInternals[] = {
+  &undefinedInternalInt, /*  &rl_readline_version, */
+  &undefinedInternalInt, /*  &rl_gnu_readline_p, */
+  &undefinedInternalInt, /*  &rl_readline_state, */
+  &undefinedInternalInt, /*  &rl_editing_mode, */
+  &undefinedInternalInt, /*  &rl_insert_mode, */
+  &undefinedInternalInt, /*  &rl_point, */
+  &undefinedInternalInt, /*  &rl_end, */
+  &undefinedInternalInt, /*  &rl_mark, */
+  &undefinedInternalInt, /*  &rl_done, */
+  &undefinedInternalInt, /*  &rl_pending_input, */
+  &undefinedInternalInt, /*  &rl_dispatching, */
+  &undefinedInternalInt, /*  &rl_explicit_arg, */
+  &undefinedInternalInt, /*  &rl_numeric_arg, */
+  &undefinedInternalInt, /*  &rl_erase_empty_line, */
+  &undefinedInternalInt, /*  &rl_already_prompted, */
+  &undefinedInternalInt, /*  &rl_num_chars_to_read, */
+  &undefinedInternalInt, /*  &rl_catch_signals, */
+  &undefinedInternalInt, /*  &rl_catch_sigwinch, */
+  &undefinedInternalInt, /*  &rl_filename_completion_desired, */
+  &undefinedInternalInt, /*  &rl_filename_quoting_desired, */
+  &undefinedInternalInt, /*  &rl_attempted_completion_over, */
+  &undefinedInternalInt, /*  &rl_completion_type, */
+  &undefinedInternalInt, /*  &rl_completion_append_character, */
+  &undefinedInternalInt, /*  &rl_completion_suppress_append, */
+  &undefinedInternalInt, /*  &rl_completion_query_items, */
+  &undefinedInternalInt, /*  &rl_completion_mark_symlink_dirs, */
+  &undefinedInternalInt, /*  &rl_ignore_completion_duplicates, */
+  &undefinedInternalInt, /*  &rl_inhibit_completion, */
+
+  &undefinedInternalInt, /*  &history_base, */
+  &undefinedInternalInt, /*  &history_length, */
+  &undefinedInternalInt, /*  &history_max_entries, */
+  &undefinedInternalInt, /*  &history_quotes_inhibit_expansion, */
+  NULL
+};
+
+static char** globalStringInternals[] = {
+  &undefinedInternalString, /* const  &rl_library_version, */
+  &undefinedInternalString, /* const  &rl_readline_name, */
+  &undefinedInternalString, /*  &rl_prompt, */
+  &undefinedInternalString, /*  &rl_line_buffer, */
+  &undefinedInternalString, /* const  &rl_terminal_name, */
+  &undefinedInternalString, /*  &rl_executing_macro, */
+  &undefinedInternalString, /* const  &rl_basic_word_break_characters, */
+  &undefinedInternalString, /* const  &rl_completer_word_break_characters, */
+  &undefinedInternalString, /* const  &rl_completer_quote_characters, */
+  &undefinedInternalString, /* const  &rl_basic_quote_characters, */
+  &undefinedInternalString, /* const  &rl_filename_quote_characters, */
+  &undefinedInternalString, /* const  &rl_special_prefixes, */
+
+  &undefinedInternalString, /*  &history_word_delimiters, */
+  &undefinedInternalString, /*  &history_no_expand_chars, */
+  &undefinedInternalString, /*  &history_search_delimiter_chars */
+};
+
+/* unused: needs [sg]etVarCharImpl */
+
+static char* globalCharInternals[] = {
+  &undefinedInternalChar, /*  &history_expansion_char, */
+  &undefinedInternalChar, /*  &history_subst_char, */
+  &undefinedInternalChar, /*  &history_comment_char */
+};
+#endif
+
+/* -------------------------------------------------------------------------- */
+/* Global buffer. The buffer is allocated when needed and grows in steps of   */
+/* 1024. It is never freed, but this is not a problem since in realistic      */
+/* environments it should never be larger than a few KB. This strategy will   */
+/* prevent constant malloc/free-cycles and keeps the code clean.              */
+/*                                                                            */
+/* TODO: buffer is changed by utf82ucs and ucs2utf8, but this is not really   */
+/*       transparent. Add some additional comments.                           */
+/*       Change the variable name buffer to globalBuffer.                     */
+/* -------------------------------------------------------------------------- */
+
+static char*  buffer = NULL;
+static size_t bufLength = 0;
+
+static char*  word_break_buffer = NULL;
+
+static char* utf2ucs(const char *utf8);
+static char* ucs2utf(const char *ucs);
+static int   allocBuffer(size_t n);
 
 static jobject   jniObject;
 static jmethodID jniMethodId;
@@ -71,7 +314,9 @@ JNIEXPORT void JNICALL Java_org_gnu_readline_Readline_initReadlineImpl
 #ifdef JavaReadline
    rl_catch_signals = 0; // don't install signal handlers in JNI code.
 #endif
+#ifndef JavaGetline
    rl_initialize();
+#endif
    using_history();
 }
 
@@ -79,21 +324,63 @@ JNIEXPORT void JNICALL Java_org_gnu_readline_Readline_initReadlineImpl
 /* Reset readline's internal states and terminal.
 /* -------------------------------------------------------------------------- */
 
+#ifndef JavaGetline
 JNIEXPORT void JNICALL Java_org_gnu_readline_Readline_cleanupReadlineImpl
                               (JNIEnv *env, jclass theClass) {
+#ifdef JavaReadline
     rl_free_line_state();
     rl_cleanup_after_signal();
+#endif
 }
+#endif
 
 
 /* -------------------------------------------------------------------------- */
+/* Report, if we have a terminal
+/* -------------------------------------------------------------------------- */
+
+#ifndef JavaGetline
+JNIEXPORT jboolean JNICALL Java_org_gnu_readline_Readline_hasTerminalImpl
+                              (JNIEnv *env, jclass theClass) {
+    return (jboolean) (isatty( STDIN_FILENO ) ? JNI_TRUE : JNI_FALSE);
+}
+#endif
+
+/* -------------------------------------------------------------------------- */
+/* Add line to history                                                        */
+/* -------------------------------------------------------------------------- */
+
+JNIEXPORT void JNICALL Java_org_gnu_readline_Readline_addToHistoryImpl
+                               (JNIEnv *env, jclass theClass, jstring jline) {
+
+  const char *line;
+  jboolean is_copy;
+
+  line = (*env)->GetStringUTFChars(env,jline,&is_copy);
+  if (!utf2ucs(line)) {
+    jclass newExcCls;
+    if (is_copy == JNI_TRUE)
+      (*env)->ReleaseStringUTFChars(env, jline, line);
+    newExcCls = (*env)->FindClass(env,"java/io/UnsupportedEncodingException");
+    if (newExcCls != NULL)
+      (*env)->ThrowNew(env,newExcCls,"");
+    return;
+  }
+
+  if (is_copy == JNI_TRUE)
+    (*env)->ReleaseStringUTFChars(env, jline, line);
+
+  add_history(buffer);
+  return;
+}
+
+/* -------------------------------------------------------------------------- */
 /* Prompt for input. "Main" readline function.          .                     */
 /* -------------------------------------------------------------------------- */
 
 JNIEXPORT jstring JNICALL Java_org_gnu_readline_Readline_readlineImpl
                                (JNIEnv *env, jclass theClass, jstring jprompt) {
 
-  char buffer[BUF_LENGTH];
   const char *prompt;
   char *input;
   jboolean is_copy;
@@ -101,7 +388,7 @@ JNIEXPORT jstring JNICALL Java_org_gnu_readline_Readline_readlineImpl
   /* retrieve prompt argument and convert to ucs ---------------------------- */
 
   prompt = (*env)->GetStringUTFChars(env,jprompt,&is_copy);
-  if (!utf2ucs(prompt,buffer,BUF_LENGTH)) {
+  if (!utf2ucs(prompt)) {
     jclass newExcCls;
     if (is_copy == JNI_TRUE)
       (*env)->ReleaseStringUTFChars(env, jprompt, prompt);
@@ -123,13 +410,93 @@ JNIEXPORT jstring JNICALL Java_org_gnu_readline_Readline_readlineImpl
       (*env)->ThrowNew(env,newExcCls,"");
     return NULL;
   } else if (*input) {
-    add_history(input);
-    ucs2utf(input,buffer,BUF_LENGTH);
+    ucs2utf(input);
     return (*env)->NewStringUTF(env,buffer);
   } else
     return NULL;
 }
 
+/* -------------------------------------------------------------------------- */
+/* Get current history buffer                                                 */
+/* -------------------------------------------------------------------------- */
+
+#ifndef JavaGetline
+JNIEXPORT void JNICALL Java_org_gnu_readline_Readline_getHistoryImpl
+                                (JNIEnv *env, jclass theClass, jobject jcoll) {
+  jclass cls;
+  jmethodID mid;
+  jstring jline;
+#ifdef JavaReadline
+  HIST_ENTRY **hist;
+#endif
+#ifdef JavaEditline
+  HIST_ENTRY *histSingle;
+  int pos;
+#endif
+
+  cls = (*env)->GetObjectClass(env,jcoll);
+  mid = (*env)->GetMethodID(env,cls,"add","(Ljava/lang/Object;)Z");
+
+#ifdef JavaReadline
+  hist = history_list();
+  if (hist != NULL) {
+    while (*hist != NULL) {
+      jline = (*env)->NewStringUTF(env,(*hist)->line);
+      (*env)->CallBooleanMethod(env,jcoll,mid,jline);
+      hist++;
+    }
+  }
+#endif
+
+#ifdef JavaEditline
+  for (pos = 0; pos < history_length; pos++) {
+    histSingle = history_get(pos + 1);
+    if (histSingle) {
+      ucs2utf(histSingle->line);
+      jline = (*env)->NewStringUTF(env,buffer);
+      (*env)->CallBooleanMethod(env,jcoll,mid,jline);
+    }
+  }
+#endif
+}
+#endif
+
+/* -------------------------------------------------------------------------- */
+/* Clear the current history buffer                                           */
+/* -------------------------------------------------------------------------- */
+
+JNIEXPORT void JNICALL Java_org_gnu_readline_Readline_clearHistoryImpl
+                                               (JNIEnv *env, jclass theClass) {
+  clear_history();
+}
+
+/* -------------------------------------------------------------------------- */
+/* Get nth entry from history file                                            */
+/* -------------------------------------------------------------------------- */
+
+#ifndef JavaGetline
+JNIEXPORT jstring JNICALL Java_org_gnu_readline_Readline_getHistoryLineImpl
+                                       (JNIEnv *env, jclass theClass, jint i) {
+  HIST_ENTRY *hist = NULL;
+
+  if ((hist = history_get ((int) (i + 1))) != NULL) {
+    ucs2utf(hist->line);
+    return (*env)->NewStringUTF(env,buffer);
+  }
+  return NULL;
+}
+#endif
+
+/* -------------------------------------------------------------------------- */
+/* Get the size of the history buffer.                                        */
+/* -------------------------------------------------------------------------- */
+
+#ifndef JavaGetline
+JNIEXPORT jint JNICALL Java_org_gnu_readline_Readline_getHistorySizeImpl
+                                               (JNIEnv *env, jclass theClass) {
+  return (jint) history_length;
+}
+#endif
 
 /* -------------------------------------------------------------------------- */
 /* Read keybindings from file.                                                */
@@ -138,14 +505,13 @@ JNIEXPORT jstring JNICALL Java_org_gnu_readline_Readline_readlineImpl
 #ifdef JavaReadline
 JNIEXPORT void JNICALL Java_org_gnu_readline_Readline_readInitFileImpl
                             (JNIEnv *env, jclass theClass, jstring jfilename) {
-  char buffer[BUF_LENGTH];
   const char *filename;
   jboolean is_copy;
 
   /* retrieve filename argument and convert to ucs -------------------------- */
 
   filename = (*env)->GetStringUTFChars(env,jfilename,&is_copy);
-  if (!utf2ucs(filename,buffer,BUF_LENGTH)) {
+  if (!utf2ucs(filename)) {
     jclass newExcCls;
     if (is_copy == JNI_TRUE)
       (*env)->ReleaseStringUTFChars(env,jfilename,filename);
@@ -176,14 +542,13 @@ JNIEXPORT void JNICALL Java_org_gnu_readline_Readline_readInitFileImpl
 #ifdef JavaReadline
 JNIEXPORT jboolean JNICALL Java_org_gnu_readline_Readline_parseAndBindImpl
                                 (JNIEnv *env, jclass theClass, jstring jline) {
-  char buffer[BUF_LENGTH];
   const char *line;
   jboolean is_copy;
 
   /* retrieve line argument and convert to ucs -------------------------- */
 
   line = (*env)->GetStringUTFChars(env,jline,&is_copy);
-  if (!utf2ucs(line,buffer,BUF_LENGTH)) {
+  if (!utf2ucs(line)) {
     jclass newExcCls;
     if (is_copy == JNI_TRUE)
       (*env)->ReleaseStringUTFChars(env,jline,line);
@@ -208,16 +573,16 @@ JNIEXPORT jboolean JNICALL Java_org_gnu_readline_Readline_parseAndBindImpl
 /* Read history file                                                          */
 /* -------------------------------------------------------------------------- */
 
+#ifndef JavaGetline
 JNIEXPORT void JNICALL Java_org_gnu_readline_Readline_readHistoryFileImpl
                             (JNIEnv *env, jclass theClass, jstring jfilename) {
-  char buffer[BUF_LENGTH];
   const char *filename;
   jboolean is_copy;
     
   /* retrieve filename argument and convert to ucs -------------------------- */
 
   filename = (*env)->GetStringUTFChars(env,jfilename,&is_copy);
-  if (!utf2ucs(filename,buffer,BUF_LENGTH)) {
+  if (!utf2ucs(filename)) {
     jclass newExcCls;
     if (is_copy == JNI_TRUE)
       (*env)->ReleaseStringUTFChars(env,jfilename,filename);
@@ -233,21 +598,22 @@ JNIEXPORT void JNICALL Java_org_gnu_readline_Readline_readHistoryFileImpl
 
   read_history(buffer);
 }
+#endif
 
 /* -------------------------------------------------------------------------- */
 /* Write history file                                                         */
 /* -------------------------------------------------------------------------- */
 
+#ifndef JavaGetline
 JNIEXPORT void JNICALL Java_org_gnu_readline_Readline_writeHistoryFileImpl
                             (JNIEnv *env, jclass theClass, jstring jfilename) {
-  char buffer[BUF_LENGTH];
   const char *filename;
   jboolean is_copy;
   
   /* retrieve filename argument and convert to ucs -------------------------- */
 
   filename = (*env)->GetStringUTFChars(env,jfilename,&is_copy);
-  if (!utf2ucs(filename,buffer,BUF_LENGTH)) {
+  if (!utf2ucs(filename)) {
     jclass newExcCls;
     if (is_copy == JNI_TRUE)
       (*env)->ReleaseStringUTFChars(env,jfilename,filename);
@@ -263,12 +629,14 @@ JNIEXPORT void JNICALL Java_org_gnu_readline_Readline_writeHistoryFileImpl
 
   write_history(buffer);
 }
+#endif
 
 
 /* -------------------------------------------------------------------------- */
 /* Completer function, visible to the readline library                        */
 /* -------------------------------------------------------------------------- */
 
+#ifndef JavaGetline
 const char *java_completer(char *text, int state) {
   jstring jtext;
   jstring completion;
@@ -290,11 +658,13 @@ const char *java_completer(char *text, int state) {
   line = (*jniEnv)->GetStringUTFChars(jniEnv,completion,&is_copy);
   return line;
 }
+#endif
   
 /* -------------------------------------------------------------------------- */
 /* Install completer object                                                   */
 /* -------------------------------------------------------------------------- */
 
+#ifndef JavaGetline
 JNIEXPORT void JNICALL Java_org_gnu_readline_Readline_setCompleterImpl
                                       (JNIEnv *env, jclass class, jobject obj) {
   
@@ -318,28 +688,36 @@ JNIEXPORT void JNICALL Java_org_gnu_readline_Readline_setCompleterImpl
       rl_completion_entry_function = NULL;
       return;
     }
-    rl_completion_entry_function = (Function*)java_completer;
+#ifdef JavaEditline
+    rl_completion_entry_function = (CPFunction *) java_completer;
+#else
+    rl_completion_entry_function = (rl_compentry_func_t *) java_completer;
+#endif
   }
   else {
     rl_completion_entry_function = NULL;
   }
 }
+#endif
 
 /* -------------------------------------------------------------------------- */
 /* Returns rl_line_buffer
 /* -------------------------------------------------------------------------- */
 
+#ifndef JavaGetline
 JNIEXPORT jstring JNICALL 
              Java_org_gnu_readline_Readline_getLineBufferImpl
                                                  (JNIEnv * env, jclass class) {
   jniEnv = env;
   return (*jniEnv)->NewStringUTF(jniEnv, rl_line_buffer);
 }
+#endif
 
 /* -------------------------------------------------------------------------- */
 /* Returns rl_completer_word_break_characters                                 */
 /* -------------------------------------------------------------------------- */
 
+#ifndef JavaGetline
 JNIEXPORT jstring JNICALL 
              Java_org_gnu_readline_Readline_getWordBreakCharactersImpl
                                                  (JNIEnv * env, jclass class) {
@@ -357,13 +735,15 @@ JNIEXPORT jstring JNICALL
 
   return word_break_characters;
 }
+#endif
 
 /* -------------------------------------------------------------------------- */
 /* Sets rl_completer_word_break_characters                                    */
+/* You should not use this function, since rl_completer_word_break_characters */
+/* is const char* !!!                                                         */
 /* -------------------------------------------------------------------------- */
 
-static char word_break_buffer[BUF_LENGTH];
-
+#ifndef JavaGetline
 JNIEXPORT void JNICALL 
                     Java_org_gnu_readline_Readline_setWordBreakCharactersImpl
                       (JNIEnv * env, jclass class, jstring jword_break_chars) {
@@ -371,7 +751,7 @@ JNIEXPORT void JNICALL
   jboolean is_copy;
   
   word_break_chars = (*env)->GetStringUTFChars(env,jword_break_chars,&is_copy);
-  if (!utf2ucs(word_break_chars,word_break_buffer,BUF_LENGTH)) {
+  if (!utf2ucs(word_break_chars)) {
     jclass newExcCls;
     if (is_copy == JNI_TRUE)
       (*env)->ReleaseStringUTFChars(env,jword_break_chars,word_break_chars);
@@ -383,20 +763,129 @@ JNIEXPORT void JNICALL
   if (is_copy == JNI_TRUE)
     (*env)->ReleaseStringUTFChars(env,jword_break_chars,word_break_chars);
   
+  if (word_break_buffer)
+    free(word_break_buffer);
+  word_break_buffer = strdup(buffer);
+  if (!word_break_buffer) {
+    jclass newExcCls;
+    newExcCls = (*env)->FindClass(env,"java/lang/OutOfMemoryError");
+    if (newExcCls != NULL)
+      (*env)->ThrowNew(env,newExcCls,"");
+    return;    
+  }
   rl_completer_word_break_characters = word_break_buffer;
 }
+#endif
+
+/* -------------------------------------------------------------------------- */
+/* Sets an internal integer variable                                          */
+/* -------------------------------------------------------------------------- */
+
+JNIEXPORT jint JNICALL 
+  Java_org_gnu_readline_Readline_setVarIntImpl(JNIEnv *env, jclass class,
+                                                     jint jindex, jint jvalue) {
+  int oldValue;
+  oldValue = *(globalIntegerInternals[(int) jindex]);
+  *(globalIntegerInternals[(int) jindex]) = (int) jvalue;
+  return (jint) oldValue;
+}
+
+/* -------------------------------------------------------------------------- */
+/* Queries an internal integer variable                                       */
+/* -------------------------------------------------------------------------- */
+
+JNIEXPORT jint JNICALL 
+  Java_org_gnu_readline_Readline_getVarIntImpl(JNIEnv *env, jclass class,
+                                                                   jint jindex) {
+  return (jint) *(globalIntegerInternals[(int) jindex]);
+}
+
+/* -------------------------------------------------------------------------- */
+/* Sets an internal string variable                                           */
+/* -------------------------------------------------------------------------- */
+
+JNIEXPORT jstring JNICALL 
+  Java_org_gnu_readline_Readline_setVarStringImpl(JNIEnv *env, jclass class,
+                                                  jint jindex, jstring jvalue) {
+  char *oldValue;
+  char **value;
+  const char *newValue;
+  jboolean is_copy;
+
+  /* save old value */
+
+  oldValue = strdup(*(globalStringInternals[(int) jindex]));
+  if (!oldValue) {
+    jclass newExcCls;
+    newExcCls = (*env)->FindClass(env,"java/lang/OutOfMemoryError");
+    if (newExcCls != NULL)
+      (*env)->ThrowNew(env,newExcCls,"");
+    return;    
+  }
+
+  /* read new value from argument */
+
+  newValue = (*env)->GetStringUTFChars(env,jvalue,&is_copy);
+  if (!utf2ucs(newValue)) {
+    jclass newExcCls;
+    if (is_copy == JNI_TRUE)
+      (*env)->ReleaseStringUTFChars(env,jvalue,newValue);
+    newExcCls = (*env)->FindClass(env,"java/io/UnsupportedEncodingException");
+    if (newExcCls != NULL)
+      (*env)->ThrowNew(env,newExcCls,"");
+    return;
+  }
+  if (is_copy == JNI_TRUE)
+    (*env)->ReleaseStringUTFChars(env,jvalue,newValue);
+  
+  /* set new value */
+
+  value = globalStringInternals[(int) jindex];
+  // TODO: currently a memory-leak, but otherwise it crashes
+  // free(*value);
+  *value = strdup(buffer);
+  
+  /* return old value */
+  
+  ucs2utf(oldValue);
+  free(oldValue);
+  return (*env)->NewStringUTF(env,buffer);
+}
+
+/* -------------------------------------------------------------------------- */
+/* Queries an internal string variable                                        */
+/* -------------------------------------------------------------------------- */
+
+JNIEXPORT jstring JNICALL 
+  Java_org_gnu_readline_Readline_getVarStringImpl(JNIEnv *env, jclass class,
+                                                                  jint jindex) {
+  char *value;
+  value = *(globalStringInternals[(int) jindex]);
+  if (value) {
+    ucs2utf(value);
+    return (*env)->NewStringUTF(env,buffer);
+  }
+  return NULL;
+}
 
 /* -------------------------------------------------------------------------- */
 /* Convert utf8-string to ucs1-string                   .                     */
 /* -------------------------------------------------------------------------- */
 
-char* utf2ucs(const char *utf8, char *ucs, size_t n) {
+char* utf2ucs(const char *utf8) {
   const char *pin;
-  char *pout;
+  char *pout, *ucs;
   unsigned char current, next;
   int i;
+  size_t n;
 
-  for (i=0,pin=utf8,pout=ucs; i<n && *pin; i++,pin++,pout++) {
+  n = strlen(utf8);
+  if (2*n > bufLength) {
+    if (allocBuffer(2*n))
+      return NULL;
+  }
+
+  for (i=0,pin=utf8,pout=buffer; i<bufLength && *pin; i++,pin++,pout++) {
     current = *pin;
     if (current >= 0xE0) {                   /* we support only two-byte utf8 */
       return NULL;
@@ -411,36 +900,64 @@ char* utf2ucs(const char *utf8, char *ucs, size_t n) {
 	(next & 63);                         /* last six bits of second byte  */
     }
   }
-  if (i<n)
+  if (i<bufLength)
     *pout = '\0';
-  return ucs;
+  return buffer;
 }
 
 /* -------------------------------------------------------------------------- */
 /* Convert ucs1-string to utf8-string                   .                     */
 /* -------------------------------------------------------------------------- */
 
-char* ucs2utf(const char *ucs, char *utf8, size_t n) {
+char* ucs2utf(const char *ucs) {
   const char *pin;
   char *pout;
   unsigned char current;
   int i;
+  size_t n;
+
+  n = strlen(ucs);
+  if (2*n > bufLength) {
+    if (allocBuffer(2*n))
+      return NULL;
+  }
 
-  for (i=0,pin=ucs,pout=utf8; i<n && *pin; i++,pin++,pout++) {
+  for (i=0,pin=ucs,pout=buffer; i<bufLength && *pin; i++,pin++,pout++) {
     current = *pin;
     if (current < 0x80)                      /* one-byte utf8                 */
       *pout = current;
     else {                                   /* two-byte utf8                 */
       *pout = 0xC0 + (current>>6);           /* first two bits                */
       pout++, i++;                           /* examine second byte           */
-      if (i>=n) {                            /* cannot convert last byte      */
+      if (i>=bufLength) {                    /* cannot convert last byte      */
 	*(--pout) = '\0';
-	return utf8;
+	return buffer;
       }
       *pout = 0x80 + (current & 63);         /* last six bits                 */
     }
   }
-  if (i<n)
+  if (i<bufLength)
     *pout = '\0';
-  return utf8;
+  return buffer;
+}
+
+/* -------------------------------------------------------------------------- */
+/* Allocate a buffer of at least the given size         .                     */
+/* -------------------------------------------------------------------------- */
+
+int allocBuffer(size_t newSize) {
+  assert(newSize >= bufLength);
+  newSize = (newSize/1024 + 1) * 1024;
+  buffer = realloc(buffer,newSize);
+  if (buffer == NULL)
+    return 1;
+  bufLength = newSize;
+  return 0;
 }
+
+#ifdef WIN32
+int WINAPI
+readline_init(HANDLE h, DWORD reason, void *foo) {
+  return 1;
+}
+#endif
diff --git a/src/org/Makefile b/src/org/Makefile
deleted file mode 100644
index 2aa9a1d..0000000
--- a/src/org/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
-#**************************************************************************
-#* Makefile for libJavaReadline.so -- load library for JNI wrapper
-#* of GNU readline
-#*
-#* Copyright (c) 1987-1998 Free Software Foundation, Inc.
-#* Java Wrapper Copyright (c) 1998-2001 by Bernhard Bablok (mail at bablokb.de)
-#*
-#* This program is free software; you can redistribute it and#or modify
-#* it under the terms of the GNU Library General Public License as published
-#* by  the Free Software Foundation; either version 2 of the License or
-#* (at your option) any later version.
-#*
-#* This program is distributed in the hope that it will be useful, but
-#* WITHOUT ANY WARRANTY; without even the implied warranty of
-#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#* GNU Library General Public License for more details.
-#*
-#* You should have received a copy of the GNU Library General Public License
-#* along with this program; see the file COPYING.LIB.  If not, write to
-#* the Free Software Foundation Inc., 59 Temple Place - Suite 330,
-#* Boston, MA  02111-1307 USA
-#***************************************************************************
-#
-# $Author: Bablokb $
-# $Revision: 1.2 $
-#
-
-include $(SRCROOT)/mkrules.inc
diff --git a/src/org/gnu/Makefile b/src/org/gnu/Makefile
deleted file mode 100644
index e0b5206..0000000
--- a/src/org/gnu/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
-#**************************************************************************
-#* Makefile for libJavaReadline.so -- load library for JNI wrapper
-#* of GNU readline
-#*
-#* Copyright (c) 1987-1998 Free Software Foundation, Inc.
-#* Java Wrapper Copyright (c) 1998-2001 by Bernhard Bablok (mail at bablokb.de)
-#*
-#* This program is free software; you can redistribute it and#or modify
-#* it under the terms of the GNU Library General Public License as published
-#* by  the Free Software Foundation; either version 2 of the License or
-#* (at your option) any later version.
-#*
-#* This program is distributed in the hope that it will be useful, but
-#* WITHOUT ANY WARRANTY; without even the implied warranty of
-#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#* GNU Library General Public License for more details.
-#*
-#* You should have received a copy of the GNU Library General Public License
-#* along with this program; see the file COPYING.LIB.  If not, write to
-#* the Free Software Foundation Inc., 59 Temple Place - Suite 330,
-#* Boston, MA  02111-1307 USA
-#***************************************************************************
-#
-# $Author: Bablokb $
-# $Revision: 1.2 $
-#
-
-include $(SRCROOT)/mkrules.inc
\ No newline at end of file
diff --git a/src/org/gnu/readline/Makefile b/src/org/gnu/readline/Makefile
deleted file mode 100644
index 93c32b9..0000000
--- a/src/org/gnu/readline/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-#**************************************************************************
-#* Makefile for libJavaReadline.so -- load library for JNI wrapper
-#* of GNU readline
-#*
-#* Copyright (c) 1987-1998 Free Software Foundation, Inc.
-#* Java Wrapper Copyright (c) 1998-2001 by Bernhard Bablok (mail at bablokb.de)
-#*
-#* This program is free software; you can redistribute it and/or modify
-#* it under the terms of the GNU Library General Public License as published
-#* by  the Free Software Foundation; either version 2 of the License or
-#* (at your option) any later version.
-#*
-#* This program is distributed in the hope that it will be useful, but
-#* WITHOUT ANY WARRANTY; without even the implied warranty of
-#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#* GNU Library General Public License for more details.
-#*
-#* You should have received a copy of the GNU Library General Public License
-#* along with this program; see the file COPYING.LIB.  If not, write to
-#* the Free Software Foundation Inc., 59 Temple Place - Suite 330,
-#* Boston, MA  02111-1307 USA
-#***************************************************************************
-#
-# $Author: Bablokb $
-# $Revision: 1.5 $
-#
-
-include $(SRCROOT)/mkrules.inc
-
-$(PACKDIR)/Readline.class: $(PACKDIR)/ReadlineLibrary.class
\ No newline at end of file
diff --git a/src/org/gnu/readline/Readline.java b/src/org/gnu/readline/Readline.java
index 4697928..4aed9f4 100644
--- a/src/org/gnu/readline/Readline.java
+++ b/src/org/gnu/readline/Readline.java
@@ -22,6 +22,7 @@
 package org.gnu.readline;
 
 import java.io.*;
+import java.util.*;
 
 /**
  This class implements basic functionality of the GNU-readline interface. It
@@ -65,12 +66,766 @@ import java.io.*;
 
 </pre>
 
- @version $Revision: 1.18 $
- @author  $Author: Bablokb $
+ @version $Revision: 1.29 $
+ @author  $Author: bablokb $
 */
 
 public class Readline {
+
+  /**
+     Constant to access rl_library_version using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstString RL_LIBRARY_VERSION = 
+    new ReadlineConstString(0, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_readline_name using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstString RL_READLINE_NAME = 
+    new ReadlineConstString(1, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_prompt using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstString RL_PROMPT = 
+    new ReadlineConstString(2, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_line_buffer using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstString RL_LINE_BUFFER = 
+    new ReadlineConstString(3, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_terminal_name using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstString RL_TERMINAL_NAME = 
+    new ReadlineConstString(4, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_executing_macro using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstString RL_EXECUTING_MACRO =
+    new ReadlineConstString(5, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_basic_word_break_characters using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstString RL_BASIC_WORD_BREAK_CHARACTERS =
+    new ReadlineConstString(6, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_completer_word_break_characters using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstString RL_COMPLETER_WORD_BREAK_CHARACTERS = 
+    new ReadlineConstString(7, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_completer_quote_characters using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstString RL_COMPLETER_QUOTE_CHARACTERS = 
+    new ReadlineConstString(8, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_basic_quote_characters using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstString RL_BASIC_QUOTE_CHARACTERS = 
+    new ReadlineConstString(9, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_filename_quote_characters using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstString RL_FILENAME_QUOTE_CHARACTERS = 
+    new ReadlineConstString(10, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_special_prefixes using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstString RL_SPECIAL_PREFIXES = 
+    new ReadlineConstString(11, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access history_word_delimiters using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstString HISTORY_WORD_DELIMITERS = 
+    new ReadlineConstString(12, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+  /**
+     Constant to access history_no_expand_chars using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstString HISTORY_NO_EXPAND_CHARS = 
+    new ReadlineConstString(13, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access history_search_delimiter_chars using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstString HISTORY_SEARCH_DELIMITERS = 
+    new ReadlineConstString(14, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_readline_version using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_READLINE_VERSION = 
+    new ReadlineConstInt(0, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_gnu_readline_p using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_GNU_READLINE_P = 
+    new ReadlineConstInt(1, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_readline_state using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_READLINE_STATE = 
+    new ReadlineConstInt(2, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_editing_mode using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_EDITING_MODE = 
+    new ReadlineConstInt(3, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_insert_mode using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_INSERT_MODE = 
+    new ReadlineConstInt(4, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_point using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_POINT = 
+    new ReadlineConstInt(5, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_end using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
   
+  public final static ReadlineConstInt RL_END = 
+    new ReadlineConstInt(6, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_mark using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_MARK = 
+    new ReadlineConstInt(7, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_done using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_DONE = 
+    new ReadlineConstInt(8, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_pending_input using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_PENDING_INPUT = 
+    new ReadlineConstInt(9, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_dispatching using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_DISPATCHING = 
+    new ReadlineConstInt(10, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_explicit_arg using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_EXPLICIT_ARG = 
+    new ReadlineConstInt(11, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_numeric_arg using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_NUMERIC_ARG = 
+    new ReadlineConstInt(12, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_erase_empty_line using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_ERASE_EMPTY_LINE = 
+    new ReadlineConstInt(13, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_already_prompted using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_ALREADY_PROMPTED = 
+    new ReadlineConstInt(14, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_num_chars_to_read using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_NUM_CHARS_TO_READ = 
+    new ReadlineConstInt(15, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_catch_signals using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_CATCH_SIGNALS = 
+    new ReadlineConstInt(16, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_catch_sigwinch using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_CATCH_SIGWINCH = 
+    new ReadlineConstInt(17, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_filename_completion_desired using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_FILENAME_COMPLETION_DESIRED = 
+    new ReadlineConstInt(18, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_filename_quoting_desired using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_FILENAME_QUOTING_DESIRED = 
+    new ReadlineConstInt(19, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_attempted_completion_over using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_ATTEMPTED_COMPLETION_OVER = 
+    new ReadlineConstInt(20, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_completion_type using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_COMPLETION_TYPE = 
+    new ReadlineConstInt(21, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_completion_append_character using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_COMPLETION_APPEND_CHARACTER = 
+    new ReadlineConstInt(22, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_completion_suppress_append using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_COMPLETION_SUPPRESS_APPEND = 
+    new ReadlineConstInt(23, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_completion_query_items using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_COMPLETION_QUERY_ITEMS = 
+    new ReadlineConstInt(24, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_completion_mark_symlink_dirs using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_COMPLETION_MARK_SYMLINK_DIRS = 
+    new ReadlineConstInt(25, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_ignore_completion_duplicates using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_IGNORE_COMPLETION_DUPLICATES = 
+    new ReadlineConstInt(26, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access rl_inhibit_completion using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt RL_INHIBIT_COMPLETION = 
+    new ReadlineConstInt(27, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access history_base using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt HISTORY_BASE = 
+    new ReadlineConstInt(28, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access history_length using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt HISTORY_LENGTH = 
+    new ReadlineConstInt(29, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access history_max_entries using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt HISTORY_MAX_ENTRIES = 
+    new ReadlineConstInt(30, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+  /**
+     Constant to access history_quotes_inhibit_expansion using
+     <code>getVar()</code> or <code>setVar()</code>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>     
+  */
+  
+  public final static ReadlineConstInt HISTORY_QUOTES_EXPANSION = 
+    new ReadlineConstInt(31, new ReadlineLibrary[] 
+      {ReadlineLibrary.GnuReadline});
+
+
+
+  /* ----------------------------------------------------------------------- */
+
   /**
      The currently defined ReadlineCompleter.
   */
@@ -91,6 +846,16 @@ public class Readline {
   private static BufferedReader iReader = null;
 
   /**
+      The current encoding of the BufferedReader. The default is the
+      value of the property <em>readline.encoding</em>. If this
+      property is unset, the default is null, so the BufferedReader
+      will use the default encoding.
+   */
+
+  private static String iEncoding =
+    System.getProperty("readline.encoding", null);
+
+   /**
      Configuration flag: throw an UnsupportedOperationException, if true.
      This value defaults to false.
   */
@@ -102,7 +867,7 @@ public class Readline {
   /**
      Load an implementing backing library. This method might throw an
      UnsatisfiedLinkError in case the native libary is not found in the
-     library path. If you want to have portable program, just catch and 
+     library path. If you want to have a portable program, just catch and 
      ignore that error. JavaReadline will then just use the pure Java fallback
      solution.
 
@@ -132,41 +897,222 @@ public class Readline {
      specific keys. See the file ReadlineTest.java int the test subdir of
      the distribution for an example.
 
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+	  <li>Editline</li>
+	  <li>Getline</li>
+        </ul>
+     </p>
+
      @param applicationName Name of application in initialization file
   */
 
   public static void initReadline(String applicationName) {
-    if (iLib != ReadlineLibrary.PureJava) {
+    if (iLib == ReadlineLibrary.GnuReadline || 
+	iLib == ReadlineLibrary.Editline ||
+	iLib == ReadlineLibrary.Getline)
       initReadlineImpl(applicationName);
-    }
   }
 
   /////////////////////////////////////////////////////////////////////////////
 
   /**
+     Display a prompt on standard output and read a string from standard
+     input. This method returns 'null', if there has been an empty input
+     (user pressed just [RETURN]) and throws an EOFException on end-of-file
+     (C-d). This versino of <tt>readline()</tt> automatically adds the line
+     to the in-memory history; use the other version of <tt>readline()</tt>
+     if you want explicit control over that feature.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+	  <li>Editline</li>
+	  <li>Getline</li>
+	  <li>PureJava</li>
+        </ul>
+     </p>
+
+     @param prompt Prompt to display
+     @return The string the user entered or 'null' if there was no input.
+     @throws EOFException on end-of-file, i.e. CTRL-d input.
+     @see #readline(String,boolean)
+     @see #addHistory()
+  */
+  public static String readline(String prompt) throws EOFException,
+                                    IOException, UnsupportedEncodingException {
+      return readline(prompt,true);
+  }
+
+  /**
      Display a prompt on standard output and read a string from
      standard input. This method returns 'null', if there has
      been an empty input (user pressed just [RETURN]) and throws
      an EOFException on end-of-file (C-d).
 
-     @param prompt Prompt to display
+     @param prompt    Prompt to display
+     @param addToHist <tt>true</tt> to add the line to the history
+                      automatically; <tt>false</tt> to refrain from
+                      adding the line to the history. (You can manually
+                      add the line to the history by calling
+                      <tt>addHistory()</tt>.)
      @return The string the user entered or 'null' if there was no input.
      @throws EOFException on end-of-file, i.e. CTRL-d input.
+     @see #readline(String)
+     @see #addHistory()
   */
 
-  public static String readline(String prompt) throws EOFException, 
-                                    IOException, UnsupportedEncodingException {
-    if (iLib != ReadlineLibrary.PureJava)
-      return readlineImpl(prompt);
-    else {
+  public static String readline(String prompt, boolean addToHist)
+               throws EOFException, IOException, UnsupportedEncodingException {
+    if (iLib != ReadlineLibrary.PureJava) {
+      String line = readlineImpl(prompt);
+      if ((line != null) && (addToHist))
+          addToHistory(line);
+      return line;
+    } else {
       System.out.print(prompt);
-      if (iReader == null)
-        iReader = new BufferedReader(new InputStreamReader(System.in));
+      if (iReader == null) {
+	if (iEncoding == null)
+	  iReader = new BufferedReader(new InputStreamReader(System.in));
+	else
+	  iReader = new BufferedReader(
+			         new InputStreamReader(System.in, iEncoding));
+      }
       String line = iReader.readLine();
       if (line == null)
         throw new EOFException("EOF");
-      return (line.length() == 0) ? null : line;
+      if (line.length() == 0)
+          line = null;
+      return line;
+    }
+  }
+
+  /////////////////////////////////////////////////////////////////////////////
+
+  /**
+     Add a line to the in-memory history.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+	  <li>Editline</li>
+	  <li>Getline</li>
+        </ul>
+     </p>
+
+     @param line  The line to add to the history
+     @throws UnsupportOperationException if underlying library doesn't support
+                                         a history
+  */
+
+  public static void addToHistory(String line) {
+      if (iLib == ReadlineLibrary.GnuReadline || 
+	  iLib == ReadlineLibrary.Editline ||
+	  iLib == ReadlineLibrary.Getline)
+        addToHistoryImpl(line);
+      else if (iThrowException)
+      throw new UnsupportedOperationException();
+  }
+
+  /////////////////////////////////////////////////////////////////////////////
+
+  /**
+     Get the history buffer in a supplied <tt>Collection</tt>.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+	  <li>Editline</li>
+        </ul>
+     </p>
+
+     @param collection  where to store the history
+     @throws UnsupportOperationException if underlying library doesn't support
+                                         a history
+  */
+
+  public static void getHistory(Collection collection) {
+      if (iLib == ReadlineLibrary.GnuReadline ||
+	  iLib == ReadlineLibrary.Editline)
+        getHistoryImpl(collection);
+      else if (iThrowException)
+        throw new UnsupportedOperationException();
+  }
+
+  /////////////////////////////////////////////////////////////////////////////
+
+  /**
+     Get the size, in elements (lines), of the history buffer.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+	  <li>Editline</li>
+        </ul>
+     </p>
+
+     @return the number of lines in the history buffer
+  */
+  public static int getHistorySize() {
+      int result = 0;
+      if (iLib == ReadlineLibrary.GnuReadline ||
+	  iLib == ReadlineLibrary.Editline)
+        result = getHistorySizeImpl();
+      else if (iThrowException)
+        throw new UnsupportedOperationException();
+      return result;
+  }
+
+  /////////////////////////////////////////////////////////////////////////////
+
+  /**
+     Clear the history buffer.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+	  <li>Editline</li>
+        </ul>
+     </p>
+  */
+  public static void clearHistory() {
+      if (iLib == ReadlineLibrary.GnuReadline ||
+	  iLib == ReadlineLibrary.Editline)
+        clearHistoryImpl();
+      else if (iThrowException)
+        throw new UnsupportedOperationException();
+  }      
+
+  /////////////////////////////////////////////////////////////////////////////
+
+  /**
+     Get the specified entry from the history buffer. History buffer entries
+     are numbered from 0 through (<tt>getHistorySize() - 1</tt>), with the
+     oldest entry at index 0.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+	  <li>Editline</li>
+        </ul>
+     </p>
+
+     @param i  the index of the entry to return
+     @return the line at the specified index in the history buffer
+     @throws ArrayIndexOutOfBoundsException index out of range
+  */
+  public static String getHistoryLine(int i) {
+    String s = null;
+    if (iLib == ReadlineLibrary.GnuReadline ||
+	iLib == ReadlineLibrary.Editline) {
+      if ((i < 0) || i >= getHistorySize())
+        throw new ArrayIndexOutOfBoundsException(i);
+      s = getHistoryLineImpl(i);
     }
+    else if (iThrowException)
+      throw new UnsupportedOperationException();
+    return s;
   }
 
   /////////////////////////////////////////////////////////////////////////////
@@ -176,6 +1122,12 @@ public class Readline {
      wrapper to rl_read_init_file(char *filename). Throws IOException if 
      something goes wrong.
 
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>
+
      @param filename Name of file to read bindings from
      @return void
   */
@@ -193,6 +1145,12 @@ public class Readline {
      Parse argument string as if it had been read from `inputrc' file
      and perform key bindings and variable assignments found.
 
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+        </ul>
+     </p>
+
      @param line Simulated line from inputrc file
      @return boolean False in case of error
   */
@@ -210,12 +1168,20 @@ public class Readline {
 
   /**
      Reads a history file into memory
-       @param filename Name of history file to read
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+	  <li>Editline</li>
+        </ul>
+     </p>
+
+     @param filename Name of history file to read
      */
 
   public static void readHistoryFile(String filename)
                               throws EOFException, UnsupportedEncodingException {
-    if (iLib != ReadlineLibrary.PureJava)
+    if (iLib == ReadlineLibrary.GnuReadline || iLib == ReadlineLibrary.Editline)
       readHistoryFileImpl(filename);
     else if (iThrowException)
       throw new UnsupportedOperationException();
@@ -227,12 +1193,19 @@ public class Readline {
   /**
      Writes a history file to disc
 
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+	  <li>Editline</li>
+        </ul>
+     </p>
+
      @param filename Name of history file to write
   */
 
   public static void writeHistoryFile(String filename)
                               throws EOFException, UnsupportedEncodingException {
-    if (iLib != ReadlineLibrary.PureJava)
+    if (iLib == ReadlineLibrary.GnuReadline || iLib == ReadlineLibrary.Editline)
       writeHistoryFileImpl(filename);
     else if (iThrowException)
       throw new UnsupportedOperationException();
@@ -246,12 +1219,20 @@ public class Readline {
      will result in the default behaviour of readline which is filename
      completion.
 
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+	  <li>Editline</li>
+        </ul>
+     </p>
+
      @param rlc An object implementing the ReadlineCompleter interface
   */
     
   public static void setCompleter(ReadlineCompleter rlc) {
     iCompleter = rlc;
-    if (iLib != ReadlineLibrary.PureJava) {
+    if (iLib == ReadlineLibrary.GnuReadline ||
+                                             iLib == ReadlineLibrary.Editline) {
       setCompleterImpl(iCompleter);
     } else if (iThrowException)
       throw new UnsupportedOperationException();
@@ -273,10 +1254,19 @@ public class Readline {
 
   /**
      Reset the readline library and with it, the terminal.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+	  <li>Editline</li>
+        </ul>
+     </p>
+
   */
     
   public static void cleanup() {
-    if (iLib != ReadlineLibrary.PureJava) {
+    if (iLib == ReadlineLibrary.GnuReadline ||
+                                             iLib == ReadlineLibrary.Editline) {
       cleanupReadlineImpl();
     }      
   }
@@ -284,11 +1274,68 @@ public class Readline {
   /////////////////////////////////////////////////////////////////////////////
 
   /**
+     Return if we have a terminal. This requires, that any of the native
+     libraries have been loaded yet
+     (so call Readline.{@link #load(ReadlineLibrary)}())
+     first, otherwise this will always return true.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+	  <li>Editline</li>
+        </ul>
+     </p>
+
+   */
+
+   public static boolean hasTerminal() {
+    if (iLib == ReadlineLibrary.GnuReadline ||
+                                             iLib == ReadlineLibrary.Editline) {
+       return hasTerminalImpl();
+     }
+     return true;
+   }
+
+  /////////////////////////////////////////////////////////////////////////////
+
+  /**
+     Set word break characters.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+	  <li>Editline</li>
+        </ul>
+     </p>
+
+     @param wordBreakCharacters A string of word break characters
+  */
+    
+  public static void 
+    setWordBreakCharacters(String wordBreakCharacters)
+                              throws UnsupportedEncodingException {
+    if (iLib == ReadlineLibrary.GnuReadline || iLib == ReadlineLibrary.Editline)
+      setWordBreakCharactersImpl(wordBreakCharacters);
+    else if (iThrowException)
+      throw new UnsupportedOperationException();
+  }
+
+  /////////////////////////////////////////////////////////////////////////////
+
+  /**
      Query word break characters.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+	  <li>Editline</li>
+        </ul>
+     </p>
+
   */
     
   public static String getWordBreakCharacters() {
-    if (iLib != ReadlineLibrary.PureJava)
+    if (iLib == ReadlineLibrary.GnuReadline || iLib == ReadlineLibrary.Editline)
       return getWordBreakCharactersImpl();
     else if (iThrowException)
       throw new UnsupportedOperationException();
@@ -303,10 +1350,17 @@ public class Readline {
      the internal line buffer. You might need this in a 
      {@link ReadlineCompleter} implementation to access the full text
      given so far.
+
+     <p>Supporting implementations:
+        <ul>
+	  <li>GNU-Readline</li>
+	  <li>Editline</li>
+        </ul>
+     </p>
   */
     
   public static String getLineBuffer() {
-    if (iLib != ReadlineLibrary.PureJava)
+    if (iLib == ReadlineLibrary.GnuReadline || iLib == ReadlineLibrary.Editline)
       return getLineBufferImpl();
     else if (iThrowException)
       throw new UnsupportedOperationException();
@@ -318,48 +1372,132 @@ public class Readline {
   /////////////////////////////////////////////////////////////////////////////
 
   /**
-     Set word break characters.
+     Configure behavior in case an unsupported method is called. If argument
+     is true, unsupported methods throw an UnsupportedOperationException.
 
-     @param wordBreakCharacters A string of word break characters
+     @param flag configuration flag
+  */
+
+  public static void setThrowExceptionOnUnsupportedMethod(boolean flag) {
+    iThrowException = flag;
+  }
+
+  /////////////////////////////////////////////////////////////////////////////
+
+  /**
+     Query behavior in case an unsupported method is called.
+
+     @return configuration flag
+  */
+
+  public static boolean getThrowExceptionOnUnsupportedMethod() {
+    return iThrowException;
+  }
+
+  /////////////////////////////////////////////////////////////////////////////
+
+  /**
+    Set current encoding of fallback BufferedReader.
+
+    @param encoding encoding to use
   */
     
-  public static void 
-    setWordBreakCharacters(String wordBreakCharacters)
-                              throws UnsupportedEncodingException {
-    if (iLib != ReadlineLibrary.PureJava)
-      setWordBreakCharactersImpl(wordBreakCharacters);
+  public static void setEncoding(String encoding) {
+      iEncoding = encoding;
+  }
+
+  /////////////////////////////////////////////////////////////////////////////
+  
+  /**
+     Query current encoding of fallback BufferedReader.
+
+     @return current encoding
+  */
+
+  public static String getEncoding() {
+   return iEncoding;
+  }
+
+  /////////////////////////////////////////////////////////////////////////////
+
+  /**
+     Set integer readline-variable.
+
+     @param c symbolic constant of readline-variable
+     @param value new value of readline-variable
+     @return old value of readline-variable
+  */
+
+  public static int setVar(ReadlineConstInt c, int value) {
+    if (c.isSupported(iLib))
+      return setVarIntImpl(c.getNumber(),value);
     else if (iThrowException)
       throw new UnsupportedOperationException();
+    else
+      return Integer.MIN_VALUE;
   }
 
   /////////////////////////////////////////////////////////////////////////////
 
   /**
-     Configure behavior in case an unsupported method is called. If argument
-     is true, unsupported methods throw an UnsupportedOperationException.
+     Query integer readline-variable.
 
-     @param flag configuration flag
+     @param c symbolic constant of readline-variable
+     @return value of variable
   */
 
-  public static void setThrowExceptionOnUnsupportedMethod(boolean flag) {
-    iThrowException = flag;
+  public static int getVar(ReadlineConstInt c) {
+    if (c.isSupported(iLib))
+      return getVarIntImpl(c.getNumber());
+    else if (iThrowException)
+      throw new UnsupportedOperationException();
+    else
+      return Integer.MIN_VALUE;
   }
 
   /////////////////////////////////////////////////////////////////////////////
 
   /**
-     Query behavior in case an unsupported method is called.
+     Set string readline-variable.
 
-     @return configuration flag
+     @param c symbolic constant of readline-variable
+     @param value new value of readline-variable
+     @return old value of readline-variable
   */
 
-  public static boolean getThrowExceptionOnUnsupportedMethod() {
-    return iThrowException;
+  public static String setVar(ReadlineConstString c, String value) throws 
+                                                UnsupportedEncodingException {
+    if (c.isSupported(iLib))
+      return setVarStringImpl(c.getNumber(),value);
+    else if (iThrowException)
+      throw new UnsupportedOperationException();
+    else
+      return null;
   }
 
   /////////////////////////////////////////////////////////////////////////////
 
   /**
+     Query string readline-variable.
+
+     @param c symbolic constant of readline-variable
+     @return value of variable
+  */
+
+  public static String getVar(ReadlineConstString c) throws 
+                                                UnsupportedEncodingException {
+    if (c.isSupported(iLib))
+      return getVarStringImpl(c.getNumber());
+    else if (iThrowException)
+      throw new UnsupportedOperationException();
+    else
+      return null;
+  }
+
+  /////////////////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////////////////
+
+  /**
      Native implementation of initReadline()
 
      @see org.gnu.readline.Readline#initReadline(String applicationName)
@@ -378,6 +1516,14 @@ public class Readline {
   /////////////////////////////////////////////////////////////////////////////
 
   /**
+     native implementation of isatty();
+  */
+
+  private native static boolean hasTerminalImpl();
+
+  /////////////////////////////////////////////////////////////////////////////
+
+  /**
      Native implementation of readline()
 
      @see org.gnu.readline.Readline#readline(String prompt)
@@ -389,6 +1535,56 @@ public class Readline {
   /////////////////////////////////////////////////////////////////////////////
 
   /**
+     Native implementation of addToHistory
+
+     @see org.gnu.readline.Readline#addToHistory(String line)
+  */
+
+  private native static void addToHistoryImpl(String line);
+
+  /////////////////////////////////////////////////////////////////////////////
+
+  /**
+     Native implementation of getHistory
+
+     @see org.gnu.readline.Readline#getHistory()
+  */
+
+  private native static void getHistoryImpl(Collection collection);
+
+  /////////////////////////////////////////////////////////////////////////////
+
+  /**
+     Native implementation of getHistorySize
+
+     @see org.gnu.readline.Readline#getHistorySize()
+  */
+
+  private native static int getHistorySizeImpl();
+
+  /////////////////////////////////////////////////////////////////////////////
+
+  /**
+     Native implementation of getHistoryLine
+
+     @see org.gnu.readline.Readline#getHistoryLine()
+  */
+
+  private native static String getHistoryLineImpl(int i);
+
+  /////////////////////////////////////////////////////////////////////////////
+
+  /**
+     Native implementation of clearHistory
+
+     @see org.gnu.readline.Readline#clearHistory()
+  */
+
+  private native static void clearHistoryImpl();
+
+  /////////////////////////////////////////////////////////////////////////////
+
+  /**
      Native implementation of readInitFile(String filename)
 
      @see org.gnu.readline.Readline#readInitFile(String filename)
@@ -472,4 +1668,49 @@ public class Readline {
   private native static void 
     setWordBreakCharactersImpl(String wordBreakCharacters)
                               throws UnsupportedEncodingException;
+
+  /////////////////////////////////////////////////////////////////////////////
+
+  /**
+     Native implementation of setVar(ReadlineConstInt,int)
+
+     @see 
+   org.gnu.readline.Readline#setVar(ReadlineConstInt,int)
+  */
+
+  private native static int setVarIntImpl(int number,int value);
+
+  /////////////////////////////////////////////////////////////////////////////
+
+  /**
+     Native implementation of getVar(ReadlineConstInt)
+
+     @see 
+   org.gnu.readline.Readline#getVar(ReadlineConstInt)
+  */
+
+  private native static int getVarIntImpl(int number);
+
+  /////////////////////////////////////////////////////////////////////////////
+
+  /**
+     Native implementation of setVar(ReadlineConstString,String)
+
+     @see 
+   org.gnu.readline.Readline#setVar(ReadlineConstString,String)
+  */
+
+  private native static String setVarStringImpl(int number,String value)
+                              throws UnsupportedEncodingException;
+  /////////////////////////////////////////////////////////////////////////////
+
+  /**
+     Native implementation of getVar(ReadlineConstString)
+
+     @see 
+   org.gnu.readline.Readline#getVar(ReadlineConstString)
+  */
+
+  private native static String getVarStringImpl(int number)
+                              throws UnsupportedEncodingException;
 }
diff --git a/src/org/gnu/readline/ReadlineConstBase.java b/src/org/gnu/readline/ReadlineConstBase.java
new file mode 100644
index 0000000..86942da
--- /dev/null
+++ b/src/org/gnu/readline/ReadlineConstBase.java
@@ -0,0 +1,85 @@
+/**************************************************************************
+/* ReadlineConstBase.java -- The base class for constants for Readline
+/*                           variables
+/*
+/* Java Wrapper Copyright (c) 1998-2003 by Bernhard Bablok (mail at bablokb.de)
+/*
+/* This program is free software; you can redistribute it and/or modify
+/* it under the terms of the GNU Library General Public License as published
+/* by  the Free Software Foundation; either version 2 of the License or
+/* (at your option) any later version.
+/*
+/* This program is distributed in the hope that it will be useful, but
+/* WITHOUT ANY WARRANTY; without even the implied warranty of
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+/* GNU Library General Public License for more details.
+/*
+/* You should have received a copy of the GNU Library General Public License
+/* along with this program; see the file COPYING.LIB.  If not, write to
+/* the Free Software Foundation Inc., 59 Temple Place - Suite 330,
+/* Boston, MA  02111-1307 USA
+/**************************************************************************/
+
+package org.gnu.readline;
+
+/**
+   This class is the base class for constants for Readline variables.
+   The constants are used to access internal variables of the
+   underlying implementation.
+
+ @version $Revision: 1.1 $
+ @author  $Author: bablokb $
+*/
+
+class ReadlineConstBase {
+  
+  /**
+     Numeric number of readline-variable. In the native implementation,
+     this number serves as an index into an array of variables. This
+     number can only be set once during initialization.
+  */
+
+  private int iNumber;
+
+  /**
+     Supporting implementations (not every implementation supports all
+     variables).
+  */
+
+  private ReadlineLibrary[] iSupport;
+
+  /**
+     Constructor. The constructor is protected, since the class should not
+     be used outside of the package.
+  */
+
+  protected ReadlineConstBase(int number, ReadlineLibrary[] support) {
+    iNumber = number;
+    iSupport = support;
+  }
+
+  /**
+     Query number.
+
+     @return number of readline-variable.
+  */
+
+  protected int getNumber() {
+    return iNumber;
+  }
+
+  /**
+     Check if this readline-variable is supported.
+     
+     @return true if supported
+  */
+
+  protected boolean isSupported(ReadlineLibrary lib) {
+    for (int i=0; i < iSupport.length; ++i) {
+      if (iSupport[i] == lib)
+	return true;
+    }
+    return false;
+  }
+}
+
diff --git a/src/org/gnu/readline/ReadlineConstInt.java b/src/org/gnu/readline/ReadlineConstInt.java
new file mode 100644
index 0000000..a0a23f4
--- /dev/null
+++ b/src/org/gnu/readline/ReadlineConstInt.java
@@ -0,0 +1,48 @@
+/**************************************************************************
+/* ReadlineConstInt.java -- The class for constants for integer Readline
+/*                          variables
+/*
+/* Java Wrapper Copyright (c) 1998-2003 by Bernhard Bablok (mail at bablokb.de)
+/*
+/* This program is free software; you can redistribute it and/or modify
+/* it under the terms of the GNU Library General Public License as published
+/* by  the Free Software Foundation; either version 2 of the License or
+/* (at your option) any later version.
+/*
+/* This program is distributed in the hope that it will be useful, but
+/* WITHOUT ANY WARRANTY; without even the implied warranty of
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+/* GNU Library General Public License for more details.
+/*
+/* You should have received a copy of the GNU Library General Public License
+/* along with this program; see the file COPYING.LIB.  If not, write to
+/* the Free Software Foundation Inc., 59 Temple Place - Suite 330,
+/* Boston, MA  02111-1307 USA
+/**************************************************************************/
+
+package org.gnu.readline;
+
+/**
+   This class implements constants for integer Readline variables.
+   The constants are used to access internal variables of the
+   underlying implementation.
+
+   <p> Note that the class does not add additional functionality, it
+   is used only for method-overloading.
+
+ @version $Revision: 1.1 $
+ @author  $Author: bablokb $
+*/
+
+class ReadlineConstInt  extends ReadlineConstBase {
+  
+  /**
+     Constructor. The constructor is protected, since the class should not
+     be used outside of the package.
+  */
+
+  protected ReadlineConstInt(int number, ReadlineLibrary[] support) {
+    super(number,support);
+  }
+}
+
diff --git a/src/org/gnu/readline/ReadlineConstString.java b/src/org/gnu/readline/ReadlineConstString.java
new file mode 100644
index 0000000..40e3eef
--- /dev/null
+++ b/src/org/gnu/readline/ReadlineConstString.java
@@ -0,0 +1,48 @@
+/**************************************************************************
+/* ReadlineConstString.java -- The class for constants for string Readline
+/*                          variables
+/*
+/* Java Wrapper Copyright (c) 1998-2003 by Bernhard Bablok (mail at bablokb.de)
+/*
+/* This program is free software; you can redistribute it and/or modify
+/* it under the terms of the GNU Library General Public License as published
+/* by  the Free Software Foundation; either version 2 of the License or
+/* (at your option) any later version.
+/*
+/* This program is distributed in the hope that it will be useful, but
+/* WITHOUT ANY WARRANTY; without even the implied warranty of
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+/* GNU Library General Public License for more details.
+/*
+/* You should have received a copy of the GNU Library General Public License
+/* along with this program; see the file COPYING.LIB.  If not, write to
+/* the Free Software Foundation Inc., 59 Temple Place - Suite 330,
+/* Boston, MA  02111-1307 USA
+/**************************************************************************/
+
+package org.gnu.readline;
+
+/**
+   This class implements constants for string Readline variables.
+   The constants are used to access internal variables of the
+   underlying implementation.
+
+   <p> Note that the class does not add additional functionality, it
+   is used only for method-overloading.
+
+ @version $Revision: 1.1 $
+ @author  $Author: bablokb $
+*/
+
+class ReadlineConstString extends ReadlineConstBase {
+  
+  /**
+     Constructor. The constructor is protected, since the class should not
+     be used outside of the package.
+  */
+
+  protected ReadlineConstString(int number, ReadlineLibrary[] support) {
+    super(number,support);
+  }
+}
+
diff --git a/src/org/gnu/readline/ReadlineLibrary.java b/src/org/gnu/readline/ReadlineLibrary.java
index 29e9295..22f48c1 100644
--- a/src/org/gnu/readline/ReadlineLibrary.java
+++ b/src/org/gnu/readline/ReadlineLibrary.java
@@ -24,8 +24,8 @@ package org.gnu.readline;
 /**
  This class implements a typesafe enumeration of the backing libraries.
 
- @version $Revision: 1.3 $
- @author  $Author: Bablokb $
+ @version $Revision: 1.4 $
+ @author  $Author: bablokb $
 */
 
 public final class ReadlineLibrary {
@@ -52,6 +52,13 @@ public final class ReadlineLibrary {
     new ReadlineLibrary("JavaEditline");
 
   /**
+     Constant for Getline implementation.
+  */
+
+  public static final ReadlineLibrary Getline = 
+    new ReadlineLibrary("JavaGetline");
+
+  /**
      The name of the backing native library.
   */
 
@@ -88,6 +95,8 @@ public final class ReadlineLibrary {
       return GnuReadline;
     else if (name.equals("Editline"))
       return Editline;
+    else if (name.equals("Getline"))
+      return Getline;
     else if (name.equals("PureJava"))
       return PureJava;
     return null;
diff --git a/src/test/ReadlineTest.java b/src/test/ReadlineTest.java
index 3d6a342..0409bb5 100644
--- a/src/test/ReadlineTest.java
+++ b/src/test/ReadlineTest.java
@@ -36,8 +36,8 @@ import org.gnu.readline.*;
  * is read. If a second argument is given, the appropriate library is
  * loaded.
  *
- * @author $Author: Bablokb $
- * @version $Revision: 1.17 $
+ * @author $Author: bablokb $
+ * @version $Revision: 1.19 $
  */
 
 public class ReadlineTest {
@@ -90,13 +90,34 @@ public class ReadlineTest {
 
     // Set word break characters
     try {
-        Readline.setWordBreakCharacters(" \t;");
-    }
-    catch (UnsupportedEncodingException enc) {
-        System.err.println("Could not set word break characters");
-        System.exit(0);
+      String breakChars = 
+	Readline.getVar(Readline.RL_COMPLETER_WORD_BREAK_CHARACTERS);
+      System.out.println("word-break-chars: " + breakChars);
+      breakChars = 
+	Readline.setVar(Readline.RL_COMPLETER_WORD_BREAK_CHARACTERS,"abc");
+      System.out.println("word-break-chars: " + breakChars);
+      breakChars = 
+	Readline.getVar(Readline.RL_COMPLETER_WORD_BREAK_CHARACTERS);
+      System.out.println("word-break-chars: " + breakChars);
+      Readline.setWordBreakCharacters(" \t;");
+      breakChars = 
+	Readline.getVar(Readline.RL_COMPLETER_WORD_BREAK_CHARACTERS);
+      System.out.println("word-break-chars: " + breakChars);
+    } catch (UnsupportedEncodingException enc) {
+      System.err.println("Could not set word break characters");
+      System.exit(0);
     }
 
+    // query version
+
+    try {
+      String version = Readline.getVar(Readline.RL_LIBRARY_VERSION);
+      System.out.println("Readline-Version: " + version);
+    } catch (UnsupportedEncodingException enc) {
+      System.err.println("Could not query libarary version");
+      System.exit(0);
+    }
+    
     // set test completer
 
     Readline.setCompleter(new TestCompleter());

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libreadline-java.git



More information about the pkg-java-commits mailing list