Mercurial > hg > octave-nkf
changeset 9416:2cc47338e427
allow which look for files on path
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 02 Jul 2009 13:26:15 +0200 |
parents | f16079069972 |
children | 5d46c4a894e8 |
files | src/ChangeLog src/help.cc |
diffstat | 2 files changed, 36 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2009-07-02 Jaroslav Hajek <highegg@gmail.com> + + * help.cc (do_which): Also look for files. + 2009-07-02 Jaroslav Hajek <highegg@gmail.com> * Cell.cc (Cell::index): Use proper resize_fill_value.
--- a/src/help.cc +++ b/src/help.cc @@ -821,33 +821,47 @@ octave_value val = symbol_table::find_function (name); - if (val.is_defined ()) + if (name.find_first_of ('.') == std::string::npos) { - octave_function *fcn = val.function_value (); + if (val.is_defined ()) + { + octave_function *fcn = val.function_value (); - if (fcn) - { - file = fcn->fcn_file_name (); + if (fcn) + { + file = fcn->fcn_file_name (); - if (file.empty ()) - { - if (fcn->is_user_function ()) - type = "command-line function"; - else - type = "built-in function"; - } - else - type = val.is_user_script () - ? std::string ("script") : std::string ("function"); - } + if (file.empty ()) + { + if (fcn->is_user_function ()) + type = "command-line function"; + else + type = "built-in function"; + } + else + type = val.is_user_script () + ? std::string ("script") : std::string ("function"); + } + } + else + { + // We might find a file that contains only a doc string. + + file = load_path::find_fcn_file (name); + } } else { - // We might find a file that contains only a doc string. + // File query. - file = load_path::find_fcn_file (name); + // For compatibility: "file." queries "file". + if (name.size () > 1 && name[name.size () - 1] == '.') + file = load_path::find_file (name.substr (0, name.size () - 1)); + else + file = load_path::find_file (name); } + return file; }