diff options
author | Brad King <brad.king@kitware.com> | 2006-09-27 17:43:46 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2006-09-27 17:43:46 (GMT) |
commit | dd332a00cc0169221243a231cd2474b6521aa11a (patch) | |
tree | 85d4722d4ac0dcbf665182a4dd2fe6f48f900fc0 /Source/cmLocalGenerator.cxx | |
parent | 5d22d36c5da1e0838d50c90250c06ba6852fb7b4 (diff) | |
download | CMake-dd332a00cc0169221243a231cd2474b6521aa11a.zip CMake-dd332a00cc0169221243a231cd2474b6521aa11a.tar.gz CMake-dd332a00cc0169221243a231cd2474b6521aa11a.tar.bz2 |
ENH: Re-implemented command line argument shell quoting to support several platforms with one code base.
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 34295ae..a3b48b3 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -39,6 +39,7 @@ cmLocalGenerator::cmLocalGenerator() this->ExcludeFromAll = false; this->Parent = 0; this->WindowsShell = false; + this->WindowsVSIDE = false; this->IgnoreLibPrefix = false; this->UseRelativePaths = false; this->Configured = false; @@ -2243,12 +2244,9 @@ cmLocalGenerator } //---------------------------------------------------------------------------- -std::string cmLocalGenerator::EscapeForShell(const char* str) +std::string cmLocalGenerator::EscapeForShellOldStyle(const char* str) { std::string result; - // Temporarily use old shell escaping code until a means of backward - // compatibility can be established in the new implementation. -#if 1 bool forceOn = cmSystemTools::GetForceUnixPaths(); if(forceOn && this->WindowsShell) { @@ -2259,25 +2257,41 @@ std::string cmLocalGenerator::EscapeForShell(const char* str) { cmSystemTools::SetForceUnixPaths(true); } -#else + return result; +} + +//---------------------------------------------------------------------------- +std::string cmLocalGenerator::EscapeForShell(const char* str, bool makeVars) +{ + // Compute the flags for the target shell environment. + int flags = 0; + if(this->WindowsVSIDE) + { + flags |= cmsysSystem_Shell_Flag_VSIDE; + } + else + { + flags |= cmsysSystem_Shell_Flag_Make; + } + if(makeVars) + { + flags |= cmsysSystem_Shell_Flag_AllowMakeVariables; + } + + // Compute the buffer size needed. + int size = (this->WindowsShell ? + cmsysSystem_Shell_GetArgumentSizeForWindows(str, flags) : + cmsysSystem_Shell_GetArgumentSizeForUnix(str, flags)); + + // Compute the shell argument itself. + std::vector<char> arg(size); if(this->WindowsShell) { - int size = cmsysSystem_Windows_ShellArgumentSize(str); - std::vector<char> arg(size); - cmsysSystem_Windows_ShellArgument(str, &arg[0]); - result = &arg[0]; + cmsysSystem_Shell_GetArgumentForWindows(str, &arg[0], flags); } else { - for(const char* c = str; *c; ++c) - { - if(*c == '\\' || *c == '\'' || *c == '"' || *c == ';' || *c == ' ') - { - result += "\\"; - } - result += *c; - } + cmsysSystem_Shell_GetArgumentForUnix(str, &arg[0], flags); } -#endif - return result; + return std::string(&arg[0]); } |