Mercurial > hg > octave-lyh
diff src/utils.cc @ 1787:ebc1a0b2e854
[project @ 1996-01-24 20:37:52 by jwe]
author | jwe |
---|---|
date | Wed, 24 Jan 1996 20:38:43 +0000 |
parents | e090f89bf2f5 |
children | 4603d7ee0258 |
line wrap: on
line diff
--- a/src/utils.cc +++ b/src/utils.cc @@ -370,43 +370,34 @@ get_fcn_file_names (int& num, int no_suffix) { static int num_max = 1024; + string_vector retval (num_max); - int i = 0; - char *path_elt = kpse_path_element (user_pref.loadpath.c_str ()); + dir_path p (user_pref.loadpath); - while (path_elt) - { - str_llist_type *elt_dirs = kpse_element_dirs (path_elt); + string_vector dirs = p.all_directories (); - str_llist_elt_type *dir; - for (dir = *elt_dirs; dir; dir = STR_LLIST_NEXT (*dir)) - { - char *elt_dir = STR_LLIST (*dir); + int len = dirs.length (); + + int k = 0; - if (elt_dir) - { - string_vector names = get_fcn_file_names (elt_dir, no_suffix); - - int tmp_num = names.length (); + for (int i = 0; i < len; i++) + { + string_vector names = get_fcn_file_names (dirs[i], no_suffix); - if (i + tmp_num > num_max) - { - num_max += tmp_num; - retval.resize (num_max); - } + int tmp_num = names.length (); - int k = 0; - while (k < tmp_num) - retval[i++] = names[k++]; - } + if (k + tmp_num > num_max) + { + num_max += tmp_num; + retval.resize (num_max); } - path_elt = kpse_path_element (0); + for (int j = 0; j < tmp_num; j++) + retval[k++] = names[j++]; } - num = i; - retval.resize (num); + retval.resize (k); return retval; } @@ -567,18 +558,9 @@ string search_path_for_file (const string& path, const string& name) { - string retval; - - char *tmp = kpse_path_search (path.c_str (), name.c_str (), - kpathsea_true); + dir_path p (path); - if (tmp) - { - retval = make_absolute (tmp, the_current_working_directory); - free (tmp); - } - - return retval; + return make_absolute (p.find (name), the_current_working_directory); } DEFUN ("file_in_path", Ffile_in_path, Sfile_in_path, 10,