summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx49
1 files changed, 14 insertions, 35 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 1376a48..548fa74 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1630,33 +1630,28 @@ std::vector<std::string> cmSystemTools::GetEnvironmentVariables()
}
//----------------------------------------------------------------------
-std::vector<std::string> cmSystemTools::AppendEnv(
- std::vector<std::string>* env)
+void cmSystemTools::AppendEnv(std::vector<std::string> const& env)
{
- std::vector<std::string> origEnv = GetEnvironmentVariables();
-
- if (env && env->size()>0)
+ for(std::vector<std::string>::const_iterator eit = env.begin();
+ eit != env.end(); ++eit)
{
- std::vector<std::string>::const_iterator eit;
-
- for (eit = env->begin(); eit!= env->end(); ++eit)
- {
- PutEnv(eit->c_str());
- }
+ cmSystemTools::PutEnv(eit->c_str());
}
-
- return origEnv;
}
//----------------------------------------------------------------------
-void cmSystemTools::RestoreEnv(const std::vector<std::string>& env)
+cmSystemTools::SaveRestoreEnvironment::SaveRestoreEnvironment()
{
- std::vector<std::string>::const_iterator eit;
+ this->Env = cmSystemTools::GetEnvironmentVariables();
+}
+//----------------------------------------------------------------------
+cmSystemTools::SaveRestoreEnvironment::~SaveRestoreEnvironment()
+{
// First clear everything in the current environment:
- //
std::vector<std::string> currentEnv = GetEnvironmentVariables();
- for (eit = currentEnv.begin(); eit!= currentEnv.end(); ++eit)
+ for(std::vector<std::string>::const_iterator
+ eit = currentEnv.begin(); eit != currentEnv.end(); ++eit)
{
std::string var(*eit);
@@ -1666,27 +1661,11 @@ void cmSystemTools::RestoreEnv(const std::vector<std::string>& env)
var = var.substr(0, pos);
}
- UnsetEnv(var.c_str());
+ cmSystemTools::UnsetEnv(var.c_str());
}
// Then put back each entry from the original environment:
- //
- for (eit = env.begin(); eit!= env.end(); ++eit)
- {
- PutEnv(eit->c_str());
- }
-}
-
-//----------------------------------------------------------------------
-cmSystemTools::SaveRestoreEnvironment::SaveRestoreEnvironment()
-{
- this->Env = cmSystemTools::GetEnvironmentVariables();
-}
-
-//----------------------------------------------------------------------
-cmSystemTools::SaveRestoreEnvironment::~SaveRestoreEnvironment()
-{
- cmSystemTools::RestoreEnv(this->Env);
+ cmSystemTools::AppendEnv(this->Env);
}
#endif