# HG changeset patch # User John W. Eaton # Date 1243353600 14400 # Node ID 95445f9f5976fe243d88df0372165a41828ab9db # Parent 9c2349a51218d876cf6b6c2866a6c12c49bfe42e omit file extensions from __list_functions__ output diff -r 9c2349a51218 -r 95445f9f5976 src/ChangeLog --- a/src/ChangeLog Tue May 26 11:20:40 2009 -0400 +++ b/src/ChangeLog Tue May 26 12:00:00 2009 -0400 @@ -1,5 +1,10 @@ 2009-05-26 John W. Eaton + * load-path.h, load-path.cc (load_path::files, load_path::do_files): + New arg, OMIT_EXTS. + * help.cc (F__list_functions__): Call load_path::files with + omit_exts set to true. + * symtab.h (symbol_table::symbol_record::symbol_record_rep::is_variable): Use "! is_local ()" instead of storage_class != local. diff -r 9c2349a51218 -r 95445f9f5976 src/help.cc --- a/src/help.cc Tue May 26 11:20:40 2009 -0400 +++ b/src/help.cc Tue May 26 12:00:00 2009 -0400 @@ -957,10 +957,17 @@ if (! error_state) { - string_vector fl = load_path::files (dir); + string_vector fl = load_path::files (dir, true); if (! error_state) - retval = Cell (fl); + { + // Return a sorted list with unique entries (in case of + // .m and .oct versions of the same function in a given + // directory, for example). + fl.sort (true); + + retval = Cell (fl); + } } else error ("__list_functions__: input must be a string"); diff -r 9c2349a51218 -r 95445f9f5976 src/load-path.cc --- a/src/load-path.cc Tue May 26 11:20:40 2009 -0400 +++ b/src/load-path.cc Tue May 26 12:00:00 2009 -0400 @@ -1337,7 +1337,7 @@ } string_vector -load_path::do_files (const std::string& dir) const +load_path::do_files (const std::string& dir, bool omit_exts) const { string_vector retval; @@ -1346,6 +1346,21 @@ if (i != dir_info_list.end ()) retval = i->fcn_files; + if (omit_exts) + { + octave_idx_type len = retval.length (); + + for (octave_idx_type i = 0; i < len; i++) + { + std::string fname = retval[i]; + + size_t pos = fname.rfind ('.'); + + if (pos != std::string::npos) + retval[i] = fname.substr (0, pos); + } + } + return retval; } diff -r 9c2349a51218 -r 95445f9f5976 src/load-path.h --- a/src/load-path.h Tue May 26 11:20:40 2009 -0400 +++ b/src/load-path.h Tue May 26 12:00:00 2009 -0400 @@ -186,9 +186,10 @@ ? instance->do_dir_list () : std::list (); } - static string_vector files (const std::string& dir) + static string_vector files (const std::string& dir, bool omit_exts = false) { - return instance_ok () ? instance->do_files (dir) : string_vector (); + return instance_ok () + ? instance->do_files (dir, omit_exts) : string_vector (); } static string_vector fcn_names (void) @@ -490,7 +491,7 @@ std::list do_dir_list (void) const; - string_vector do_files (const std::string& dir) const; + string_vector do_files (const std::string& dir, bool omit_exts) const; string_vector do_fcn_names (void) const;