Mercurial > hg > octave-nkf
changeset 8704:236ff50db90f
load-path.cc: catch execution exception in getcwd
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 09 Feb 2009 13:23:09 -0500 |
parents | c953a6977be6 |
children | ccdab7f029a3 |
files | src/ChangeLog src/load-path.cc src/toplev.cc |
diffstat | 3 files changed, 53 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ 2009-02-09 John W. Eaton <jwe@octave.org> + * load-path.cc (dir_info::update, dir_info::initialize): + Likewise, to allow some functionality if getcwd fails. + + * toplev.cc (main_loop): Also catch octave_execution_exception. + * DLD-FUNCTIONS/dispatch.cc: Comment out troublesome tests. * DLD-FUNCTIONS/eigs.cc: Increase tolerance to 1e-11 on all tests.
--- a/src/load-path.cc +++ b/src/load-path.cc @@ -58,28 +58,38 @@ { if (is_relative) { - std::string abs_name - = octave_env::make_absolute (dir_name, octave_env::getcwd ()); - - abs_dir_cache_iterator p = abs_dir_cache.find (abs_name); - - if (p != abs_dir_cache.end ()) + try { - // 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. + std::string abs_name + = octave_env::make_absolute (dir_name, octave_env::getcwd ()); + + abs_dir_cache_iterator p = abs_dir_cache.find (abs_name); + + 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. - const dir_info& di = p->second; + const dir_info& di = p->second; + + if (fs.mtime () != di.dir_mtime) + initialize (); + else + *this = di; - if (fs.mtime () != di.dir_mtime) - initialize (); - else - *this = di; + return; + } + } + catch (octave_execution_exception) + { + // Skip updating if we don't know where we are, but + // don't treat it as an error. - return; + error_state = 0; } } @@ -106,14 +116,21 @@ get_file_list (dir_name); - std::string abs_name - = octave_env::make_absolute (dir_name, octave_env::getcwd ()); + try + { + std::string abs_name + = octave_env::make_absolute (dir_name, octave_env::getcwd ()); - // FIXME -- nothing is ever removed from this cache of directory - // information, so there could be some resource problems. - // Perhaps it should be pruned from time to time. + // FIXME -- nothing is ever removed from this cache of + // directory information, so there could be some resource + // problems. Perhaps it should be pruned from time to time. - abs_dir_cache[abs_name] = *this; + abs_dir_cache[abs_name] = *this; + } + catch (octave_execution_exception) + { + // Skip updating if we don't know where we are. + } } else {
--- a/src/toplev.cc +++ b/src/toplev.cc @@ -605,6 +605,13 @@ recover_from_exception (); octave_stdout << "\n"; } + catch (octave_execution_exception) + { + recover_from_exception (); + std::cerr + << "error: unhandled execution exception -- trying to return to prompt" + << std::endl; + } catch (std::bad_alloc) { recover_from_exception ();