# HG changeset patch # User John W. Eaton # Date 1215615492 14400 # Node ID 8018e10d2b8774eead9fe90f96e714f29c67de17 # Parent c51ae36fcbce829ad019e13b6803dc95eb4240ff save and restore global_command as needed diff -r c51ae36fcbce -r 8018e10d2b87 src/ChangeLog --- a/src/ChangeLog Tue Jul 08 14:22:08 2008 -0400 +++ b/src/ChangeLog Wed Jul 09 10:58:12 2008 -0400 @@ -1,3 +1,8 @@ +2008-07-09 John W. Eaton + + * toplev.cc (main_loop): Unwind-protect global_command. + * input.cc (get_debug_input): Likewise. + 2008-07-08 John W. Eaton * graphics.h.in (axes::properties::keypos): Declare as diff -r c51ae36fcbce -r 8018e10d2b87 src/input.cc --- a/src/input.cc Tue Jul 08 14:22:08 2008 -0400 +++ b/src/input.cc Wed Jul 09 10:58:12 2008 -0400 @@ -625,16 +625,24 @@ reset_parser (); + // Save current value of global_command. + unwind_protect_ptr (global_command); + // This is the same as yyparse in parse.y. int retval = octave_parse (); - if (retval == 0 && global_command) - { - global_command->eval (); + tree_statement_list *command = global_command; + + // Restore previous value of global_command. + unwind_protect::run (); - delete global_command; + if (retval == 0 && command) + { + command->eval (); - global_command = 0; + delete command; + + command = 0; OCTAVE_QUIT; diff -r c51ae36fcbce -r 8018e10d2b87 src/parse.y --- a/src/parse.y Tue Jul 08 14:22:08 2008 -0400 +++ b/src/parse.y Wed Jul 09 10:58:12 2008 -0400 @@ -3719,8 +3719,6 @@ current_eval_string = s; - unwind_protect_ptr (global_command); - YY_BUFFER_STATE old_buf = current_buffer (); YY_BUFFER_STATE new_buf = create_buffer (0); @@ -3733,10 +3731,15 @@ { reset_parser (); + unwind_protect_ptr (global_command); + parse_status = yyparse (); tree_statement_list *command = global_command; + // Restore previous value of global_command. + unwind_protect::run (); + if (parse_status == 0) { if (command) diff -r c51ae36fcbce -r 8018e10d2b87 src/toplev.cc --- a/src/toplev.cc Tue Jul 08 14:22:08 2008 -0400 +++ b/src/toplev.cc Wed Jul 09 10:58:12 2008 -0400 @@ -543,6 +543,8 @@ octave_initialized = true; + unwind_protect::begin_frame ("main_loop"); + // The big loop. int retval = 0; @@ -556,18 +558,26 @@ reset_parser (); + // Save current value of global_command. + unwind_protect_ptr (global_command); + // This is the same as yyparse in parse.y. retval = octave_parse (); + tree_statement_list *command = global_command; + + // Restore previous value of global_command. + unwind_protect::run (); + if (retval == 0) { - if (global_command) + if (command) { - global_command->eval (); + command->eval (); - delete global_command; + delete command; - global_command = 0; + command = 0; OCTAVE_QUIT; @@ -622,6 +632,8 @@ } while (retval == 0); + unwind_protect::run_frame ("main_loop"); + return retval; }