From bug-octave-request at bevo dot che dot wisc dot edu Fri Nov 14 03:00:56 1997 Subject: Re: command history lacks debug commands From: "John W. Eaton" To: Jim Van Zandt Cc: bug-octave at bevo dot che dot wisc dot edu Date: Fri, 14 Nov 1997 03:01:18 -0600 On 8-Apr-1997, Jim Van Zandt wrote: | "John W. Eaton" writes: | >As far as I can tell, the command history is saved when using the | >input and keyboard functions. | ... | >Can you provide a precise set of commands that don't work? | | Here is a script from a run: | | Script started on Tue Apr 8 06:44:27 1997 | vanzandt-pc:~/proj/cec$ cat foobar.m | 0; | a=rand(4,3); | b=rand(4,1); | a\b | keyboard("foobar> "); | vanzandt-pc:~/proj/cec$ octave | Octave, version 2.0.5 (i586-pc-linux-gnu). | Copyright (C) 1996 John W. Eaton. | This is free software with ABSOLUTELY NO WARRANTY. | For details, type `warranty'. | | octave:1> d=1/9 | d = 0.11111 | octave:2> e=sqrt(10)(10) | e = 3.1623 | octave:3> foobe ar | ans = | | 0.66354 | -0.17554 | 0.73907 | | foobar> atan(.6)(.6) | 0.54042 | foobar> sqrt(11)(11) | 3.3166 | foobar> foobare=sqrt(10) | 3.1623 | foobar> quit | octave:4> foobare=sqrt(10) | e = 3.1623 | octave:5> quit | vanzandt-pc:~/proj/cec$ exit | exit | | Script done on Tue Apr 8 06:45:51 1997 | | Aside from indenting, I haven't edited the above at all. Most of the | backspaces are from the "show paren mode". I will append a uuencoded | version of the script in case the backspaces do not survive the mail. | | At the first two foobar> prompts, I typed `atan(.6)' and `sqrt(11)'. | At the third foobar> prompt, I typed ^P twice. The first command | fetched from the history was `foobar', and not `sqrt(11)'. The next | command fetched was `sqrt(10)'. I typed and got the same answer | as before. | | I typed `quit' to finish the keyboard command. | | I then typed ^P, and again the first command fetched was `foobar'. | The commands I had typed to the `foobar>' prompt never went into the | history. | | I am using the debian package octave-2.0.5-1. Here is a patch to try. It should appear in 2.0.10. Thanks, jwe Fri Nov 14 01:53:13 1997 John W. Eaton * variables.cc (Vsaving_history): No longer static. * variables.h (Vsaving_history): Provide declaration. * input.cc (Fkeyboard): Unconditionally turn on history here. *** src/variables.h~ Wed Oct 30 13:32:14 1996 --- src/variables.h Fri Nov 14 02:39:11 1997 *************** *** 175,180 **** --- 185,192 ---- }; extern int Vecho_executing_commands; + + extern int Vsaving_history; #endif *** src/variables.cc~ Mon May 19 20:13:50 1997 --- src/variables.cc Fri Nov 14 02:39:20 1997 *************** *** 104,110 **** static bool Vignore_function_time_stamp; // TRUE if we are saving history. ! static int Vsaving_history; // Symbol table for symbols at the top level. symbol_table *top_level_sym_tab = 0; --- 104,110 ---- static bool Vignore_function_time_stamp; // TRUE if we are saving history. ! int Vsaving_history; // Symbol table for symbols at the top level. symbol_table *top_level_sym_tab = 0; *** src/input.cc~ Tue May 27 10:04:29 1997 --- src/input.cc Fri Nov 14 02:56:35 1997 *************** *** 78,83 **** --- 78,84 ---- #include "sighandlers.h" #include "symtab.h" #include "sysdep.h" + #include "unwind-prot.h" #include "utils.h" #include "variables.h" *************** *** 1133,1138 **** --- 1137,1148 ---- return retval; } + static void + restore_command_history (void *) + { + octave_command_history.ignore_entries (! Vsaving_history); + } + DEFUN (keyboard, args, , "keyboard (PROMPT)\n\ \n\ *************** *** 1143,1149 **** int nargin = args.length (); if (nargin == 0 || nargin == 1) ! retval = get_user_input (args, true); else print_usage ("keyboard"); --- 1153,1176 ---- int nargin = args.length (); if (nargin == 0 || nargin == 1) ! { ! begin_unwind_frame ("keyboard"); ! ! // XXX FIXME XXX -- we shouldn't need both the ! // octave_command_history object and the ! // Vsaving_history variable... ! octave_command_history.ignore_entries (false); ! ! add_unwind_protect (restore_command_history, 0); ! ! unwind_protect_int (Vsaving_history); ! ! Vsaving_history = 1; ! ! retval = get_user_input (args, true); ! ! run_unwind_frame ("keyboard"); ! } else print_usage ("keyboard");