# HG changeset patch # User Jaroslav Hajek # Date 1246535026 -7200 # Node ID b59e304fe00a18fa701ac2519a119042d55dce7b # Parent 3335e82622ba0933ae3f6d8d2b2bc7daf80cc452 allow which look for files on path diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2009-07-02 Jaroslav Hajek + + * help.cc (do_which): Also look for files. + 2009-07-02 Jaroslav Hajek * Cell.cc (Cell::index): Use proper resize_fill_value. diff --git a/src/help.cc b/src/help.cc --- 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; }