[cmake-developers] [PATCH v4 3/4] Use SystemTools::GetEnv and HasEnv functions

2016-07-07 Thread Dāvis Mosāns
---
 Source/CPack/cmCPackGenerator.cxx   |  8 +++---
 Source/CTest/cmCTestCoverageHandler.cxx | 12 -
 Source/CTest/cmCTestCurl.cxx| 27 ++--
 Source/CTest/cmCTestMultiProcessHandler.cxx |  8 +++---
 Source/cmBuildCommand.cxx   | 25 +--
 Source/cmCLocaleEnvironmentScope.cxx|  5 ++--
 Source/cmCTest.cxx  | 11 +
 Source/cmCommandArgumentParserHelper.cxx|  8 +++---
 Source/cmConditionEvaluator.cxx |  2 +-
 Source/cmExportCommand.cxx  |  5 ++--
 Source/cmExtraEclipseCDT4Generator.cxx  |  9 ---
 Source/cmFileCommand.cxx| 11 +
 Source/cmFindPackageCommand.cxx |  4 +--
 Source/cmGlobalVisualStudio7Generator.cxx   |  6 ++---
 Source/cmMakefile.cxx   |  5 +++-
 Source/cmNinjaTargetGenerator.cxx   |  2 +-
 Source/cmQtAutoGenerators.cxx   |  2 +-
 Source/cmSetCommand.cxx |  7 +++---
 Source/cmState.cxx  |  5 ++--
 Source/cmSystemTools.cxx|  6 ++---
 Source/cmTimestamp.cxx  |  7 +++---
 Source/cmUtils.hxx  | 26 
 Source/cmake.cxx| 21 +---
 Source/cmcmd.cxx| 16 +---
 Source/kwsys/SystemInformation.cxx  | 20 +++
 Source/kwsys/SystemTools.cxx| 38 +++--
 Source/kwsys/testSystemTools.cxx|  9 ---
 27 files changed, 156 insertions(+), 149 deletions(-)
 create mode 100644 Source/cmUtils.hxx

diff --git a/Source/CPack/cmCPackGenerator.cxx 
b/Source/CPack/cmCPackGenerator.cxx
index df8bb0f..76609e1 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -1074,11 +1074,11 @@ const char* cmCPackGenerator::GetInstallPath()
 return this->InstallPath.c_str();
   }
 #if defined(_WIN32) && !defined(__CYGWIN__)
-  const char* prgfiles = cmsys::SystemTools::GetEnv("ProgramFiles");
-  const char* sysDrive = cmsys::SystemTools::GetEnv("SystemDrive");
-  if (prgfiles) {
+  std::string prgfiles;
+  std::string sysDrive;
+  if (cmsys::SystemTools::GetEnv("ProgramFiles", prgfiles)) {
 this->InstallPath = prgfiles;
-  } else if (sysDrive) {
+  } else if (cmsys::SystemTools::GetEnv("SystemDrive", sysDrive)) {
 this->InstallPath = sysDrive;
 this->InstallPath += "/Program Files";
   } else {
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx 
b/Source/CTest/cmCTestCoverageHandler.cxx
index 7102533..9410a52 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -727,10 +727,7 @@ int cmCTestCoverageHandler::HandleCoberturaCoverage(
   // if it doesn't exist or is empty, assume the
   // binary directory is used.
   std::string coverageXMLFile;
-  const char* covDir = cmSystemTools::GetEnv("COBERTURADIR");
-  if (covDir && strlen(covDir) != 0) {
-coverageXMLFile = std::string(covDir);
-  } else {
+  if (!cmSystemTools::GetEnv("COBERTURADIR", coverageXMLFile) || 
coverageXMLFile.empty()) {
 coverageXMLFile = this->CTest->GetBinaryDir();
   }
   // build the find file string with the directory from above
@@ -791,7 +788,8 @@ struct cmCTestCoverageHandlerLocale
 {
   cmCTestCoverageHandlerLocale()
   {
-if (const char* l = cmSystemTools::GetEnv("LC_ALL")) {
+std::string l;
+if (cmSystemTools::GetEnv("LC_ALL", l)) {
   lc_all = l;
 }
 if (lc_all != "C") {
@@ -2121,8 +2119,8 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
 int cmCTestCoverageHandler::HandleBullseyeCoverage(
   cmCTestCoverageHandlerContainer* cont)
 {
-  const char* covfile = cmSystemTools::GetEnv("COVFILE");
-  if (!covfile || strlen(covfile) == 0) {
+  std::string covfile;
+  if (!cmSystemTools::GetEnv("COVFILE", covfile) || covfile.empty()) {
 cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
" COVFILE environment variable not found, not running "
" bullseye\n",
diff --git a/Source/CTest/cmCTestCurl.cxx b/Source/CTest/cmCTestCurl.cxx
index 6b8e5b5..b335e32 100644
--- a/Source/CTest/cmCTestCurl.cxx
+++ b/Source/CTest/cmCTestCurl.cxx
@@ -219,16 +219,18 @@ bool cmCTestCurl::HttpRequest(std::string const& url,
 
 void cmCTestCurl::SetProxyType()
 {
-  if (cmSystemTools::GetEnv("HTTP_PROXY")) {
-this->HTTPProxy = cmSystemTools::GetEnv("HTTP_PROXY");
-if (cmSystemTools::GetEnv("HTTP_PROXY_PORT")) {
+  this->HTTPProxy = "";
+  // this is the default
+  this->HTTPProxyType = CURLPROXY_HTTP;
+  this->HTTPProxyAuth = "";
+  if (cmSystemTools::GetEnv("HTTP_PROXY", this->HTTPProxy)) {
+std::string port;
+if (cmSystemTools::GetEnv("HTTP_PROXY_PORT", port)) {
   this->HTTPProxy += ":";
-  this->HTTPProxy += cmSystemTools::GetEnv("HTTP_PROXY_PORT");
+  this->HTTPPro

Re: [cmake-developers] [PATCH v4 3/4] Use SystemTools::GetEnv and HasEnv functions

2016-07-18 Thread Brad King
On 07/07/2016 05:54 PM, Dāvis Mosāns wrote:
>  Source/CPack/cmCPackGenerator.cxx   |  8 +++---
>  Source/CTest/cmCTestCoverageHandler.cxx | 12 -
>  Source/CTest/cmCTestCurl.cxx| 27 ++--
>  Source/CTest/cmCTestMultiProcessHandler.cxx |  8 +++---
>  Source/cmBuildCommand.cxx   | 25 +--
>  Source/cmCLocaleEnvironmentScope.cxx|  5 ++--
>  Source/cmCTest.cxx  | 11 +
>  Source/cmCommandArgumentParserHelper.cxx|  8 +++---
>  Source/cmConditionEvaluator.cxx |  2 +-
>  Source/cmExportCommand.cxx  |  5 ++--
>  Source/cmExtraEclipseCDT4Generator.cxx  |  9 ---
>  Source/cmFileCommand.cxx| 11 +
>  Source/cmFindPackageCommand.cxx |  4 +--
>  Source/cmGlobalVisualStudio7Generator.cxx   |  6 ++---
>  Source/cmMakefile.cxx   |  5 +++-
>  Source/cmNinjaTargetGenerator.cxx   |  2 +-
>  Source/cmQtAutoGenerators.cxx   |  2 +-
>  Source/cmSetCommand.cxx |  7 +++---
>  Source/cmState.cxx  |  5 ++--
>  Source/cmSystemTools.cxx|  6 ++---
>  Source/cmTimestamp.cxx  |  7 +++---
>  Source/cmUtils.hxx  | 26 
>  Source/cmake.cxx| 21 +---
>  Source/cmcmd.cxx| 16 +---

Applied:

 Use better KWSys SystemTools::GetEnv and HasEnv signatures
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b1f87a50

>  Source/kwsys/SystemInformation.cxx  | 20 +++

I dropped this one because it introduces a dependency
SystemInformation => SystemTools that was not there before
and I don't think we need this for the environment variables
it uses.

>  Source/kwsys/SystemTools.cxx| 38 
> +++--
>  Source/kwsys/testSystemTools.cxx|  9 ---

Applied to upstream KWSys first:

 http://review.source.kitware.com/21340

Thanks,
-Brad

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Re: [cmake-developers] [PATCH v4 3/4] Use SystemTools::GetEnv and HasEnv functions

2016-07-20 Thread Brad King
On 07/18/2016 10:00 AM, Brad King wrote:
> On 07/07/2016 05:54 PM, Dāvis Mosāns wrote:
>>  Source/kwsys/SystemTools.cxx| 38 
>> +++--
>>  Source/kwsys/testSystemTools.cxx|  9 ---
> 
> Applied to upstream KWSys first:
> 
>  http://review.source.kitware.com/21340

This is now in KWSys `master`.  I've updated it in CMake:

 KWSys 2016-07-18 (19732229)
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=eb7b5087

Thanks,
-Brad

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers