diff src/debug.cc @ 5743:a527e0f77aa5

[project @ 2006-04-06 08:20:21 by jwe]
author jwe
date Thu, 06 Apr 2006 08:20:23 +0000
parents 9c9bd01099ce
children 1c36a2e82266
line wrap: on
line diff
--- a/src/debug.cc
+++ b/src/debug.cc
@@ -49,14 +49,20 @@
 #include "unwind-prot.h"
 #include "variables.h"
 
+// Return a pointer to the user-defined function FNAME.  If FNAME is
+// empty, search backward for the first user-defined function in the
+// current call stack.
+
 static octave_user_function *
-get_user_function (std::string str = "")
+get_user_function (std::string fname = "")
 {
   octave_user_function *dbg_fcn = 0;
 
-  if (str.compare (""))
+  if (fname == "")
+    dbg_fcn = octave_call_stack::caller_script ();
+  else
     {
-      symbol_record *ptr = curr_sym_tab->lookup (str);
+      symbol_record *ptr = curr_sym_tab->lookup (fname);
 
       if (ptr && ptr->is_user_function ())
 	{
@@ -65,7 +71,7 @@
 	}
       else
 	{
-	  ptr = lookup_by_name (str, false);
+	  ptr = lookup_by_name (fname, false);
 	
 	  if (ptr && ptr->is_user_function ())
 	    {
@@ -74,8 +80,6 @@
 	    }
 	}
     }
-  else if (curr_caller_function && curr_caller_function->is_user_function ())
-    dbg_fcn = dynamic_cast<octave_user_function *> (curr_caller_function);
 
   return dbg_fcn;
 }
@@ -282,10 +286,7 @@
 {
   octave_value retval;
 
-  octave_user_function *dbg_fcn = 0;
-
-  if (curr_caller_function && curr_caller_function->is_user_function ())
-    dbg_fcn = dynamic_cast<octave_user_function *> (curr_caller_function);
+  octave_user_function *dbg_fcn = get_user_function ();
 
   if (dbg_fcn)
     {