changeset 3519:957d7d6ab0e0

[project @ 2000-02-02 06:00:09 by jwe]
author jwe
date Wed, 02 Feb 2000 06:00:59 +0000
parents 2dcc5f58ca0c
children b153b9fa7f1a
files liboctave/ChangeLog liboctave/DASSL.cc liboctave/DASSL.h liboctave/Makefile.in liboctave/cmd-edit.cc liboctave/cmd-edit.h liboctave/cmd-hist.cc liboctave/cmd-hist.h liboctave/oct-getopt.h liboctave/oct-rl-edit.c liboctave/oct-rl-edit.h liboctave/oct-rl-hist.c liboctave/oct-rl-hist.h src/input.cc
diffstat 14 files changed, 895 insertions(+), 191 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog	Tue Feb 01 23:11:59 2000 +0000
+++ b/liboctave/ChangeLog	Wed Feb 02 06:00:59 2000 +0000
@@ -1,5 +1,13 @@
 2000-02-01  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
+	* oct-rl-edit.c, oct-rl-edit.h: New files for interface to GNU
+	readline library.
+	* Makefile.in: Add them to the appropriate lists.
+
+	* oct-rl-hist.c, oct-rl-hist.h: New files for interface to GNU
+	readline history library.
+	* Makefile.in: Add them to the appropriate lists.
+
 	* data-conv.cc (LS_DO_WRITE): Cast arg to ostream::write to char*.
 	(LS_DO_READ): Likewise, for istream::read.
 	(write_doubles): Likewise.
@@ -24,8 +32,10 @@
 	* NLEqn.cc (hybrd1_fcn_ptr, hybrj1_fcn_ptr): Ditto.
 
 	* oct-getopt.h, oct-getopt.c: New files for interface to getopt.
+	* Makefile.in: Add them to the appropriate lists.
 
 	* oct-kpse.h, oct-kpse.c: New files for interface to kpathsearch.
+	* Makefile.in: Add them to the appropriate lists.
 
 	* dMatrix.cc (write_int, read_int): No longer declared static.
 
--- a/liboctave/DASSL.cc	Tue Feb 01 23:11:59 2000 +0000
+++ b/liboctave/DASSL.cc	Wed Feb 02 06:00:59 2000 +0000
@@ -369,6 +369,13 @@
 }
 
 Matrix
+DASSL::do_integrate (const ColumnVector& tout, const ColumnVector& tcrit)
+{
+  Matrix dummy;
+  return integrate (tout, dummy, tcrit);
+}
+
+Matrix
 DASSL::integrate (const ColumnVector& tout, Matrix& xdot_out,
 		  const ColumnVector& tcrit) 
 {
--- a/liboctave/DASSL.h	Tue Feb 01 23:11:59 2000 +0000
+++ b/liboctave/DASSL.h	Wed Feb 02 06:00:59 2000 +0000
@@ -129,6 +129,8 @@
 
   Matrix do_integrate (const ColumnVector& tout);
 
+  Matrix do_integrate (const ColumnVector& tout, const ColumnVector& tcrit); 
+
   Matrix integrate (const ColumnVector& tout, Matrix& xdot_out);
 
   Matrix integrate (const ColumnVector& tout, Matrix& xdot_out,
--- a/liboctave/Makefile.in	Tue Feb 01 23:11:59 2000 +0000
+++ b/liboctave/Makefile.in	Wed Feb 02 06:00:59 2000 +0000
@@ -47,10 +47,10 @@
 	dir-ops.h file-ops.h file-stat.h getopt.h glob-match.h \
 	idx-vector.h lo-ieee.h lo-mappers.h lo-specfun.h lo-sysdep.h \
 	lo-utils.h mach-info.h oct-alloc.h oct-cmplx.h oct-env.h \
-	oct-getopt.h oct-group.h oct-kpse.h oct-passwd.h \
-	oct-shlib.h oct-syscalls.h oct-time.h pathlen.h pathsearch.h \
-	prog-args.h statdefs.h str-vec.h sun-utils.h sysdir.h systime.h \
-	syswait.h \
+	oct-getopt.h oct-group.h oct-kpse.h oct-passwd.h oct-rl-edit.h \
+	oct-rl-hist.h oct-shlib.h oct-syscalls.h oct-time.h pathlen.h \
+	pathsearch.h prog-args.h statdefs.h str-vec.h sun-utils.h \
+	sysdir.h systime.h syswait.h \
 	$(MATRIX_INC) \
 	$(MX_OP_INC)
 
@@ -82,9 +82,9 @@
 	idx-vector.cc lo-ieee.cc lo-mappers.cc lo-specfun.cc \
 	lo-sysdep.cc lo-utils.cc mach-info.cc mkdir.c oct-alloc.cc \
 	oct-env.cc oct-getopt.c oct-group.cc oct-kpse.c oct-passwd.cc \
-	oct-shlib.cc oct-syscalls.cc oct-time.cc \
-	pathsearch.cc prog-args.cc rename.c rmdir.c strftime.c \
-	strptime.c str-vec.cc tempname.c tempnam.c \
+	oct-rl-edit.c oct-rl-hist.c oct-shlib.cc oct-syscalls.cc \
+	oct-time.cc pathsearch.cc prog-args.cc rename.c rmdir.c \
+	strftime.c strptime.c str-vec.cc tempname.c tempnam.c \
 	$(TEMPLATE_SRC) \
 	$(TI_SRC) \
 	$(MATRIX_SRC) \
--- a/liboctave/cmd-edit.cc	Tue Feb 01 23:11:59 2000 +0000
+++ b/liboctave/cmd-edit.cc	Wed Feb 02 06:00:59 2000 +0000
@@ -50,22 +50,16 @@
 #include <cstdio>
 #include <cstdlib>
 
-#include <readline/readline.h>
-
-// It would be nice if readline.h declared these, I think.
-
-extern int rl_blink_matching_paren;
-
-extern int screenheight;
-
-extern int screenwidth;
+#include "oct-rl-edit.h"
 
 class
 gnu_readline : public command_editor
 {
 public:
 
-  typedef command_editor::fcn fcn;
+  typedef command_editor::startup_hook_fcn startup_hook_fcn;
+
+  typedef command_editor::event_hook_fcn event_hook_hook_fcn;
 
   typedef command_editor::completion_fcn completion_fcn;
 
@@ -113,71 +107,69 @@
 
   void do_clear_undo_list (void);
 
-  void do_set_startup_hook (fcn f);
+  void do_set_startup_hook (startup_hook_fcn f);
 
   void do_restore_startup_hook (void);
 
-  void do_set_event_hook (fcn f);
+  void do_set_event_hook (event_hook_fcn f);
 
   void do_restore_event_hook (void);
 
   void do_read_init_file (const std::string& file);
 
-  static void operate_and_get_next (int, int);
+  static int operate_and_get_next (int, int);
 
 private:
 
-  fcn previous_startup_hook;
+  startup_hook_fcn previous_startup_hook;
 
-  fcn previous_event_hook;
+  event_hook_fcn previous_event_hook;
 
   completion_fcn completion_function;
 
   static char *command_generator (const char *text, int state);
 
-  static char **command_completer (char *text, int start, int end);
+  static char **command_completer (const char *text, int start, int end);
 };
 
 gnu_readline::gnu_readline ()
   : command_editor (), previous_startup_hook (0),
     previous_event_hook (0), completion_function (0)
 {
-  rl_terminal_name = ::getenv ("TERM");
+  // XXX FIXME XXX -- need interface to rl_add_defun, rl_initialize, and
+  // a function to set rl_terminal_name
 
-  rl_initialize ();
+  string term = octave_env::getenv ("TERM");
+
+  octave_rl_set_terminal_name (term.c_str ());
+
+  octave_rl_initialize ();
 
   do_blink_matching_paren (true);
 
-  // Bind operate-and-get-next.
+  /* Bind operate-and-get-next. */
 
-  rl_add_defun ("operate-and-get-next",
-		gnu_readline::operate_and_get_next, CTRL ('O'));
+  octave_rl_add_defun ("operate-and-get-next",
+		       gnu_readline::operate_and_get_next,
+		       octave_rl_ctrl ('O'));
 
-  // And the history search functions.
+  /* And the history search functions. */
 
-  rl_add_defun ("history-search-backward",
-		rl_history_search_backward, META ('p'));
+  octave_rl_add_defun ("history-search-backward",
+		       octave_rl_history_search_backward,
+		       octave_rl_meta ('P'));
 
-  rl_add_defun ("history-search-forward",
-		rl_history_search_forward, META ('n'));
+  octave_rl_add_defun ("history-search-forward",
+		       octave_rl_history_search_forward,
+		       octave_rl_meta ('N'));
 }
 
+
+
 void
-gnu_readline::do_set_name (const std::string& n)
+gnu_readline::do_set_name (const std::string& nm)
 {
-  static char *nm = 0;
-
-  delete [] nm;
-
-  nm = strsave (n.c_str ());
-
-  rl_readline_name = nm;
-
-  // Since we've already called rl_initialize, we need to re-read the
-  // init file to take advantage of the conditional parsing feature
-  // based on rl_readline_name;
-
-  rl_re_read_init_file ();
+  ::octave_rl_set_name (nm.c_str ());
 }
 
 std::string
@@ -187,7 +179,7 @@
 
   eof = false;
 
-  char *line = ::readline (prompt.c_str ());
+  char *line = ::octave_rl_readline (prompt.c_str ());
 
   if (line)
     {
@@ -204,25 +196,25 @@
 void
 gnu_readline::do_set_input_stream (FILE *f)
 {
-  rl_instream = f;
+  ::octave_rl_set_input_stream (f);
 }
 
 FILE *
 gnu_readline::do_get_input_stream (void)
 {
-  return rl_instream;
+  return ::octave_rl_get_input_stream ();
 }
 
 void
 gnu_readline::do_set_output_stream (FILE *f)
 {
-  rl_outstream = f;
+  ::octave_rl_set_output_stream (f);
 }
 
 FILE *
 gnu_readline::do_get_output_stream (void)
 {
-  return rl_outstream;
+  return ::octave_rl_get_output_stream ();
 }
 
 // GNU readline handles SIGWINCH, so these values have a good chance
@@ -234,25 +226,29 @@
 int
 gnu_readline::do_terminal_rows (void)
 {
-  return screenheight > 0 ? screenheight : 24;
+  int sh = ::octave_rl_screen_height ();
+
+  return sh > 0 ? sh : 24;
 }
 
 int
 gnu_readline::do_terminal_cols (void)
 {
-  return screenwidth > 0 ? screenwidth : 80;
+  int sw = ::octave_rl_screen_width ();
+
+  return sw > 0 ? sw : 80;
 }
 
 void
 gnu_readline::do_clear_screen (void)
 {
-  rl_clear_screen ();
+  ::octave_rl_clear_screen ();
 }
 
 void
 gnu_readline::do_resize_terminal (void)
 {
-  rl_resize_terminal ();
+  ::octave_rl_resize_terminal ();
 }
 
 std::string
@@ -264,32 +260,25 @@
 void
 gnu_readline::do_restore_terminal_state (void)
 {
-  if (rl_deprep_term_function)
-    rl_deprep_term_function ();
+  ::octave_rl_restore_terminal_state ();
 }
 
 void
 gnu_readline::do_blink_matching_paren (bool flag)
 {
-  rl_blink_matching_paren = flag ? 1 : 0;
+  ::octave_set_rl_blink_matching_paren_flag (flag ? 1 : 0);
 }
 
 void
 gnu_readline::do_set_basic_quote_characters (const std::string& s)
 {
-  static char *ss = 0;
-
-  delete [] ss;
-
-  ss = strsave (s.c_str ());
-
-  rl_basic_quote_characters = ss;
+  ::octave_rl_set_basic_quote_characters (s.c_str ());
 }
 
 void
 gnu_readline::do_set_completion_append_character (char c)
 {
-  rl_completion_append_character = c;
+  ::octave_rl_set_completion_append_character (c);
 }
 
 void
@@ -297,11 +286,10 @@
 {
   completion_function = f;
 
-  typedef char** (*foo) (...);
+  rl_attempted_completion_fcn_ptr fp
+    = f ? gnu_readline::command_completer : 0;
 
-  rl_attempted_completion_function
-    = completion_function
-    ? reinterpret_cast<foo> (gnu_readline::command_completer) : 0;
+  ::octave_rl_set_completion_function (fp);
 }
 
 gnu_readline::completion_fcn
@@ -313,64 +301,56 @@
 void
 gnu_readline::do_insert_text (const std::string& text)
 {
-  rl_insert_text (text.c_str ());
+  ::octave_rl_insert_text (text.c_str ());
 }
 
 void
 gnu_readline::do_newline (void)
 {
-  rl_newline ();
+  ::octave_rl_newline ();
 }
 
 void
 gnu_readline::do_clear_undo_list ()
 {
-  if (rl_undo_list)
-    {
-      free_undo_list ();
-
-      rl_undo_list = 0;
-    }
+  ::octave_rl_clear_undo_list ();
 }
 
 void
-gnu_readline::do_set_startup_hook (fcn f)
+gnu_readline::do_set_startup_hook (startup_hook_fcn f)
 {
-  previous_startup_hook = rl_startup_hook;
+  previous_startup_hook = ::octave_rl_get_startup_hook ();
 
-  rl_startup_hook = f;
+  ::octave_rl_set_startup_hook (f);
 }
 
 void
 gnu_readline::do_restore_startup_hook (void)
 {
-  rl_startup_hook = previous_startup_hook;
+  ::octave_rl_set_startup_hook (previous_startup_hook);
 }
 
 void
-gnu_readline::do_set_event_hook (fcn f)
+gnu_readline::do_set_event_hook (event_hook_fcn f)
 {
-  previous_event_hook = rl_event_hook;
+  previous_event_hook = octave_rl_get_event_hook ();
 
-  rl_event_hook = f;
+  ::octave_rl_set_event_hook (f);
 }
 
 void
 gnu_readline::do_restore_event_hook (void)
 {
-  rl_event_hook = previous_event_hook;
+  ::octave_rl_set_event_hook (previous_event_hook);
 }
 
 void
 gnu_readline::do_read_init_file (const std::string& file)
 {
-  if (file.empty ())
-    rl_re_read_init_file ();
-  else
-    rl_read_init_file (file.c_str ());
+  ::octave_rl_read_init_file (file.c_str ());
 }
 
-void
+int
 gnu_readline::operate_and_get_next (int /* count */, int /* c */)
 {
   // Accept the current line.
@@ -391,6 +371,8 @@
     command_history::set_mark (x_where + 1);
 
   command_editor::set_startup_hook (command_history::goto_mark);
+
+  return 0;
 }
 
 char *
@@ -415,10 +397,11 @@
 }
 
 char **
-gnu_readline::command_completer (char *text, int /* start */, int /* end */)
+gnu_readline::command_completer (const char *text, int, int)
 {
   char **matches = 0;
-  matches = completion_matches (text, gnu_readline::command_generator);
+  matches
+    = ::octave_rl_completion_matches (text, gnu_readline::command_generator);
   return matches;
 }
 
@@ -701,7 +684,7 @@
 }
 
 void
-command_editor::set_startup_hook (fcn f)
+command_editor::set_startup_hook (startup_hook_fcn f)
 {
   if (instance_ok ())
     instance->do_set_startup_hook (f);
@@ -715,7 +698,7 @@
 }
 
 void
-command_editor::set_event_hook (fcn f)
+command_editor::set_event_hook (event_hook_fcn f)
 {
   if (instance_ok ())
     instance->do_set_event_hook (f);
@@ -912,8 +895,8 @@
 
 		temp[0] = '\001';
 		temp[1] = ((c == '[')
-			   ? RL_PROMPT_START_IGNORE
-			   : RL_PROMPT_END_IGNORE);
+			   ? ::octave_rl_prompt_start_ignore ()
+			   : ::octave_rl_prompt_end_ignore ());
 
 		goto add_string;
 	      }
--- a/liboctave/cmd-edit.h	Tue Feb 01 23:11:59 2000 +0000
+++ b/liboctave/cmd-edit.h	Wed Feb 02 06:00:59 2000 +0000
@@ -37,7 +37,9 @@
 
 public:
 
-  typedef int (*fcn) (...);
+  typedef void (*startup_hook_fcn) (void);
+
+  typedef void (*event_hook_fcn) (void);
 
   typedef std::string (*completion_fcn) (const std::string&, int);
 
@@ -85,11 +87,11 @@
 
   static void clear_undo_list (void);
 
-  static void set_startup_hook (fcn f);
+  static void set_startup_hook (startup_hook_fcn f);
 
   static void restore_startup_hook (void);
 
-  static void set_event_hook (fcn f);
+  static void set_event_hook (event_hook_fcn f);
 
   static void restore_event_hook (void);
 
@@ -171,11 +173,11 @@
 
   virtual void do_clear_undo_list (void) { }
 
-  virtual void do_set_startup_hook (fcn) { }
+  virtual void do_set_startup_hook (startup_hook_fcn) { }
 
   virtual void do_restore_startup_hook (void) { }
 
-  virtual void do_set_event_hook (fcn) { }
+  virtual void do_set_event_hook (event_hook_fcn) { }
 
   virtual void do_restore_event_hook (void) { }
 
--- a/liboctave/cmd-hist.cc	Tue Feb 01 23:11:59 2000 +0000
+++ b/liboctave/cmd-hist.cc	Wed Feb 02 06:00:59 2000 +0000
@@ -54,7 +54,7 @@
 #include <unistd.h>
 #endif
 
-#include <readline/history.h>
+#include "oct-rl-hist.h"
 
 #include "file-stat.h"
 
@@ -124,7 +124,7 @@
 	  || (s.length () == 1 && (s[0] == '\r' || s[0] == '\n')))
 	return;
 
-      ::add_history (s.c_str ());
+      ::octave_add_history (s.c_str ());
 
       lines_this_session++;
     }
@@ -133,39 +133,31 @@
 void
 gnu_history::do_remove (int n)
 {
-  HIST_ENTRY *discard = ::remove_history (n);
-
-  if (discard)
-    {
-      if (discard->line)
-	::free (discard->line);
-
-      ::free (discard);
-    }
+  ::octave_remove_history (n);
 }
 
 int
 gnu_history::do_where (void)
 {
-  return ::where_history ();
+  return ::octave_where_history ();
 }
 
 int
 gnu_history::do_length (void)
 {
-  return ::history_length;
+  return ::octave_history_length ();
 }
 
 int
 gnu_history::do_max_input_history (void)
 {
-  return ::max_input_history;
+  return ::octave_max_input_history ();
 }
 
 int
 gnu_history::do_base (void)
 {
-  return ::history_base;
+  return ::octave_history_base ();
 }
 
 int
@@ -177,19 +169,19 @@
 void
 gnu_history::do_stifle (int n)
 {
-  ::stifle_history (n);
+  ::octave_stifle_history (n);
 }
 
 int
 gnu_history::do_unstifle (void)
 {
-  return ::unstifle_history ();
+  return ::octave_unstifle_history ();
 }
 
 int
 gnu_history::do_is_stifled (void)
 {
-  return ::history_is_stifled ();
+  return ::octave_history_is_stifled ();
 }
 
 void
@@ -201,20 +193,15 @@
 void
 gnu_history::do_goto_mark (void)
 {
-  HIST_ENTRY *h;
-
   if (mark)
     {
-      if (history_set_pos (mark))
-	{
-	  h = ::current_history ();
+      char *line = ::octave_history_goto_mark (mark);
 
-	  if (h)
-	    {
-	      command_editor::insert_text (h->line);
+      if (line)
+	{
+	  command_editor::insert_text (line);
 
-	      command_editor::clear_undo_list ();
-	    }
+	  command_editor::clear_undo_list ();
 	}
     }
 
@@ -229,7 +216,7 @@
 {
   if (! f.empty ())
     {
-      int status = ::read_history (f.c_str ());
+      int status = ::octave_read_history (f.c_str ());
 
       if (status != 0 && must_exist)
 	error (status);
@@ -237,7 +224,7 @@
 	{
 	  lines_in_file = do_where ();
 
-	  ::using_history ();
+	  ::octave_using_history ();
 	}
     }
   else
@@ -253,7 +240,7 @@
 
   if (! f.empty ())
     {
-      int status = ::read_history_range (f.c_str (), from, to);
+      int status = ::octave_read_history_range (f.c_str (), from, to);
 
       if (status != 0 && must_exist)
 	error (status);
@@ -261,7 +248,7 @@
 	{
 	  lines_in_file = do_where ();
 
-	  ::using_history ();
+	  ::octave_using_history ();
 	}
     }
   else
@@ -278,7 +265,7 @@
 
   if (! f.empty ())
     {
-      int status = ::write_history (f.c_str ());
+      int status = ::octave_write_history (f.c_str ());
 
       if (status != 0)
 	error (status);
@@ -313,7 +300,8 @@
 		  close (tem);
 		}
 
-	      int status = ::append_history (lines_this_session, f.c_str ());
+	      int status
+		= ::octave_append_history (lines_this_session, f.c_str ());
 
 	      if (status != 0)
 		error (status);
@@ -337,7 +325,7 @@
     f = xfile;
 
   if (! f.empty ())
-    ::history_truncate_file (f.c_str (), n);
+    ::octave_history_truncate_file (f.c_str (), n);
   else
     error ("gnu_history::truncate_file: missing file name");
 }
@@ -348,38 +336,7 @@
   string_vector retval;
 
   if (limit)
-    {
-      HIST_ENTRY **hlist = ::history_list ();
-
-      if (hlist)
-	{
-	  int end = 0;
-	  while (hlist[end])
-	    end++;
-
-	  int beg = (limit < 0 || end < limit) ? 0 : (end - limit);
-
-	  retval.resize (end - beg);
-
-	  int k = 0;
-	  for (int i = beg; i < end; i++)
-	    {
-	      std::ostrstream output_buf;
-
-	      if (number_lines)
-		output_buf.form ("%5d%c", i + do_base (),
-				 hlist[i]->data ? '*' : ' '); 
-
-	      output_buf << hlist[i]->line << std::ends;
-
-	      const char *tmp = output_buf.str ();
-
-	      retval[k++] = tmp;
-
-	      delete [] tmp;  
-	    }
-	}
-    }
+    retval = ::octave_history_list (limit, number_lines);
 
   return retval;
 }
@@ -389,10 +346,10 @@
 {
   std::string retval;
 
-  HIST_ENTRY *entry = ::history_get (do_base () + n);
+  char *line = ::octave_history_get (do_base () + n);
 
-  if (entry && entry->line)
-    retval = entry->line;
+  if (line)
+    retval = line;
 
   return retval;
 }
@@ -400,15 +357,7 @@
 void
 gnu_history::do_replace_entry (int which, const std::string& line)
 {
-  HIST_ENTRY *discard = ::replace_history_entry (which, line.c_str (), 0);
-
-  if (discard)
-    {
-      if (discard->line)
-	::free (discard->line);
-
-      ::free (discard);
-    }
+  ::octave_replace_history_entry (which, line.c_str ());
 }
 
 void
@@ -582,13 +531,11 @@
     instance->do_set_mark (n);
 }
 
-int
-command_history::goto_mark (...)
+void
+command_history::goto_mark (void)
 {
   if (instance_ok ())
     instance->do_goto_mark ();
-
-  return 0;
 }
 
 void
--- a/liboctave/cmd-hist.h	Tue Feb 01 23:11:59 2000 +0000
+++ b/liboctave/cmd-hist.h	Wed Feb 02 06:00:59 2000 +0000
@@ -77,7 +77,7 @@
   // Gag.  This declaration has to match the Function typedef in
   // readline.h.
 
-  static int goto_mark (...);
+  static void goto_mark (void);
 
   static void read (bool = true);
 
--- a/liboctave/oct-getopt.h	Tue Feb 01 23:11:59 2000 +0000
+++ b/liboctave/oct-getopt.h	Wed Feb 02 06:00:59 2000 +0000
@@ -23,6 +23,11 @@
 #if !defined (octave_getopt_h)
 #define octave_getopt_h 1
 
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
 extern int
 octave_getopt (int, char *const *, const char *);
 
@@ -34,6 +39,10 @@
 
 extern int optind;
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
 
 /*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/liboctave/oct-rl-edit.c	Wed Feb 02 06:00:59 2000 +0000
@@ -0,0 +1,293 @@
+/*
+
+Copyright (C) 2000 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave 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 General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined (USE_READLINE)
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <readline/readline.h>
+
+#include "oct-rl-edit.h"
+
+// It would be nice if readline.h declared these, I think.
+
+extern int rl_blink_matching_paren;
+
+extern int screenheight;
+
+extern int screenwidth;
+
+int
+octave_rl_screen_height (void)
+{
+  return screenheight;
+}
+
+int
+octave_rl_screen_width (void)
+{
+  return screenwidth;
+}
+
+void
+octave_set_rl_blink_matching_paren_flag (int val)
+{
+  rl_blink_matching_paren = val;
+}
+
+int
+octave_get_rl_blink_matching_paren_flag (void)
+{
+  return rl_blink_matching_paren;
+}
+
+void
+octave_rl_clear_screen (void)
+{
+  rl_clear_screen ();
+}
+
+void
+octave_rl_resize_terminal (void)
+{
+  rl_resize_terminal ();
+}
+
+void
+octave_rl_restore_terminal_state ()
+{
+  if (rl_deprep_term_function)
+    rl_deprep_term_function ();
+}
+
+void
+octave_rl_insert_text (const char *s)
+{
+  rl_insert_text (s);
+}
+
+void
+octave_rl_newline (void)
+{
+  rl_newline ();
+}
+
+void
+octave_rl_clear_undo_list (void)
+{
+  if (rl_undo_list)
+    {
+      free_undo_list ();
+
+      rl_undo_list = 0;
+    }
+}
+
+void
+octave_rl_set_name (const char *n)
+{
+  static char *nm = 0;
+
+  if (nm)
+    {
+      free (nm);
+      nm = 0;
+    }
+
+  nm = malloc (strlen (n + 1));
+
+  strcpy (nm, n);
+
+  rl_readline_name = nm;
+
+  /* Since we've already called rl_initialize, we need to re-read the
+     init file to take advantage of the conditional parsing feature
+     based on rl_readline_name; */
+
+  rl_re_read_init_file ();
+}
+
+char *
+octave_rl_readline (const char *prompt)
+{
+  return readline (prompt);
+}
+
+void
+octave_rl_set_input_stream (FILE *f)
+{
+  rl_instream = f;
+}
+
+FILE *
+octave_rl_get_input_stream (void)
+{
+  return rl_instream;
+}
+
+void
+octave_rl_set_output_stream (FILE *f)
+{
+  rl_outstream = f;
+}
+
+FILE *
+octave_rl_get_output_stream (void)
+{
+  return rl_outstream;
+}
+
+void
+octave_rl_read_init_file (const char *f)
+{
+  if (f && *f)
+    rl_read_init_file (f);
+  else
+    rl_re_read_init_file ();
+}
+
+void
+octave_rl_set_basic_quote_characters (const char *s)
+{
+  static char *ss = 0;
+
+  if (ss)
+    {
+      free (ss);
+      ss = 0;
+    }
+
+  ss = malloc (strlen (s) + 1);
+
+  strcpy (ss, s);
+
+  rl_basic_quote_characters = ss;
+}
+
+void
+octave_rl_set_completion_append_character (char c)
+{
+  rl_completion_append_character = c;
+}
+
+void
+octave_rl_set_completion_function (rl_attempted_completion_fcn_ptr f)
+{
+  rl_attempted_completion_function = f;
+}
+
+void
+octave_rl_set_startup_hook (rl_startup_hook_fcn_ptr f)
+{
+  rl_startup_hook = (void *) f;
+}
+
+rl_startup_hook_fcn_ptr
+octave_rl_get_startup_hook (void)
+{
+  return (void *) rl_startup_hook;
+}
+
+void
+octave_rl_set_event_hook (rl_event_hook_fcn_ptr f)
+{
+  rl_event_hook = (void *) f;
+}
+
+rl_event_hook_fcn_ptr
+octave_rl_get_event_hook (void)
+{
+  return (void *) rl_event_hook;
+}
+
+char **
+octave_rl_completion_matches (const char *text, rl_completer_fcn_ptr f)
+{
+  return completion_matches (text, f);
+}
+
+char
+octave_rl_prompt_start_ignore (void)
+{
+  return RL_PROMPT_START_IGNORE;
+}
+
+char
+octave_rl_prompt_end_ignore (void)
+{
+  return RL_PROMPT_END_IGNORE;
+}
+
+void
+octave_rl_add_defun (const char *name, rl_fcn_ptr f, char key)
+{
+  rl_add_defun (name, f, key);
+}
+
+void
+octave_rl_set_terminal_name (const char *term)
+{
+  rl_terminal_name = (char *) term;
+}
+
+void
+octave_rl_initialize (void)
+{
+  rl_initialize ();
+}
+
+int
+octave_rl_history_search_forward (int count, int ignore)
+{
+  return rl_history_search_forward (count, ignore);
+}
+
+int
+octave_rl_history_search_backward (int count, int ignore)
+{
+  return rl_history_search_backward (count, ignore);
+}
+
+char
+octave_rl_ctrl (char c)
+{
+  return CTRL (c);
+}
+
+char
+octave_rl_meta (char c)
+{
+  return META (c);
+}
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/liboctave/oct-rl-edit.h	Wed Feb 02 06:00:59 2000 +0000
@@ -0,0 +1,123 @@
+/*
+
+Copyright (C) 2000 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave 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 General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_rl_edit_h)
+#define octave_rl_edit_h 1
+
+typedef void (*rl_startup_hook_fcn_ptr) (void);
+
+typedef void (*rl_event_hook_fcn_ptr) (void);
+
+typedef int (*rl_fcn_ptr) (int, int);
+
+typedef char ** (*rl_attempted_completion_fcn_ptr) (const char *, int, int);
+
+typedef char * (*rl_completer_fcn_ptr) (const char *, int);
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+extern int octave_rl_screen_height (void);
+
+extern int octave_rl_screen_width (void);
+
+extern void octave_set_rl_blink_matching_paren_flag (int);
+
+extern int octave_get_rl_blink_matching_paren_flag (void);
+
+extern void octave_rl_init (void);
+
+extern void octave_rl_clear_screen (void);
+
+extern void octave_rl_resize_terminal (void);
+
+extern void octave_rl_restore_terminal_state (void);
+
+extern void octave_rl_insert_text (const char *);
+
+extern void octave_rl_newline (void);
+
+extern void octave_rl_clear_undo_list (void);
+
+extern void octave_rl_set_name (const char *);
+
+extern char *octave_rl_readline (const char *);
+
+extern void octave_rl_set_input_stream (FILE *);
+
+extern FILE *octave_rl_get_input_stream (void);
+
+extern void octave_rl_set_output_stream (FILE *);
+
+extern FILE *octave_rl_get_output_stream (void);
+
+extern void octave_rl_read_init_file (const char *);
+
+extern void octave_rl_set_basic_quote_characters (const char *);
+
+extern void octave_rl_set_completion_append_character (char);
+
+extern void
+octave_rl_set_completion_function (rl_attempted_completion_fcn_ptr);
+
+extern void octave_rl_set_startup_hook (rl_startup_hook_fcn_ptr);
+
+extern rl_startup_hook_fcn_ptr octave_rl_get_startup_hook (void);
+
+extern void octave_rl_set_event_hook (rl_event_hook_fcn_ptr f);
+
+extern rl_event_hook_fcn_ptr octave_rl_get_event_hook (void);
+
+extern char **
+octave_rl_completion_matches (const char *, rl_completer_fcn_ptr);
+
+extern char octave_rl_prompt_start_ignore (void);
+
+extern char octave_rl_prompt_end_ignore (void);
+
+extern void octave_rl_add_defun (const char *, rl_fcn_ptr, char);
+
+extern void octave_rl_set_terminal_name (const char *);
+
+extern void octave_rl_initialize (void);
+
+extern int octave_rl_history_search_forward (int, int);
+
+extern int octave_rl_history_search_backward (int, int);
+
+extern char octave_rl_ctrl (char);
+
+extern char octave_rl_meta (char);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/liboctave/oct-rl-hist.c	Wed Feb 02 06:00:59 2000 +0000
@@ -0,0 +1,249 @@
+/*
+
+Copyright (C) 2000 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave 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 General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined (USE_READLINE)
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <readline/history.h>
+
+void
+octave_add_history (const char *line)
+{
+  return add_history (line);
+}
+
+int
+octave_where_history (void)
+{
+  return where_history ();
+}
+
+int
+octave_history_length (void)
+{
+  return history_length;
+}
+
+int
+octave_max_input_history (void)
+{
+  return max_input_history;
+}
+
+int
+octave_history_base (void)
+{
+  return history_base;
+}
+
+void
+octave_stifle_history (int n)
+{
+  return stifle_history (n);
+}
+
+int
+octave_unstifle_history (void)
+{
+  return unstifle_history ();
+}
+
+int
+octave_history_is_stifled (void)
+{
+  return history_is_stifled ();
+}
+
+int
+octave_history_set_pos (int n)
+{
+  return history_set_pos (n);
+}
+
+int
+octave_read_history (const char *f)
+{
+  return read_history (f);
+}
+
+void
+octave_using_history (void)
+{
+  return using_history ();
+}
+
+int
+octave_read_history_range (const char *f, int b, int e)
+{
+  return read_history_range (f, b, e);
+}
+
+int
+octave_write_history (const char *f)
+{
+  return write_history (f);
+}
+
+int
+octave_append_history (int n, const char *f)
+{
+  return append_history (n, f);
+}
+
+int
+octave_history_truncate_file (const char *f, int n)
+{
+  return history_truncate_file (f, n);
+}
+
+void
+octave_remove_history (int n)
+{
+  HIST_ENTRY *discard = remove_history (n);
+
+  if (discard)
+    {
+      if (discard->line)
+	free (discard->line);
+
+      free (discard);
+    }
+}
+
+char *
+octave_history_goto_mark (int n)
+{
+  HIST_ENTRY *h;
+
+  char *retval = 0;
+
+  if (history_set_pos (n))
+    {
+      h = current_history ();
+
+      if (h)
+	retval = h->line;
+    }
+
+  return retval;
+}
+
+char *
+octave_history_get (int n)
+{
+  char *retval = 0;
+
+  HIST_ENTRY *h = history_get (n);
+
+  if (h)
+    retval = h->line;
+
+  return retval;
+}
+
+char **
+octave_history_list (int limit, int number_lines)
+{
+  static char **retval = 0;
+
+  HIST_ENTRY **hlist = 0;
+
+  if (retval)
+    {
+      char **p = retval;
+
+      while (p)
+	{
+	  if (*p)
+	    free (*p++);
+	}
+
+      free (retval);
+
+      retval = 0;
+    }
+
+  hlist = history_list ();
+
+  if (hlist)
+    {
+      int i, k;
+
+      int beg = 0;
+      int end = 0;
+      while (hlist[end])
+	end++;
+
+      beg = (limit < 0 || end < limit) ? 0 : (end - limit);
+
+      retval = malloc ((end - beg + 1) * sizeof (char **));
+
+      k = 0;
+      for (i = beg; i < end; i++)
+	{
+	  char *tmp = 0;
+	  char buf[64];
+
+	  if (number_lines)
+	    sprintf (buf, "%5d%c", i + history_base,
+		     hlist[i]->data ? '*' : ' '); 
+
+	  tmp = malloc (strlen (buf) + 1);
+
+	  strcpy (tmp, buf);
+
+	  retval[k++] = tmp;
+	}
+
+      retval[k] = 0;
+    }
+
+  return retval;
+}
+
+void
+octave_replace_history_entry (int which, const char *line)
+{
+  HIST_ENTRY *discard = replace_history_entry (which, line, 0);
+
+  if (discard)
+    {
+      if (discard->line)
+	free (discard->line);
+
+      free (discard);
+    }
+}
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/liboctave/oct-rl-hist.h	Wed Feb 02 06:00:59 2000 +0000
@@ -0,0 +1,81 @@
+/*
+
+Copyright (C) 2000 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave 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 General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_rl_hist_h)
+#define octave_rl_hist_h 1
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+extern void octave_add_history (const char *);
+
+extern int octave_where_history (void);
+
+extern int octave_history_length (void);
+
+extern int octave_max_input_history (void);
+
+extern int octave_history_base (void);
+
+extern void octave_stifle_history (int);
+
+extern int octave_unstifle_history (void);
+
+extern int octave_history_is_stifled (void);
+
+extern int octave_history_set_pos (int);
+
+extern int octave_read_history (const char *);
+
+extern void octave_using_history (void);
+
+extern int octave_read_history_range (const char *, int, int);
+
+extern int octave_write_history (const char *);
+
+extern int octave_append_history (int, const char *);
+
+extern int octave_history_truncate_file (const char *, int);
+
+extern void octave_remove_history (int);
+
+extern char *octave_history_goto_mark (int n);
+
+extern char *octave_history_get (int n);
+
+extern char **octave_history_list (int, int);
+
+extern void octave_replace_history_entry (int, const char *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
--- a/src/input.cc	Tue Feb 01 23:11:59 2000 +0000
+++ b/src/input.cc	Wed Feb 02 06:00:59 2000 +0000
@@ -882,15 +882,13 @@
 static string hook_fcn;
 static octave_value user_data;
 
-static int
-input_event_hook (...)
+static void
+input_event_hook (void)
 {
   if (user_data.is_defined ())
     feval (hook_fcn, user_data, 0);
   else
     feval (hook_fcn, octave_value_list (), 0);
-
-  return 0;
 }
 
 DEFUN (input_event_hook, args, ,