diff options
author | Brad King <brad.king@kitware.com> | 2016-07-20 13:03:42 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2016-07-20 13:03:42 (GMT) |
commit | df14a98e9c4af316cd5e75d6af8cc7b75da2db8f (patch) | |
tree | e64cd24565f089535e716189852b471536c0b7bf | |
parent | 6a98785d8f76d78447716fa90f93a36060288b8f (diff) | |
parent | 788bb146643030ebed27db297af83fe15b1f5447 (diff) | |
download | CMake-df14a98e9c4af316cd5e75d6af8cc7b75da2db8f.zip CMake-df14a98e9c4af316cd5e75d6af8cc7b75da2db8f.tar.gz CMake-df14a98e9c4af316cd5e75d6af8cc7b75da2db8f.tar.bz2 |
Merge topic 'update-kwsys'
788bb146 Merge branch 'upstream-KWSys' into update-kwsys
eb7b5087 KWSys 2016-07-18 (19732229)
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 38 | ||||
-rw-r--r-- | Source/kwsys/testSystemTools.cxx | 9 |
2 files changed, 19 insertions, 28 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index f8ea884..0526372 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -490,14 +490,12 @@ void SystemTools::GetPath(std::vector<std::string>& path, const char* env) { env = "PATH"; } - const char* cpathEnv = SystemTools::GetEnv(env); - if ( !cpathEnv ) + std::string pathEnv; + if ( !SystemTools::GetEnv(env, pathEnv) ) { return; } - std::string pathEnv = cpathEnv; - // A hack to make the below algorithm work. if(!pathEnv.empty() && *pathEnv.rbegin() != pathSep) { @@ -2132,8 +2130,8 @@ void SystemTools::ConvertToUnixSlashes(std::string& path) pathCString = path.c_str(); if(pathCString[0] == '~' && (pathCString[1] == '/' || pathCString[1] == '\0')) { - const char* homeEnv = SystemTools::GetEnv("HOME"); - if (homeEnv) + std::string homeEnv; + if (SystemTools::GetEnv("HOME", homeEnv)) { path.replace(0,1,homeEnv); } @@ -4149,16 +4147,9 @@ void SystemTools::SplitPath(const std::string& p, if(root.size() == 1) { #if defined(_WIN32) && !defined(__CYGWIN__) - if(const char* userp = getenv("USERPROFILE")) - { - homedir = userp; - } - else + if (!SystemTools::GetEnv("USERPROFILE", homedir)) #endif - if(const char* h = getenv("HOME")) - { - homedir = h; - } + SystemTools::GetEnv("HOME", homedir); } #ifdef HAVE_GETPWNAM else if(passwd* pw = getpwnam(root.c_str()+1)) @@ -4899,7 +4890,7 @@ int SystemTools::GetTerminalWidth() int width = -1; #ifdef HAVE_TTY_INFO struct winsize ws; - char *columns; /* Unix98 environment variable */ + std::string columns; /* Unix98 environment variable */ if(ioctl(1, TIOCGWINSZ, &ws) != -1 && ws.ws_col>0 && ws.ws_row>0) { width = ws.ws_col; @@ -4908,12 +4899,11 @@ int SystemTools::GetTerminalWidth() { width = -1; } - columns = getenv("COLUMNS"); - if(columns && *columns) + if(SystemTools::GetEnv("COLUMNS", columns) && !columns.empty()) { long t; char *endptr; - t = strtol(columns, &endptr, 0); + t = strtol(columns.c_str(), &endptr, 0); if(endptr && !*endptr && (t>0) && (t<1000)) { width = static_cast<int>(t); @@ -5525,7 +5515,8 @@ void SystemTools::ClassInitialize() // If the current working directory is a logical path then keep the // logical name. - if(const char* pwd = getenv("PWD")) + std::string pwd_str; + if(SystemTools::GetEnv("PWD", pwd_str)) { char buf[2048]; if(const char* cwd = Getcwd(buf, 2048)) @@ -5537,10 +5528,9 @@ void SystemTools::ClassInitialize() std::string pwd_changed; // Test progressively shorter logical-to-physical mappings. - std::string pwd_str = pwd; std::string cwd_str = cwd; std::string pwd_path; - Realpath(pwd, pwd_path); + Realpath(pwd_str.c_str(), pwd_path); while(cwd_str == pwd_path && cwd_str != pwd_str) { // The current pair of paths is a working logical mapping. @@ -5596,8 +5586,8 @@ static int SystemToolsDebugReport(int, char* message, int*) void SystemTools::EnableMSVCDebugHook() { - if (getenv("DART_TEST_FROM_DART") || - getenv("DASHBOARD_TEST_FROM_CTEST")) + if (SystemTools::HasEnv("DART_TEST_FROM_DART") || + SystemTools::HasEnv("DASHBOARD_TEST_FROM_CTEST")) { _CrtSetReportHook(SystemToolsDebugReport); } diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx index 4d97688..4dab347 100644 --- a/Source/kwsys/testSystemTools.cxx +++ b/Source/kwsys/testSystemTools.cxx @@ -848,9 +848,9 @@ static bool CheckPutEnv(const std::string& env, const char* name, const char* va << "\") failed!" << std::endl; return false; } - const char* v = kwsys::SystemTools::GetEnv(name); - v = v? v : "(null)"; - if(strcmp(v, value) != 0) + std::string v = "(null)"; + kwsys::SystemTools::GetEnv(name, v); + if(v != value) { std::cerr << "GetEnv(\"" << name << "\") returned \"" << v << "\", not \"" << value << "\"!" << std::endl; @@ -867,7 +867,8 @@ static bool CheckUnPutEnv(const char* env, const char* name) << std::endl; return false; } - if(const char* v = kwsys::SystemTools::GetEnv(name)) + std::string v; + if(kwsys::SystemTools::GetEnv(name, v)) { std::cerr << "GetEnv(\"" << name << "\") returned \"" << v << "\", not (null)!" << std::endl; |