# HG changeset patch # User John W. Eaton # Date 1239247085 14400 # Node ID 9b12ed1fbbbd4387e24b2fa69b275654095127d6 # Parent e0250e2b60ed4af469e0f4a11158dd9cc1230336 force rehash if path, addpath, or rmpath modify path diff -r e0250e2b60ed -r 9b12ed1fbbbd src/ChangeLog --- a/src/ChangeLog Wed Apr 08 13:16:23 2009 +0200 +++ b/src/ChangeLog Wed Apr 08 23:18:05 2009 -0400 @@ -1,3 +1,9 @@ +2009-04-08 John W. Eaton + + * load-path.cc (rehash_internal): New function. + (Frehash): Use it. + (Fpath, Faddpath, Frmpath): Call rehash_internal if path is modified. + 2009-04-08 Jaroslav Hajek * xpow.cc (elem_xpow (double, const Range&), diff -r e0250e2b60ed -r 9b12ed1fbbbd src/load-path.cc --- a/src/load-path.cc Wed Apr 08 13:16:23 2009 +0200 +++ b/src/load-path.cc Wed Apr 08 23:18:05 2009 -0400 @@ -1817,6 +1817,18 @@ return retval; } +static void +rehash_internal (void) +{ + load_path::update (); + + // FIXME -- maybe we should rename this variable since it is being + // used for more than keeping track of the prompt time. + + // This will force updated functions to be found. + Vlast_prompt_time.stamp (); +} + DEFUN (rehash, , , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} rehash ()\n\ @@ -1825,13 +1837,7 @@ { octave_value_list retval; - load_path::update (); - - // FIXME -- maybe we should rename this variable since it is being - // used for more than keeping track of the prompt time. - - // This will force updated functions to be found. - Vlast_prompt_time.stamp (); + rehash_internal (); return retval; } @@ -1909,6 +1915,8 @@ path += dir_path::path_sep_str () + argv[i]; load_path::set (path, true); + + rehash_internal (); } if (nargout > 0) @@ -1991,6 +1999,8 @@ } } + bool need_to_update = false; + for (int i = 0; i < nargin; i++) { std::string arg = args(i).string_value (); @@ -2012,11 +2022,16 @@ load_path::append (dir, true); else load_path::prepend (dir, true); + + need_to_update = true; } } else error ("addpath: expecting all args to be character strings"); } + + if (need_to_update) + rehash_internal (); } else print_usage (); @@ -2044,6 +2059,8 @@ if (nargin > 0) { + bool need_to_update = false; + for (int i = 0; i < nargin; i++) { std::string arg = args(i).string_value (); @@ -2063,11 +2080,16 @@ if (! load_path::remove (dir)) warning ("rmpath: %s: not found", dir.c_str ()); + else + need_to_update = true; } } else error ("addpath: expecting all args to be character strings"); } + + if (need_to_update) + rehash_internal (); } else print_usage ();