瀏覽代碼

BUG: Avoid full paths and spaces when constructing object file names.

Brad King 20 年之前
父節點
當前提交
c332ff41f1
共有 1 個文件被更改,包括 11 次插入0 次删除
  1. 11 0
      Source/cmLocalUnixMakefileGenerator3.cxx

+ 11 - 0
Source/cmLocalUnixMakefileGenerator3.cxx

@@ -929,9 +929,20 @@ cmLocalUnixMakefileGenerator3::CreateSafeUniqueObjectFileName(const char* sin)
     // Start with the original name.
     std::string ssin = sin;
 
+    // Avoid full paths by removing leading slashes.
+    std::string::size_type pos = 0;
+    for(;pos < ssin.size() && ssin[pos] == '/'; ++pos);
+    ssin = ssin.substr(pos);
+
+    // Avoid full paths by removing colons.
+    cmSystemTools::ReplaceString(ssin, ":", "_");
+
     // Avoid relative paths that go up the tree.
     cmSystemTools::ReplaceString(ssin, "../", "__/");
 
+    // Avoid spaces.
+    cmSystemTools::ReplaceString(ssin, " ", "_");
+
     // Mangle the name if necessary.
     if(m_Makefile->IsOn("CMAKE_MANGLE_OBJECT_FILE_NAMES"))
       {