changeset 10067:6f79338c269b

omission from last patch
author Jaroslav Hajek <highegg@gmail.com>
date Wed, 06 Jan 2010 22:17:01 +0100
parents 2cd940306a06
children ca93f583573d
files src/oct-parse.yy
diffstat 1 files changed, 93 insertions(+), 119 deletions(-) [+]
line wrap: on
line diff
--- a/src/oct-parse.yy	Wed Jan 06 13:18:41 2010 +0100
+++ b/src/oct-parse.yy	Wed Jan 06 22:17:01 2010 +0100
@@ -1806,13 +1806,13 @@
 {
   tree_expression *retval = e;
 
-  unwind_protect::frame_id_t uwp_frame = unwind_protect::begin_frame ();
-
-  unwind_protect::protect_var (error_state);
-  unwind_protect::protect_var (warning_state);
-
-  unwind_protect::protect_var (discard_error_messages);
-  unwind_protect::protect_var (discard_warning_messages);
+  unwind_protect frame;
+
+  frame.protect_var (error_state);
+  frame.protect_var (warning_state);
+
+  frame.protect_var (discard_error_messages);
+  frame.protect_var (discard_warning_messages);
 
   discard_error_messages = true;
   discard_warning_messages = true;
@@ -1849,8 +1849,6 @@
 	}
     }
 
-  unwind_protect::run_frame (uwp_frame);
-
   return retval;
 }
 
@@ -1859,13 +1857,13 @@
 {
   tree_expression *retval = e;
 
-  unwind_protect::frame_id_t uwp_frame = unwind_protect::begin_frame ();
-
-  unwind_protect::protect_var (error_state);
-  unwind_protect::protect_var (warning_state);
-
-  unwind_protect::protect_var (discard_error_messages);
-  unwind_protect::protect_var (discard_warning_messages);
+  unwind_protect frame;
+
+  frame.protect_var (error_state);
+  frame.protect_var (warning_state);
+
+  frame.protect_var (discard_error_messages);
+  frame.protect_var (discard_warning_messages);
 
   discard_error_messages = true;
   discard_warning_messages = true;
@@ -1895,8 +1893,6 @@
 	}
     }
 
-  unwind_protect::run_frame (uwp_frame);
-
   return retval;
 }
 
@@ -1907,13 +1903,13 @@
 {
   tree_expression *retval = e;
 
-  unwind_protect::frame_id_t uwp_frame = unwind_protect::begin_frame ();
-
-  unwind_protect::protect_var (error_state);
-  unwind_protect::protect_var (warning_state);
-
-  unwind_protect::protect_var (discard_error_messages);
-  unwind_protect::protect_var (discard_warning_messages);
+  unwind_protect frame;
+
+  frame.protect_var (error_state);
+  frame.protect_var (warning_state);
+
+  frame.protect_var (discard_error_messages);
+  frame.protect_var (discard_warning_messages);
 
   discard_error_messages = true;
   discard_warning_messages = true;
@@ -1961,8 +1957,6 @@
 	}
     }
 
-  unwind_protect::run_frame (uwp_frame);
-
   return retval;
 }
 
@@ -3125,13 +3119,13 @@
 {
   tree_expression *retval = m;
 
-  unwind_protect::frame_id_t uwp_frame = unwind_protect::begin_frame ();
-
-  unwind_protect::protect_var (error_state);
-  unwind_protect::protect_var (warning_state);
-
-  unwind_protect::protect_var (discard_error_messages);
-  unwind_protect::protect_var (discard_warning_messages);
+  unwind_protect frame;
+
+  frame.protect_var (error_state);
+  frame.protect_var (warning_state);
+
+  frame.protect_var (discard_error_messages);
+  frame.protect_var (discard_warning_messages);
 
   discard_error_messages = true;
   discard_warning_messages = true;
@@ -3159,8 +3153,6 @@
 	}
     }
 
-  unwind_protect::run_frame (uwp_frame);
-
   return retval;
 }
 
@@ -3242,7 +3234,7 @@
 }
 
 static void
-safe_fclose (void *f)
+safe_fclose (FILE *f)
 {
   // FIXME -- comments at the end of an input file are
   // discarded (otherwise, they would be appended to the next
@@ -3429,7 +3421,7 @@
 		bool force_script = false, bool require_file = true,
 		const std::string& warn_for = std::string ())
 {
-  unwind_protect::frame_id_t uwp_frame = unwind_protect::begin_frame ();
+  unwind_protect frame;
 
   octave_function *fcn_ptr = 0;
 
@@ -3437,20 +3429,19 @@
 
   FILE *in_stream = command_editor::get_input_stream ();
 
-  unwind_protect::add_fcn (command_editor::set_input_stream,
-                           in_stream);
-
-  unwind_protect::protect_var (ff_instream);
-
-  unwind_protect::protect_var (input_line_number);
-  unwind_protect::protect_var (current_input_column);
-  unwind_protect::protect_var (reading_fcn_file);
-  unwind_protect::protect_var (line_editing);
-  unwind_protect::protect_var (current_class_name);
-  unwind_protect::protect_var (current_function_depth);
-  unwind_protect::protect_var (max_function_depth);
-  unwind_protect::protect_var (parsing_subfunctions);
-  unwind_protect::protect_var (endfunction_found);
+  frame.add_fcn (command_editor::set_input_stream, in_stream);
+
+  frame.protect_var (ff_instream);
+
+  frame.protect_var (input_line_number);
+  frame.protect_var (current_input_column);
+  frame.protect_var (reading_fcn_file);
+  frame.protect_var (line_editing);
+  frame.protect_var (current_class_name);
+  frame.protect_var (current_function_depth);
+  frame.protect_var (max_function_depth);
+  frame.protect_var (parsing_subfunctions);
+  frame.protect_var (endfunction_found);
 
   input_line_number = 1;
   current_input_column = 1;
@@ -3463,20 +3454,20 @@
   endfunction_found = false;
 
   // The next four lines must be in this order.
-  unwind_protect::add_fcn (command_history::ignore_entries, ! Vsaving_history);
+  frame.add_fcn (command_history::ignore_entries, ! Vsaving_history);
 
   // FIXME -- we shouldn't need both the
   // command_history object and the
   // Vsaving_history variable...
   command_history::ignore_entries ();
 
-  unwind_protect::protect_var (Vsaving_history);
+  frame.protect_var (Vsaving_history);
 
   Vsaving_history = false;
 
   FILE *ffile = get_input_from_file (ff, 0);
 
-  unwind_protect::add (safe_fclose, ffile);
+  frame.add_fcn (safe_fclose, ffile);
 
   if (ffile)
     {
@@ -3488,12 +3479,12 @@
 	{
 	  std::string file_type;
 
-	  unwind_protect::protect_var (get_input_from_eval_string);
-	  unwind_protect::protect_var (parser_end_of_input);
-	  unwind_protect::protect_var (reading_fcn_file);
-	  unwind_protect::protect_var (reading_script_file);
-	  unwind_protect::protect_var (reading_classdef_file);
-	  unwind_protect::protect_var (Vecho_executing_commands);
+	  frame.protect_var (get_input_from_eval_string);
+	  frame.protect_var (parser_end_of_input);
+	  frame.protect_var (reading_fcn_file);
+	  frame.protect_var (reading_script_file);
+	  frame.protect_var (reading_classdef_file);
+	  frame.protect_var (Vecho_executing_commands);
 
 
 	  get_input_from_eval_string = false;
@@ -3533,12 +3524,12 @@
 	  YY_BUFFER_STATE old_buf = current_buffer ();
 	  YY_BUFFER_STATE new_buf = create_buffer (ffile);
 
-	  unwind_protect::add_fcn (switch_to_buffer, old_buf);
-	  unwind_protect::add_fcn (delete_buffer, new_buf);
+	  frame.add_fcn (switch_to_buffer, old_buf);
+	  frame.add_fcn (delete_buffer, new_buf);
 
 	  switch_to_buffer (new_buf);
 
-	  unwind_protect::protect_var (primary_fcn_ptr);
+	  frame.protect_var (primary_fcn_ptr);
 	  primary_fcn_ptr = 0;
 
 	  reset_parser ();
@@ -3547,7 +3538,7 @@
 	  // the forced variables will be unmarked in the event of an
 	  // interrupt. 
 	  symbol_table::scope_id scope = symbol_table::top_scope ();
-	  unwind_protect::add_fcn (symbol_table::unmark_forced_variables, scope);
+	  frame.add_fcn (symbol_table::unmark_forced_variables, scope);
 
 	  if (! help_txt.empty ())
 	    help_buf.push (help_txt);
@@ -3578,8 +3569,6 @@
   else if (! warn_for.empty ())
     error ("%s: unable to open file `%s'", warn_for.c_str (), ff.c_str ());    
 
-  unwind_protect::run_frame (uwp_frame);
-
   return fcn_ptr;
 }
 
@@ -3599,7 +3588,8 @@
 
       if (fptr)
 	{
-	  unwind_protect::add (safe_fclose, fptr);
+	  unwind_protect frame;
+	  frame.add_fcn (safe_fclose, fptr);
 
 	  bool eof;
 	  retval = gobble_leading_white_space (fptr, eof);
@@ -3615,8 +3605,6 @@
 		  delete fcn;
 		}
 	    }
-
-	  unwind_protect::run ();
 	}
     }
 
@@ -3678,7 +3666,7 @@
 {
   octave_function *retval = 0;
 
-  unwind_protect::frame_id_t uwp_frame = unwind_protect::begin_frame ();
+  unwind_protect frame;
 
   std::string nm = file_name;
 
@@ -3686,7 +3674,7 @@
 
   std::string file;
 
-  unwind_protect::protect_var (fcn_file_from_relative_lookup);
+  frame.protect_var (fcn_file_from_relative_lookup);
 
   fcn_file_from_relative_lookup = false;
 
@@ -3702,7 +3690,7 @@
 
   if (autoload)
     {
-      unwind_protect::protect_var (autoloading);
+      frame.protect_var (autoloading);
       autoloading = true;
     }
 
@@ -3725,8 +3713,8 @@
     {
       // These are needed by yyparse.
 
-      unwind_protect::protect_var (curr_fcn_file_name);
-      unwind_protect::protect_var (curr_fcn_file_full_name);
+      frame.protect_var (curr_fcn_file_name);
+      frame.protect_var (curr_fcn_file_full_name);
 
       curr_fcn_file_name = nm;
       curr_fcn_file_full_name = file;
@@ -3746,8 +3734,6 @@
 	}
     }
 
-  unwind_protect::run_frame (uwp_frame);
-
   return retval;
 }
 
@@ -3862,10 +3848,10 @@
 {
   std::string file_full_name = file_ops::tilde_expand (file_name);
 
-  unwind_protect::frame_id_t uwp_frame = unwind_protect::begin_frame ();
-
-  unwind_protect::protect_var (curr_fcn_file_name);
-  unwind_protect::protect_var (curr_fcn_file_full_name);
+  unwind_protect frame;
+
+  frame.protect_var (curr_fcn_file_name);
+  frame.protect_var (curr_fcn_file_full_name);
 
   curr_fcn_file_name = file_name;
   curr_fcn_file_full_name = file_full_name;
@@ -3880,7 +3866,7 @@
 	error ("source: context must be \"caller\" or \"base\"");
 
       if (! error_state)
-	unwind_protect::add_fcn (octave_call_stack::pop);
+	frame.add_fcn (octave_call_stack::pop);
     }      
 
   if (! error_state)
@@ -3913,8 +3899,6 @@
 	error ("source: error sourcing file `%s'",
 	       file_full_name.c_str ());
     }
-
-  unwind_protect::run_frame (uwp_frame);
 }
 
 DEFUN (mfilename, args, ,
@@ -4170,19 +4154,19 @@
 {
   octave_value_list retval;
 
-  unwind_protect::frame_id_t uwp_frame = unwind_protect::begin_frame ();
-
-  unwind_protect::protect_var (input_line_number);
-  unwind_protect::protect_var (current_input_column);
-  unwind_protect::protect_var (get_input_from_eval_string);
-  unwind_protect::protect_var (input_from_eval_string_pending);
-  unwind_protect::protect_var (parser_end_of_input);
-  unwind_protect::protect_var (line_editing);
-  unwind_protect::protect_var (current_eval_string);
-  unwind_protect::protect_var (current_function_depth);
-  unwind_protect::protect_var (max_function_depth);
-  unwind_protect::protect_var (parsing_subfunctions);
-  unwind_protect::protect_var (endfunction_found);
+  unwind_protect frame;
+
+  frame.protect_var (input_line_number);
+  frame.protect_var (current_input_column);
+  frame.protect_var (get_input_from_eval_string);
+  frame.protect_var (input_from_eval_string_pending);
+  frame.protect_var (parser_end_of_input);
+  frame.protect_var (line_editing);
+  frame.protect_var (current_eval_string);
+  frame.protect_var (current_function_depth);
+  frame.protect_var (max_function_depth);
+  frame.protect_var (parsing_subfunctions);
+  frame.protect_var (endfunction_found);
 
   input_line_number = 1;
   current_input_column = 1;
@@ -4200,8 +4184,8 @@
   YY_BUFFER_STATE old_buf = current_buffer ();
   YY_BUFFER_STATE new_buf = create_buffer (0);
 
-  unwind_protect::add_fcn (switch_to_buffer, old_buf);
-  unwind_protect::add_fcn (delete_buffer, new_buf);
+  frame.add_fcn (switch_to_buffer, old_buf);
+  frame.add_fcn (delete_buffer, new_buf);
 
   switch_to_buffer (new_buf);
 
@@ -4209,23 +4193,21 @@
     {
       reset_parser ();
 
-      unwind_protect::protect_var (global_command);
+      frame.protect_var (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_fcn (symbol_table::unmark_forced_variables, scope);
+      frame.add_fcn (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 ();
+      frame.run_top (2);
 
       if (parse_status == 0)
         {
@@ -4283,8 +4265,6 @@
     }
   while (parse_status == 0);
 
-  unwind_protect::run_frame (uwp_frame);
-
   return retval;
 }
 
@@ -4348,11 +4328,11 @@
 
   if (nargin > 0)
     {
-      unwind_protect::frame_id_t uwp_frame = unwind_protect::begin_frame ();
+      unwind_protect frame;
 
       if (nargin > 1)
 	{
-	  unwind_protect::protect_var (buffer_error_messages);
+	  frame.protect_var (buffer_error_messages);
 	  buffer_error_messages++;
 	}
 
@@ -4377,8 +4357,6 @@
 	}
       else if (nargout > 0)
 	retval = tmp;
-
-      unwind_protect::run_frame (uwp_frame);
     }
   else
     print_usage ();
@@ -4486,7 +4464,7 @@
 
       if (! error_state)
         {
-	  unwind_protect::frame_id_t uwp_frame = unwind_protect::begin_frame ();
+	  unwind_protect frame;
 
 	  if (context == "caller")
 	    octave_call_stack::goto_caller_frame ();
@@ -4497,7 +4475,7 @@
 
 	  if (! error_state)
 	    {
-	      unwind_protect::add_fcn (octave_call_stack::pop);
+	      frame.add_fcn (octave_call_stack::pop);
 
 	      std::string nm = args(1).string_value ();
 
@@ -4511,8 +4489,6 @@
 	      else
 		error ("assignin: expecting variable name as second argument");
 	    }
-
-	  unwind_protect::run_frame (uwp_frame);
 	}
       else
         error ("assignin: expecting string as first argument");
@@ -4541,7 +4517,7 @@
 
       if (! error_state)
         {
-	  unwind_protect::frame_id_t uwp_frame = unwind_protect::begin_frame ();
+	  unwind_protect frame;
 
 	  if (context == "caller")
 	    octave_call_stack::goto_caller_frame ();
@@ -4552,11 +4528,11 @@
 
 	  if (! error_state)
 	    {
-	      unwind_protect::add_fcn (octave_call_stack::pop);
+	      frame.add_fcn (octave_call_stack::pop);
 
 	      if (nargin > 2)
 	        {
-		  unwind_protect::protect_var (buffer_error_messages);
+		  frame.protect_var (buffer_error_messages);
 		  buffer_error_messages++;
 		}
 
@@ -4583,8 +4559,6 @@
 		  retval = (nargout > 0) ? tmp : octave_value_list ();
 		}
 	    }
-
-	  unwind_protect::run_frame (uwp_frame);
 	}
       else
         error ("evalin: expecting string as first argument");