changeset 15005:74c7265c057a

fix failure with function handles caused by changeset ea6997657614 * ov-fcn-handle.cc (octave_fcn_handle::set_fcn): Undo previous change. * ov-fcn.h (octave_function::src_file_name): New virtual function. * ov-builtin.h (octave_builtin::src_file_name): Rename from octave_builtin::fcn_file_name. * help.cc (do_which): Return source file name for built-in functions.
author John W. Eaton <jwe@octave.org>
date Mon, 23 Jul 2012 15:23:41 -0400
parents ea6997657614
children d8acad691f26
files src/help.cc src/ov-builtin.h src/ov-fcn-handle.cc src/ov-fcn.h
diffstat 4 files changed, 14 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/help.cc	Mon Jul 23 12:59:44 2012 -0400
+++ b/src/help.cc	Mon Jul 23 15:23:41 2012 -0400
@@ -1118,7 +1118,10 @@
                   if (fcn->is_user_function ())
                     type = "command-line function";
                   else
-                    type = "built-in function";
+                    {
+                      file = fcn->src_file_name ();
+                      type = "built-in function";
+                    }
                 }
               else
                 type = val.is_user_script ()
--- a/src/ov-builtin.h	Mon Jul 23 12:59:44 2012 -0400
+++ b/src/ov-builtin.h	Mon Jul 23 15:23:41 2012 -0400
@@ -54,7 +54,7 @@
 
   ~octave_builtin (void) { }
 
-  std::string fcn_file_name (void) const { return file; }
+  std::string src_file_name (void) const { return file; }
 
   octave_value subsref (const std::string& type,
                         const std::list<octave_value_list>& idx)
--- a/src/ov-fcn-handle.cc	Mon Jul 23 12:59:44 2012 -0400
+++ b/src/ov-fcn-handle.cc	Mon Jul 23 15:23:41 2012 -0400
@@ -313,11 +313,7 @@
     }
   else
     {
-      size_t fpath_len = fpath.length ();
-
-      if ((fpath_len > 4 && fpath.substr (fpath_len-4) == ".oct")
-          || (fpath_len > 4 && fpath.substr (fpath_len-4) == ".mex")
-          || (fpath_len > 2 && fpath.substr (fpath_len-4) == ".m"))
+      if (fpath.length () > 0)
         {
           size_t xpos = fpath.find_last_of (file_ops::dir_sep_chars ());
 
@@ -331,6 +327,11 @@
 
               fcn = octave_value (new octave_fcn_handle (tmp, nm));
             }
+          else
+            {
+              error ("function handle points to non-existent function");
+              success = false;
+            }
         }
       else
         {
@@ -383,10 +384,9 @@
     {
       octave_function *f = function_value ();
       std::string fnm = f ? f->fcn_file_name () : std::string ();
-      bool is_builtin = f && f->is_builtin_function ();
 
       os << "# octaveroot: " << OCTAVE_EXEC_PREFIX << "\n";
-      if (! (is_builtin || fnm.empty ()))
+      if (! fnm.empty ())
         os << "# path: " << fnm << "\n";
       os << nm << "\n";
     }
--- a/src/ov-fcn.h	Mon Jul 23 12:59:44 2012 -0400
+++ b/src/ov-fcn.h	Mon Jul 23 15:23:41 2012 -0400
@@ -61,6 +61,8 @@
 
   virtual std::string fcn_file_name (void) const { return std::string (); }
 
+  virtual std::string src_file_name (void) const { return std::string (); }
+
   // The name to show in the profiler (also used as map-key).
   virtual std::string profiler_name (void) const { return name (); }