changeset 16492:91c32a702284

Correctly fill stack field in lasterror() when given as input. * libinterp/interpfcn/error.cc(Flasterror): If stack field is given, use it to fill out Vlast_error_stack. Otherwise, do the current behavior of filling it with backtrace info.
author Rik <rik@octave.org>
date Wed, 10 Apr 2013 11:23:31 -0700
parents b10a23fe80bb
children 3a2daa39c682
files libinterp/interpfcn/error.cc
diffstat 1 files changed, 17 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/interpfcn/error.cc	Wed Apr 10 22:43:30 2013 -0700
+++ b/libinterp/interpfcn/error.cc	Wed Apr 10 11:23:31 2013 -0700
@@ -1703,6 +1703,7 @@
           else if (args(0).is_map ())
             {
               octave_scalar_map new_err = args(0).scalar_map_value ();
+              octave_scalar_map new_err_stack;
               std::string new_error_message;
               std::string new_error_id;
               std::string new_error_file;
@@ -1726,7 +1727,7 @@
 
               if (! error_state && new_err.contains ("stack"))
                 {
-                  octave_scalar_map new_err_stack =
+                  new_err_stack = 
                     new_err.getfield ("stack").scalar_map_value ();
 
                   if (! error_state && new_err_stack.contains ("file"))
@@ -1763,10 +1764,22 @@
                   Vlast_error_message = new_error_message;
                   Vlast_error_id = new_error_id;
 
-                  octave_idx_type curr_frame = -1;
+                  if (new_err.contains ("stack"))
+                    {
+                      new_err_stack.setfield ("file", new_error_file);
+                      new_err_stack.setfield ("name", new_error_name);
+                      new_err_stack.setfield ("line", new_error_line);
+                      new_err_stack.setfield ("column", new_error_column);
+                      Vlast_error_stack = new_err_stack;
+                    }
+                  else
+                    {
+                      // No stack field.  Fill it in with backtrace info.
+                      octave_idx_type curr_frame = -1;
 
-                  Vlast_error_stack
-                    = octave_call_stack::backtrace (0, curr_frame);
+                      Vlast_error_stack
+                        = octave_call_stack::backtrace (0, curr_frame);
+                    }
                 }
             }
           else