Mercurial > hg > octave-jordi
diff libinterp/corefcn/variables.cc @ 18857:a1dde4d4c45c
Return correct exist code for mex files when .mex extension given (bug #42614).
* variables.cc (symbol_exist): Check for '.mex' extension on file found in path
and return code 3 if found.
* variables.cc (Fexist): Add %!test for new behavior.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 25 Jun 2014 14:03:20 -0700 (2014-06-25) |
parents | de8c67ba7ac4 |
children | da6ffbf75edf |
line wrap: on
line diff
--- a/libinterp/corefcn/variables.cc +++ b/libinterp/corefcn/variables.cc @@ -454,7 +454,18 @@ if (fs) { if (search_any || search_file) - return fs.is_dir () ? 7 : 2; + { + if (fs.is_dir ()) + return 7; + + size_t len = file_name.length (); + + if (len > 4 && (file_name.substr (len-4) == ".oct" + || file_name.substr (len-4) == ".mex")) + return 3; + else + return 2; + } else if (search_dir && fs.is_dir ()) return 7; } @@ -602,6 +613,7 @@ %!testif HAVE_CHOLMOD %! assert (exist ("chol"), 3); +%! assert (exist ("chol.oct"), 3); %! assert (exist ("chol", "file"), 3); %! assert (exist ("chol", "builtin"), 0);