Mercurial > hg > octave-lyh
diff src/variables.cc @ 5534:e107161b8ca3
[project @ 2005-11-11 17:44:05 by jwe]
author | jwe |
---|---|
date | Fri, 11 Nov 2005 17:45:51 +0000 |
parents | 2ff5363a16bd |
children | 2618a0750ae6 |
line wrap: on
line diff
--- a/src/variables.cc +++ b/src/variables.cc @@ -1030,14 +1030,35 @@ std::string nm = fcn->name (); + // XXX FIXME XXX -- the following code is repeated + // in load_fcn_from_file in parse.y. + string_vector names (2); - names[0] = nm + ".oct"; - names[1] = nm + ".m"; - - std::string file = octave_env::make_absolute - (Vload_path_dir_path.find_first_of (names), - octave_env::getcwd ()); + int nm_len = nm.length (); + + std::string file; + + if (octave_env::absolute_pathname (nm) + && ((nm_len > 4 && nm.substr (nm_len-4) == ".oct") + || (nm_len > 2 && nm.substr (nm_len-4) == ".m"))) + { + file = nm; + } + else + { + file = lookup_autoload (nm); + + if (file.empty ()) + { + names[0] = nm + ".oct"; + names[1] = nm + ".m"; + + file = octave_env::make_absolute + (Vload_path_dir_path.find_first_of (names), + octave_env::getcwd ()); + } + } if (same_file (file, ff)) {