changeset 18892: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
parents 7bbe3658c5ef
children da6ffbf75edf
files libinterp/corefcn/variables.cc
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/variables.cc	Wed Jun 25 13:45:41 2014 -0700
+++ b/libinterp/corefcn/variables.cc	Wed Jun 25 14:03:20 2014 -0700
@@ -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);