Mercurial > octave
changeset 22542:e0a1e8803d8c
Don't replace relative directory names in PATH with absolute names (bug #49184).
* load-path.cc (load_path::dir_info::update): Move warning code to top
of function. If information for a relative path name is found in the
cache which is indexed by absolute path name, then only copy over
informational fields from the cache, but do not copy over the absolute
path name which would replace the relative name stored in dir_name.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 27 Sep 2016 12:38:57 -0700 |
parents | 4b7ab10b5c38 |
children | b9f5ac691e03 |
files | libinterp/corefcn/load-path.cc |
diffstat | 1 files changed, 26 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/load-path.cc Tue Sep 27 17:56:34 2016 +0200 +++ b/libinterp/corefcn/load-path.cc Tue Sep 27 12:38:57 2016 -0700 @@ -57,7 +57,12 @@ { octave::sys::file_stat fs (dir_name); - if (fs) + if (! fs) + { + std::string msg = fs.error (); + warning ("load_path: %s: %s", dir_name.c_str (), msg.c_str ()); + } + else { if (is_relative) { @@ -69,44 +74,47 @@ if (p != abs_dir_cache.end ()) { - // The directory is in the cache of all directories - // we have visited (indexed by its absolute name). - // If it is out of date, initialize it. Otherwise, - // copy the info from the cache. By doing that, we - // avoid unnecessary calls to stat that can slow - // things down tremendously for large directories. - + // The directory is in the cache of all directories we have + // visited (indexed by absolute name). If it is out of date, + // initialize it. Otherwise, copy the info from the cache. + // By doing that, we avoid unnecessary calls to stat that can + // slow things down tremendously for large directories. const dir_info& di = p->second; if (fs.mtime () + fs.time_resolution () > di.dir_time_last_checked) initialize (); else - *this = di; + { + // Copy over info from cache, but leave dir_name and + // is_relative unmodified. + this->abs_dir_name = di.abs_dir_name; + this->dir_mtime = di.dir_mtime; + this->dir_time_last_checked = di.dir_time_last_checked; + this->all_files = di.all_files; + this->fcn_files = di.fcn_files; + this->private_file_map = di.private_file_map; + this->method_file_map = di.method_file_map; + this->package_dir_map = di.package_dir_map; + } } else { // We haven't seen this directory before. - initialize (); } } catch (const octave::execution_exception&) { - // Skip updating if we don't know where we are but - // don't treat it as an error. - + // Skip updating if we don't know where we are, + // but don't treat it as an error. recover_from_exception (); } } + // Absolute path, check timestamp to see whether it requires re-caching else if (fs.mtime () + fs.time_resolution () > dir_time_last_checked) initialize (); } - else - { - std::string msg = fs.error (); - warning ("load_path: %s: %s", dir_name.c_str (), msg.c_str ()); - } } bool