Mercurial > jwe > octave
comparison libinterp/corefcn/load-path.cc @ 30152:4f039927308b
maint: use "s_" prefix for static variables in class load_path.
* load-path.cc, load-path.h: Use "s_" prefix for static variables in class
load_path.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 09 Sep 2021 20:07:29 -0700 |
parents | 1955fc6e2128 |
children | 8f61866f0f6d |
comparison
equal
deleted
inserted
replaced
30151:1955fc6e2128 | 30152:4f039927308b |
---|---|
223 | 223 |
224 // This will force updated functions to be found. | 224 // This will force updated functions to be found. |
225 Vlast_prompt_time.stamp (); | 225 Vlast_prompt_time.stamp (); |
226 } | 226 } |
227 | 227 |
228 std::string load_path::sys_path; | 228 std::string load_path::s_sys_path; |
229 load_path::abs_dir_cache_type load_path::abs_dir_cache; | 229 load_path::abs_dir_cache_type load_path::s_abs_dir_cache; |
230 | 230 |
231 load_path::load_path (interpreter& interp) | 231 load_path::load_path (interpreter& interp) |
232 : add_hook ([=] (const std::string& dir) { this->execute_pkg_add (dir); }), | 232 : add_hook ([=] (const std::string& dir) { this->execute_pkg_add (dir); }), |
233 remove_hook ([=] (const std::string& dir) { this->execute_pkg_del (dir); }), | 233 remove_hook ([=] (const std::string& dir) { this->execute_pkg_del (dir); }), |
234 m_interpreter (interp), m_package_map (), m_top_level_package (), | 234 m_interpreter (interp), m_package_map (), m_top_level_package (), |
236 { } | 236 { } |
237 | 237 |
238 void | 238 void |
239 load_path::initialize (bool set_initial_path) | 239 load_path::initialize (bool set_initial_path) |
240 { | 240 { |
241 sys_path = ""; | 241 s_sys_path = ""; |
242 | 242 |
243 if (set_initial_path) | 243 if (set_initial_path) |
244 { | 244 { |
245 maybe_add_path_elts (sys_path, config::local_ver_oct_file_dir ()); | 245 maybe_add_path_elts (s_sys_path, config::local_ver_oct_file_dir ()); |
246 maybe_add_path_elts (sys_path, config::local_api_oct_file_dir ()); | 246 maybe_add_path_elts (s_sys_path, config::local_api_oct_file_dir ()); |
247 maybe_add_path_elts (sys_path, config::local_oct_file_dir ()); | 247 maybe_add_path_elts (s_sys_path, config::local_oct_file_dir ()); |
248 maybe_add_path_elts (sys_path, config::local_ver_fcn_file_dir ()); | 248 maybe_add_path_elts (s_sys_path, config::local_ver_fcn_file_dir ()); |
249 maybe_add_path_elts (sys_path, config::local_api_fcn_file_dir ()); | 249 maybe_add_path_elts (s_sys_path, config::local_api_fcn_file_dir ()); |
250 maybe_add_path_elts (sys_path, config::local_fcn_file_dir ()); | 250 maybe_add_path_elts (s_sys_path, config::local_fcn_file_dir ()); |
251 maybe_add_path_elts (sys_path, config::oct_file_dir ()); | 251 maybe_add_path_elts (s_sys_path, config::oct_file_dir ()); |
252 maybe_add_path_elts (sys_path, config::fcn_file_dir ()); | 252 maybe_add_path_elts (s_sys_path, config::fcn_file_dir ()); |
253 maybe_add_path_elts (sys_path, config::oct_data_dir ()); | 253 maybe_add_path_elts (s_sys_path, config::oct_data_dir ()); |
254 } | 254 } |
255 | 255 |
256 std::string tpath = load_path::m_command_line_path; | 256 std::string tpath = load_path::m_command_line_path; |
257 | 257 |
258 if (tpath.empty ()) | 258 if (tpath.empty ()) |
262 | 262 |
263 if (! tpath.empty ()) | 263 if (! tpath.empty ()) |
264 { | 264 { |
265 xpath = tpath; | 265 xpath = tpath; |
266 | 266 |
267 if (! sys_path.empty ()) | 267 if (! s_sys_path.empty ()) |
268 xpath += directory_path::path_sep_str () + sys_path; | 268 xpath += directory_path::path_sep_str () + s_sys_path; |
269 } | 269 } |
270 else | 270 else |
271 xpath = sys_path; | 271 xpath = s_sys_path; |
272 | 272 |
273 set (xpath, false, true); | 273 set (xpath, false, true); |
274 } | 274 } |
275 | 275 |
276 void | 276 void |
1347 { | 1347 { |
1348 try | 1348 try |
1349 { | 1349 { |
1350 std::string abs_name = sys::canonicalize_file_name (dir_name); | 1350 std::string abs_name = sys::canonicalize_file_name (dir_name); |
1351 | 1351 |
1352 const_abs_dir_cache_iterator p = abs_dir_cache.find (abs_name); | 1352 const_abs_dir_cache_iterator p = s_abs_dir_cache.find (abs_name); |
1353 | 1353 |
1354 if (p != abs_dir_cache.end ()) | 1354 if (p != s_abs_dir_cache.end ()) |
1355 { | 1355 { |
1356 // The directory is in the cache of all directories we have | 1356 // The directory is in the cache of all directories we have |
1357 // visited (indexed by absolute name). If it is out of date, | 1357 // visited (indexed by absolute name). If it is out of date, |
1358 // initialize it. Otherwise, copy the info from the cache. | 1358 // initialize it. Otherwise, copy the info from the cache. |
1359 // By doing that, we avoid unnecessary calls to stat that can | 1359 // By doing that, we avoid unnecessary calls to stat that can |
1453 | 1453 |
1454 // FIXME: nothing is ever removed from this cache of | 1454 // FIXME: nothing is ever removed from this cache of |
1455 // directory information, so there could be some resource | 1455 // directory information, so there could be some resource |
1456 // problems. Perhaps it should be pruned from time to time. | 1456 // problems. Perhaps it should be pruned from time to time. |
1457 | 1457 |
1458 abs_dir_cache[abs_dir_name] = *this; | 1458 s_abs_dir_cache[abs_dir_name] = *this; |
1459 } | 1459 } |
1460 catch (const execution_exception&) | 1460 catch (const execution_exception&) |
1461 { | 1461 { |
1462 // Skip updating if we don't know where we are but don't treat | 1462 // Skip updating if we don't know where we are but don't treat |
1463 // it as an error. | 1463 // it as an error. |
1933 | 1933 |
1934 // Don't warn about Contents.m files since we expect | 1934 // Don't warn about Contents.m files since we expect |
1935 // more than one to exist in the load path. | 1935 // more than one to exist in the load path. |
1936 | 1936 |
1937 if (fname != "Contents.m" | 1937 if (fname != "Contents.m" |
1938 && sys_path.find (old.dir_name) != std::string::npos | 1938 && s_sys_path.find (old.dir_name) != std::string::npos |
1939 && in_path_list (sys_path, old.dir_name)) | 1939 && in_path_list (s_sys_path, old.dir_name)) |
1940 { | 1940 { |
1941 std::string fcn_path = sys::file_ops::concat (dir_name, fname); | 1941 std::string fcn_path = sys::file_ops::concat (dir_name, fname); |
1942 | 1942 |
1943 warning_with_id ("Octave:shadowed-function", | 1943 warning_with_id ("Octave:shadowed-function", |
1944 "function %s shadows a core library function", | 1944 "function %s shadows a core library function", |