Mercurial > hg > octave-terminal
changeset 4395:cc6d369355ec
[project @ 2003-04-28 18:14:56 by jwe]
author | jwe |
---|---|
date | Mon, 28 Apr 2003 18:14:56 +0000 |
parents | 13619163e159 |
children | 452698dd6ed9 |
files | liboctave/kpse.cc liboctave/pathsearch.cc |
diffstat | 2 files changed, 14 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/kpse.cc +++ b/liboctave/kpse.cc @@ -1303,9 +1303,8 @@ } int len = ret.length (); - if (len > 0) - ret.resize (len - 1); + ret.resize (len-1); return ret; } @@ -1372,11 +1371,9 @@ ret += expansion + ENV_SEP_STRING; } - /* Waste the last byte by overwriting the trailing env_sep with a null. */ size_t len = ret.length (); - if (len > 0) - ret.resize (len - 1); + ret.resize (len-1); return kpse_expand_kpse_dot (ret); } @@ -1439,28 +1436,25 @@ const std::string thedir = STR_LLIST (*dir); unsigned dirlen = thedir.length (); + ret += thedir; + len += dirlen; + /* Retain trailing slash if that's the root directory. */ if (dirlen == 1 || (dirlen == 3 && NAME_BEGINS_WITH_DEVICE (thedir) && IS_DIR_SEP (thedir[2]))) { - ret += thedir + ENV_SEP_STRING; - len += dirlen + 1; - ret[len - 1] = ENV_SEP; + ret += ENV_SEP_STRING; + len++; } - else - { - ret += thedir; - len += dirlen; - ret [len - 1] = ENV_SEP; - } + + ret[len-1] = ENV_SEP; } } } - /* Get rid of trailing ':', if any. */ - if (len != 0) - ret[len - 1] = 0; + if (len > 0) + ret.resize (len-1); return ret; }
--- a/liboctave/pathsearch.cc +++ b/liboctave/pathsearch.cc @@ -128,14 +128,8 @@ octave_kpathsea_initialized = true; } - if (p_default.empty ()) - p = kpse_path_expand (p_orig); - else - { - std::string s = kpse_expand_default (p_orig, p_default); - - p = kpse_path_expand (s); - } + p = kpse_path_expand (p_default.empty () + ? p_orig : kpse_expand_default (p_orig, p_default)); int count = 0; for (kpse_path_iterator pi (p); pi != NPOS; pi++) @@ -146,10 +140,7 @@ kpse_path_iterator pi (p); for (int i = 0; i < count; i++) - { - pv[i] = *pi++; - std::cerr << pv[i] << std::endl; - } + pv[i] = *pi++; initialized = true; }