changeset 20546:9502e0142c19

Simplify error output if max_recursion_depth is exceeded (Bug #45843). * error.cc (pr_where): Call unique on std::list frames. * toplev.h (operator==): Declare equality operator for octave_call_stack::stack_frame. * toplev.cc (operator==): Implement equality operator for octave_call_stack::stack_frame.
author Stefan Miereis <stefan.miereis@gmx.de>
date Sat, 05 Sep 2015 01:02:27 +0200
parents 315b7d51d6c8
children 8164c580922b
files libinterp/corefcn/error.cc libinterp/corefcn/toplev.cc libinterp/corefcn/toplev.h
diffstat 3 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/error.cc	Wed Sep 23 15:31:34 2015 +0200
+++ b/libinterp/corefcn/error.cc	Sat Sep 05 01:02:27 2015 +0200
@@ -314,6 +314,10 @@
   if (nframes > 0)
     pr_where_1 ("%s: called from\n", who);
 
+  // Print the error message only if it is different from the previous one;
+  // Makes the output more concise and readable.
+  frames.unique ();
+
   for (std::list<octave_call_stack::stack_frame>::const_iterator p = frames.begin ();
        p != frames.end (); p++)
     {
--- a/libinterp/corefcn/toplev.cc	Wed Sep 23 15:31:34 2015 +0200
+++ b/libinterp/corefcn/toplev.cc	Sat Sep 05 01:02:27 2015 +0200
@@ -130,6 +130,21 @@
   return retval;
 }
 
+bool
+octave_call_stack::stack_frame::operator== (const octave_call_stack::stack_frame &rhs) const
+{
+  if (this->line () != rhs.line ())
+    return false;
+  else if (this->column () != rhs.column ())
+    return false;
+  else if (this->fcn_file_name () != rhs.fcn_file_name ())
+    return false;
+  else if (this->fcn_name () != rhs.fcn_name ())
+    return false;
+  else
+    return true;
+}
+
 void
 octave_call_stack::create_instance (void)
 {
--- a/libinterp/corefcn/toplev.h	Wed Sep 23 15:31:34 2015 +0200
+++ b/libinterp/corefcn/toplev.h	Sat Sep 05 01:02:27 2015 +0200
@@ -107,6 +107,8 @@
 
     std::string fcn_name (bool print_subfn = true) const;
 
+    bool operator== (const stack_frame &rhs) const;
+
   private:
 
     octave_function *m_fcn;