# HG changeset patch # User John W. Eaton # Date 1287379168 14400 # Node ID a6ab46b5926fdd90be9027710fb5aa03dfae8f5d # Parent 2c356a35d7f5824f506ab9a74d5b99242d8cb041 load_path::do_find{all,}first_of: search path for relative file names diff -r 2c356a35d7f5 -r a6ab46b5926f src/ChangeLog --- a/src/ChangeLog Sun Oct 17 23:43:42 2010 -0400 +++ b/src/ChangeLog Mon Oct 18 01:19:28 2010 -0400 @@ -1,3 +1,9 @@ +2010-10-18 John W. Eaton + + * load-path.cc (load_path::do_find_first_of, + load_path::do_find_all_first_of): Also search path for relative + filenames. + 2010-10-17 John W. Eaton * DLD-FUNCTIONS/tril.cc: Use Octave copyright notice instead of diff -r 2c356a35d7f5 -r a6ab46b5926f src/load-path.cc --- a/src/load-path.cc Sun Oct 17 23:43:42 2010 -0400 +++ b/src/load-path.cc Mon Oct 18 01:19:28 2010 -0400 @@ -1257,15 +1257,35 @@ for (octave_idx_type i = 0; i < flen; i++) { - if (octave_env::absolute_pathname (flist[i])) + std::string file = flist[i]; + + if (file.find_first_of (file_ops::dir_sep_chars ()) != std::string::npos) { - file_stat fs (flist[i]); - - if (fs.exists ()) - return flist[i]; + if (octave_env::absolute_pathname (file) + || octave_env::rooted_relative_pathname (file)) + { + file_stat fs (file); + + if (fs.exists ()) + return file; + } + else + { + for (const_dir_info_list_iterator p = dir_info_list.begin (); + p != dir_info_list.end (); + p++) + { + std::string tfile = file_ops::concat (p->dir_name, file); + + file_stat fs (tfile); + + if (fs.exists ()) + return tfile; + } + } } else - rel_flist[rel_flen++] = flist[i]; + rel_flist[rel_flen++] = file; } rel_flist.resize (rel_flen); @@ -1316,15 +1336,35 @@ for (octave_idx_type i = 0; i < flen; i++) { - if (octave_env::absolute_pathname (flist[i])) + std::string file = flist[i]; + + if (file.find_first_of (file_ops::dir_sep_chars ()) != std::string::npos) { - file_stat fs (flist[i]); - - if (fs.exists ()) - retlist.push_back (flist[i]); + if (octave_env::absolute_pathname (file) + || octave_env::rooted_relative_pathname (file)) + { + file_stat fs (file); + + if (fs.exists ()) + retlist.push_back (file); + } + else + { + for (const_dir_info_list_iterator p = dir_info_list.begin (); + p != dir_info_list.end (); + p++) + { + std::string tfile = file_ops::concat (p->dir_name, file); + + file_stat fs (tfile); + + if (fs.exists ()) + retlist.push_back (tfile); + } + } } else - rel_flist[rel_flen++] = flist[i]; + rel_flist[rel_flen++] = file; } rel_flist.resize (rel_flen);