From b89fcfb54a198c2b749302da29b49ef088067feb Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sun, 17 Aug 2008 05:18:25 -0400 Subject: [PATCH] Re-enabled the disabled expand_path routine. --- src/utils.cc | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/utils.cc b/src/utils.cc index 5ac5cef0..2f563dde 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -656,13 +656,11 @@ path expand_path(const path& pathname) if (pathname.empty()) return pathname; -#if 0 - // jww (2007-04-30): I need to port this code to use - // boost::filesystem::path + std::string path_string = pathname.string(); const char * pfx = NULL; - string::size_type pos = pathname.find_first_of('/'); + string::size_type pos = path_string.find_first_of('/'); - if (pathname.length() == 1 || pos == 1) { + if (path_string.length() == 1 || pos == 1) { pfx = std::getenv("HOME"); #ifdef HAVE_GETPWUID if (! pfx) { @@ -675,8 +673,8 @@ path expand_path(const path& pathname) } #ifdef HAVE_GETPWNAM else { - string user(pathname, 1, pos == string::npos ? - string::npos : pos - 1); + string user(path_string, 1, pos == string::npos ? + string::npos : pos - 1); struct passwd * pw = getpwnam(user.c_str()); if (pw) pfx = pw->pw_dir; @@ -696,12 +694,9 @@ path expand_path(const path& pathname) if (result.length() == 0 || result[result.length() - 1] != '/') result += '/'; - result += pathname.substr(pos + 1); + result += path_string.substr(pos + 1); return result; -#else - return pathname; -#endif } path resolve_path(const path& pathname)