# HG changeset patch # User John W. Eaton # Date 1405550335 14400 # Node ID cc8aaf9c9e331261533b4ae6845bdac45a517de4 # Parent 87324260043d908668824326bc97eb9598931630 exist: don't search path for absolute or rooted relative file names * load-path.cc (load_path::do_find_file): If file name is absolute or rooted relative simply check for existence of file. * variables.cc: New tests. diff -r 87324260043d -r cc8aaf9c9e33 libinterp/corefcn/load-path.cc --- a/libinterp/corefcn/load-path.cc Tue Jul 15 22:18:35 2014 +0200 +++ b/libinterp/corefcn/load-path.cc Wed Jul 16 18:38:55 2014 -0400 @@ -1300,8 +1300,7 @@ { file_stat fs (file); - if (fs.exists ()) - return file; + return fs.exists () ? file : retval; } else { diff -r 87324260043d -r cc8aaf9c9e33 libinterp/corefcn/variables.cc --- a/libinterp/corefcn/variables.cc Tue Jul 15 22:18:35 2014 +0200 +++ b/libinterp/corefcn/variables.cc Wed Jul 16 18:38:55 2014 -0400 @@ -663,6 +663,16 @@ %!error exist ("a", 1) %!error exist (1) +%!test +%! flist = dir (); +%! fname = flist(3).name; ## skip . and .. +%! assert (exist (fullfile (pwd (), fname), "file"), 2) +%! assert (exist (fullfile (pwd (), "nonexistentfile"), "file"), 0) + +%!assert (exist ("plot.m", "file"), 2); +%!assert (exist ("./plot.m", "file"), 0); +%!assert (exist ("./nonexistentfile", "file"), 0); +%!assert (exist ("nonexistentfile", "file"), 0); */ octave_value