# HG changeset patch # User John W. Eaton # Date 1243351240 14400 # Node ID 9c2349a51218d876cf6b6c2866a6c12c49bfe42e # Parent 75c502937d2cd4a25e0d6e703ef23da664aed77b properly unmark forced variables diff -r 75c502937d2c -r 9c2349a51218 src/ChangeLog --- a/src/ChangeLog Tue Mar 17 20:36:01 2009 +0100 +++ b/src/ChangeLog Tue May 26 11:20:40 2009 -0400 @@ -1,3 +1,20 @@ +2009-05-26 John W. Eaton + + * symtab.h + (symbol_table::symbol_record::symbol_record_rep::is_variable): + Use "! is_local ()" instead of storage_class != local. + (symbol_table::do_variable_names): Only add variables to the list. + (symbol_table::unmark_forced_variables): New static function + * variables.cc (do_who): Use is_variable instead of is_defined. + Also limit output to variables when using regexp pattern. + * octave.cc (unmark_forced_vars): Delete. + (execute_eval_option_code): Don't add unmark_forced_vars to + unwind_protect stack here. + * toplev.cc (main_loop): Add symbol_table::unmark_forced_variables + to the unwind_protect stack here. + * input.cc (get_debug_input): Likewise. + * parse.y (parse_fcn_file, eval_string): Likewise. + 2009-05-25 Jaroslav Hajek * toplev.h (quit_allowed): New global variable. diff -r 75c502937d2c -r 9c2349a51218 src/input.cc --- a/src/input.cc Tue Mar 17 20:36:01 2009 +0100 +++ b/src/input.cc Tue May 26 11:20:40 2009 -0400 @@ -666,6 +666,11 @@ // Save current value of global_command. unwind_protect_ptr (global_command); + // Do this with an unwind-protect cleanup function so that the + // forced variables will be unmarked in the event of an interrupt. + symbol_table::scope_id scope = symbol_table::top_scope (); + unwind_protect::add (symbol_table::unmark_forced_variables, &scope); + // This is the same as yyparse in parse.y. int retval = octave_parse (); @@ -687,6 +692,9 @@ octave_completion_matches_called = false; } + // Unmark forced variables. + unwind_protect::run (); + // Restore previous value of global_command. unwind_protect::run (); diff -r 75c502937d2c -r 9c2349a51218 src/octave.cc --- a/src/octave.cc Tue Mar 17 20:36:01 2009 +0100 +++ b/src/octave.cc Tue May 26 11:20:40 2009 -0400 @@ -367,18 +367,6 @@ unwind_protect::run_frame ("execute_startup_files"); } -static void -unmark_forced_vars (void *arg) -{ - // Unmark any symbols that may have been tagged as local variables - // while parsing (for example, by force_local_variable in lex.l). - - symbol_table::scope_id *pscope = static_cast (arg); - - if (pscope) - symbol_table::unmark_forced_variables (*pscope); -} - static int execute_eval_option_code (const std::string& code) { @@ -398,11 +386,6 @@ unwind_protect_bool (interactive); - // Do this with an unwind-protect cleanup function so that the - // forced variables will be unmarked in the event of an interrupt. - symbol_table::scope_id scope = symbol_table::top_scope (); - unwind_protect::add (unmark_forced_vars, &scope); - interactive = false; int parse_status = 0; diff -r 75c502937d2c -r 9c2349a51218 src/parse.y --- a/src/parse.y Tue Mar 17 20:36:01 2009 +0100 +++ b/src/parse.y Tue May 26 11:20:40 2009 -0400 @@ -3258,6 +3258,12 @@ reset_parser (); + // Do this with an unwind-protect cleanup function so that + // the forced variables will be unmarked in the event of an + // interrupt. + symbol_table::scope_id scope = symbol_table::top_scope (); + unwind_protect::add (symbol_table::unmark_forced_variables, &scope); + if (! help_txt.empty ()) help_buf.push (help_txt); @@ -3905,10 +3911,19 @@ unwind_protect_ptr (global_command); + // Do this with an unwind-protect cleanup function so that the + // forced variables will be unmarked in the event of an + // interrupt. + symbol_table::scope_id scope = symbol_table::top_scope (); + unwind_protect::add (symbol_table::unmark_forced_variables, &scope); + parse_status = yyparse (); tree_statement_list *command_list = global_command; + // Unmark forced variables. + unwind_protect::run (); + // Restore previous value of global_command. unwind_protect::run (); diff -r 75c502937d2c -r 9c2349a51218 src/symtab.h --- a/src/symtab.h Tue Mar 17 20:36:01 2009 +0100 +++ b/src/symtab.h Tue May 26 11:20:40 2009 -0400 @@ -297,7 +297,7 @@ bool is_variable (context_id context) const { - return (storage_class != local || is_defined (context) || is_forced ()); + return (! is_local () || is_defined (context) || is_forced ()); } bool is_local (void) const { return storage_class & local; } @@ -1335,6 +1335,19 @@ } // For unwind_protect. + static void unmark_forced_variables (void *arg) + { + // Unmark any symbols that may have been tagged as local variables + // while parsing (for example, by force_local_variable in lex.l). + + symbol_table::scope_id *p = static_cast (arg); + + if (p) + unmark_forced_variables (*p); +} + + + // For unwind_protect. static void clear_variables (void *) { clear_variables (); } static void clear_functions (void) @@ -2289,7 +2302,10 @@ std::list retval; for (table_const_iterator p = table.begin (); p != table.end (); p++) - retval.push_back (p->first); + { + if (p->second.is_variable ()) + retval.push_back (p->first); + } retval.sort (); diff -r 75c502937d2c -r 9c2349a51218 src/toplev.cc --- a/src/toplev.cc Tue Mar 17 20:36:01 2009 +0100 +++ b/src/toplev.cc Tue May 26 11:20:40 2009 -0400 @@ -548,10 +548,18 @@ { try { + unwind_protect::begin_frame ("main_loop"); + reset_error_handler (); reset_parser (); + // Do this with an unwind-protect cleanup function so that + // the forced variables will be unmarked in the event of an + // interrupt. + symbol_table::scope_id scope = symbol_table::top_scope (); + unwind_protect::add (symbol_table::unmark_forced_variables, &scope); + // This is the same as yyparse in parse.y. retval = octave_parse (); @@ -602,6 +610,8 @@ else if (parser_end_of_input) break; } + + unwind_protect::run_frame ("main_loop"); } catch (octave_quit_exception e) { diff -r 75c502937d2c -r 9c2349a51218 src/variables.cc --- a/src/variables.cc Tue Mar 17 20:36:01 2009 +0100 +++ b/src/variables.cc Tue May 26 11:20:40 2009 -0400 @@ -1453,10 +1453,13 @@ for (std::list::const_iterator p = tmp.begin (); p != tmp.end (); p++) { - if (verbose) - symbol_stats.append (*p); - else - symbol_names.push_back (p->name ()); + if (p->is_variable ()) + { + if (verbose) + symbol_stats.append (*p); + else + symbol_names.push_back (p->name ()); + } } } else @@ -1505,7 +1508,7 @@ for (std::list::const_iterator p = tmp.begin (); p != tmp.end (); p++) { - if (p->is_defined ()) + if (p->is_variable ()) { if (verbose) symbol_stats.append (*p);