Mercurial > hg > octave-nkf
changeset 1787:ebc1a0b2e854
[project @ 1996-01-24 20:37:52 by jwe]
author | jwe |
---|---|
date | Wed, 24 Jan 1996 20:38:43 +0000 |
parents | b9e8c73e154e |
children | b7de2fd2be6b |
files | src/help.cc src/utils.cc |
diffstat | 2 files changed, 31 insertions(+), 56 deletions(-) [+] |
line wrap: on
line diff
--- a/src/help.cc +++ b/src/help.cc @@ -481,31 +481,24 @@ // Also need to search octave_path for script files. - 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 (); - if (elt_dir) - { - string_vector names = get_fcn_file_names (elt_dir); + for (int i = 0; i < len; i++) + { + string_vector names = get_fcn_file_names (dirs[i]); - output_buf << "\n*** function files in " - << make_absolute (elt_dir, the_current_working_directory) - << ":\n\n"; + if (! names.empty ()) + { + output_buf << "\n*** function files in " + << make_absolute (dirs[i], the_current_working_directory) + << ":\n\n"; - if (names.length () > 0) - list_in_columns (output_buf, names); - } + list_in_columns (output_buf, names); } - - path_elt = kpse_path_element (0); } additional_help_message (output_buf);
--- 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,