Browse Source

BUG: fix spaces in path with mingw and custom commands

Bill Hoffman 21 years ago
parent
commit
f1842f9137
1 changed files with 33 additions and 19 deletions
  1. 33 19
      Source/cmSystemTools.cxx

+ 33 - 19
Source/cmSystemTools.cxx

@@ -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;
+  bool useDoubleQ = true;
+#else
+  bool useDoubleQ = false;
+#endif
+  if(cmSystemTools::s_ForceUnixPaths)
+    {
+    useDoubleQ = false;
+    }
   
-  // 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;
+  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;
     }
-  return str;
-#else
-  std::string result = "";
-  for(const char* ch = str; *ch != '\0'; ++ch)
+  else
     {
-    if(*ch == ' ')
+    std::string result = "";
+    for(const char* ch = str; *ch != '\0'; ++ch)
       {
-      result += '\\';
+      if(*ch == ' ')
+        {
+        result += '\\';
+        }
+      result += *ch;
       }
-    result += *ch;
+    return result;
     }
-  return result;
-#endif
 }
 
+
 std::string cmSystemTools::RemoveEscapes(const char* s)
 {
   std::string result = "";