# HG changeset patch # User John W. Eaton # Date 1343071421 14400 # Node ID 74c7265c057afcc2975d40753fa114c539de5823 # Parent ea69976576142602e3314aba2987db2188948906 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. diff --git a/src/help.cc b/src/help.cc --- a/src/help.cc +++ b/src/help.cc @@ -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 () diff --git a/src/ov-builtin.h b/src/ov-builtin.h --- a/src/ov-builtin.h +++ b/src/ov-builtin.h @@ -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& idx) diff --git a/src/ov-fcn-handle.cc b/src/ov-fcn-handle.cc --- a/src/ov-fcn-handle.cc +++ b/src/ov-fcn-handle.cc @@ -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"; } diff --git a/src/ov-fcn.h b/src/ov-fcn.h --- a/src/ov-fcn.h +++ b/src/ov-fcn.h @@ -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 (); }