Mercurial > hg > octave-shane
changeset 11578:06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 20 Jan 2011 03:24:14 -0500 |
parents | b124b83e5626 |
children | 5c680b69b4e2 |
files | src/ChangeLog src/load-path.cc |
diffstat | 2 files changed, 26 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2011-01-20 John W. Eaton <jwe@octave.org> + + * load-path.cc (strip_trailing_separators): New static function. + (load_path::do_add, load_path::do_remove): Call it on directory arg. + 2011-01-20 John W. Eaton <jwe@octave.org> * gl-render.h, graphics.cc, gl-render.cc, graphics.h.in:
--- a/src/load-path.cc +++ b/src/load-path.cc @@ -606,6 +606,23 @@ do_add (dir, false, warn); } +// Strip trailing directory separators. + +static std::string +strip_trailing_separators (const std::string& dir_arg) +{ + std::string dir = dir_arg; + + octave_idx_type k = dir.length (); + while (k > 1 && file_ops::is_dir_sep (dir[k-1])) + k--; + + if (k < dir.length ()) + dir.resize (k); + + return dir; +} + void load_path::do_add (const std::string& dir_arg, bool at_end, bool warn) { @@ -617,6 +634,8 @@ std::string dir = file_ops::tilde_expand (dir_arg); + dir = strip_trailing_separators (dir); + dir_info_list_iterator i = find_dir_info (dir); if (i != dir_info_list.end ()) @@ -774,6 +793,8 @@ { std::string dir = file_ops::tilde_expand (dir_arg); + dir = strip_trailing_separators (dir); + dir_info_list_iterator i = find_dir_info (dir); if (i != dir_info_list.end ())