diff src/help.cc @ 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 610bf90fce2a
children 8e345f2fe4d6
line wrap: on
line diff
--- 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;
 }