ENH: still escape () but do not escape
This commit is contained in:
parent
5c1bd19eb8
commit
71af96aad1
@ -1366,18 +1366,32 @@ kwsys_stl::string SystemTools::ConvertToUnixOutputPath(const char* path)
|
|||||||
{
|
{
|
||||||
ret.erase(pos, 1);
|
ret.erase(pos, 1);
|
||||||
}
|
}
|
||||||
// now escape spaces if there is a space in the path
|
// escape spaces and () in the path
|
||||||
if(ret.find_first_of(" ()") != kwsys_stl::string::npos)
|
if(ret.find_first_of(" ()") != kwsys_stl::string::npos)
|
||||||
{
|
{
|
||||||
kwsys_stl::string result = "";
|
kwsys_stl::string result = "";
|
||||||
char lastch = 1;
|
char lastch = 1;
|
||||||
|
bool inDollarVariable = false;
|
||||||
for(const char* ch = ret.c_str(); *ch != '\0'; ++ch)
|
for(const char* ch = ret.c_str(); *ch != '\0'; ++ch)
|
||||||
{
|
{
|
||||||
// if it is already escaped then don't try to escape it again
|
// if it is already escaped then don't try to escape it again
|
||||||
if((*ch == ' ' || *ch == '(' || *ch == ')') && lastch != '\\')
|
if((*ch == ' ' || *ch == '(' || *ch == ')') && lastch != '\\')
|
||||||
|
{
|
||||||
|
if(*ch == '(' && lastch == '$')
|
||||||
|
{
|
||||||
|
inDollarVariable = true;
|
||||||
|
}
|
||||||
|
// if we are in a $(..... and we get a ) then do not escape
|
||||||
|
// the ) and but set inDollarVariable to false
|
||||||
|
else if(*ch == ')' && inDollarVariable)
|
||||||
|
{
|
||||||
|
inDollarVariable = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
result += '\\';
|
result += '\\';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
result += *ch;
|
result += *ch;
|
||||||
lastch = *ch;
|
lastch = *ch;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user