changeset 10334:db540cb0e959

improve shadowed function checking
author Jaroslav Hajek <highegg@gmail.com>
date Thu, 18 Feb 2010 08:40:17 +0100
parents 0c42b6b7da24
children 9dd04a06410e
files src/ChangeLog src/load-path.cc
diffstat 2 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Thu Feb 18 01:36:04 2010 -0500
+++ b/src/ChangeLog	Thu Feb 18 08:40:17 2010 +0100
@@ -1,3 +1,8 @@
+2010-02-18  Jaroslav Hajek  <highegg@gmail.com>
+
+	* load-path.cc (in_path_list): New helper function.
+	(add_to_fcn_map): Use it here.
+
 2010-02-18  Søren Hauberg  <hauberg@gmail.com>
 
 	* DLD-FUNCTIONS/__magick_read__.cc (__magick_finfo__):
--- a/src/load-path.cc	Thu Feb 18 01:36:04 2010 -0500
+++ b/src/load-path.cc	Thu Feb 18 08:40:17 2010 +0100
@@ -1617,6 +1617,24 @@
 #endif
 }
 
+// True if a path is contained in a path list separated by path_sep_char
+static bool
+in_path_list (const std::string& path_list, const std::string& path)
+{
+  size_t ps = path.size (), pls = path_list.size (), pos = path_list.find (path);
+  char psc = dir_path::path_sep_char ();
+  while (pos != std::string::npos)
+    {
+      if ((pos == 0 || path_list[pos-1] == psc)
+          && (pos + ps == pls || path_list[pos + ps] == psc))
+        return true;
+      else
+        pos = path_list.find (path, pos + 1);
+    }
+
+  return false;
+}
+
 void
 load_path::add_to_fcn_map (const dir_info& di, bool at_end) const
 {
@@ -1674,6 +1692,7 @@
                 {
                   file_info& old = file_info_list.front ();
                   if (sys_path.find (old.dir_name) != std::string::npos)
+                  if (in_path_list (sys_path, old.dir_name))
                     {
                       std::string fcn_path = file_ops::concat (dir_name, fname);
                       warning_with_id ("Octave:shadowed-function",