BUG: fix spaces in path with mingw and custom commands
This commit is contained in:
parent
b5f2442ba9
commit
f1842f9137
@ -127,33 +127,47 @@ std::string cmSystemTools::EscapeQuotes(const char* str)
|
|||||||
std::string cmSystemTools::EscapeSpaces(const char* str)
|
std::string cmSystemTools::EscapeSpaces(const char* str)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
std::string result;
|
bool useDoubleQ = true;
|
||||||
|
#else
|
||||||
// if there are spaces
|
bool useDoubleQ = false;
|
||||||
std::string temp = str;
|
#endif
|
||||||
if (temp.find(" ") != std::string::npos &&
|
if(cmSystemTools::s_ForceUnixPaths)
|
||||||
temp.find("\"")==std::string::npos)
|
|
||||||
{
|
{
|
||||||
result = "\"";
|
useDoubleQ = false;
|
||||||
result += str;
|
}
|
||||||
result += "\"";
|
|
||||||
|
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 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 cmSystemTools::RemoveEscapes(const char* s)
|
||||||
{
|
{
|
||||||
std::string result = "";
|
std::string result = "";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user