BUG: fix spaces in path with mingw and custom commands

This commit is contained in:
Bill Hoffman 2004-06-22 17:23:28 -04:00
parent b5f2442ba9
commit f1842f9137
1 changed files with 36 additions and 22 deletions

View File

@ -127,33 +127,47 @@ std::string cmSystemTools::EscapeQuotes(const char* str)
std::string cmSystemTools::EscapeSpaces(const char* str)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
std::string result;
// if there are spaces
std::string temp = str;
if (temp.find(" ") != std::string::npos &&
temp.find("\"")==std::string::npos)
bool useDoubleQ = true;
#else
bool useDoubleQ = false;
#endif
if(cmSystemTools::s_ForceUnixPaths)
{
result = "\"";
result += str;
result += "\"";
useDoubleQ = false;
}
if(useDoubleQ)
{
std::string result;
// if there are spaces
std::string temp = str;
if (temp.find(" ") != std::string::npos &&
temp.find("\"")==std::string::npos)
{
result = "\"";
result += str;
result += "\"";
return result;
}
return str;
}
else
{
std::string result = "";
for(const char* ch = str; *ch != '\0'; ++ch)
{
if(*ch == ' ')
{
result += '\\';
}
result += *ch;
}
return result;
}
return str;
#else
std::string result = "";
for(const char* ch = str; *ch != '\0'; ++ch)
{
if(*ch == ' ')
{
result += '\\';
}
result += *ch;
}
return result;
#endif
}
std::string cmSystemTools::RemoveEscapes(const char* s)
{
std::string result = "";