changeset 3098:f4acdc9a77cc

[project @ 1997-11-14 09:30:20 by jwe]
author jwe
date Fri, 14 Nov 1997 09:30:29 +0000
parents d12c312d1cfb
children 8ce6fed79320
files src/ChangeLog src/input.cc
diffstat 2 files changed, 45 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,12 @@
 Fri Nov 14 01:53:13 1997  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
+	* input.cc (get_user_input (const octave_value_list&, bool)):
+	Return octave_value() if user enters `quit', `exit', or `return'.
+	If debugging, let eval_string handle the printing chores and
+	reset error_state before asking for more input.
+
+	* input.cc (Fkeyboard): Unconditionally turn on history here.
+
 	* lex.l (have_continuation, have_ellipsis_continuation): Declare
 	arg as bool, not int.  Change callers.
 
--- a/src/input.cc
+++ b/src/input.cc
@@ -64,6 +64,7 @@
 #include "sighandlers.h"
 #include "symtab.h"
 #include "sysdep.h"
+#include "unwind-prot.h"
 #include "utils.h"
 #include "variables.h"
 
@@ -541,14 +542,9 @@
 	{
 	  int parse_status = 0;
 
-	  retval = eval_string (input_buf, true, parse_status);
+	  retval = eval_string (input_buf, (! debug), parse_status);
 
-	  if (retval.is_defined ())
-	    {
-	      if (debug)
-		retval.print (octave_stdout);
-	    }
-	  else
+	  if (retval.is_undefined ())
 	    retval = Matrix ();
 	}
     }
@@ -556,7 +552,17 @@
     error ("input: reading user-input failed!");
 
   if (debug)
-    goto again;
+    {
+      // Clear error_state so that if errors were encountered while
+      // evaluating user input, extra error messages will not be
+      // printed after we return.
+
+      error_state = 0;
+
+      retval = octave_value ();
+
+      goto again;
+    }
 
   return retval;
 }
@@ -579,6 +585,12 @@
   return retval;
 }
 
+static void
+restore_command_history (void *)
+{
+  command_history::ignore_entries (! Vsaving_history);
+}
+
 DEFUN (keyboard, args, ,
   "keyboard (PROMPT)\n\
 \n\
@@ -589,7 +601,24 @@
   int nargin = args.length ();
 
   if (nargin == 0 || nargin == 1)
-    retval = get_user_input (args, true);
+    {
+      unwind_protect::begin_frame ("keyboard");
+
+      // XXX FIXME XXX -- we shouldn't need both the
+      // command_history object and the
+      // Vsaving_history variable...
+      command_history::ignore_entries (false);
+
+      unwind_protect::add (restore_command_history, 0);
+
+      unwind_protect_bool (Vsaving_history);
+
+      Vsaving_history = true;
+
+      retval = get_user_input (args, true);
+
+      unwind_protect::run_frame ("keyboard");
+    }
   else
     print_usage ("keyboard");