Merge branch 'upstream-kwsys' into update-kwsys
This commit is contained in:
commit
daab3b3bdf
|
@ -3425,9 +3425,12 @@ kwsys_stl::string SystemTools::RelativePath(const kwsys_stl::string& local, cons
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kwsys_stl::string l = SystemTools::CollapseFullPath(local);
|
||||||
|
kwsys_stl::string r = SystemTools::CollapseFullPath(remote);
|
||||||
|
|
||||||
// split up both paths into arrays of strings using / as a separator
|
// split up both paths into arrays of strings using / as a separator
|
||||||
kwsys_stl::vector<kwsys::String> localSplit = SystemTools::SplitString(local, '/', true);
|
kwsys_stl::vector<kwsys::String> localSplit = SystemTools::SplitString(l, '/', true);
|
||||||
kwsys_stl::vector<kwsys::String> remoteSplit = SystemTools::SplitString(remote, '/', true);
|
kwsys_stl::vector<kwsys::String> remoteSplit = SystemTools::SplitString(r, '/', true);
|
||||||
kwsys_stl::vector<kwsys::String> commonPath; // store shared parts of path in this array
|
kwsys_stl::vector<kwsys::String> commonPath; // store shared parts of path in this array
|
||||||
kwsys_stl::vector<kwsys::String> finalPath; // store the final relative path here
|
kwsys_stl::vector<kwsys::String> finalPath; // store the final relative path here
|
||||||
// count up how many matching directory names there are from the start
|
// count up how many matching directory names there are from the start
|
||||||
|
@ -3533,6 +3536,16 @@ static int GetCasePathName(const kwsys_stl::string & pathIn,
|
||||||
kwsys_stl::string test_str = casePath;
|
kwsys_stl::string test_str = casePath;
|
||||||
test_str += path_components[idx];
|
test_str += path_components[idx];
|
||||||
|
|
||||||
|
// If path component contains wildcards, we skip matching
|
||||||
|
// because these filenames are not allowed on windows,
|
||||||
|
// and we do not want to match a different file.
|
||||||
|
if(path_components[idx].find('*') != kwsys_stl::string::npos ||
|
||||||
|
path_components[idx].find('?') != kwsys_stl::string::npos)
|
||||||
|
{
|
||||||
|
casePath = "";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
WIN32_FIND_DATAW findData;
|
WIN32_FIND_DATAW findData;
|
||||||
HANDLE hFind = ::FindFirstFileW(Encoding::ToWide(test_str).c_str(),
|
HANDLE hFind = ::FindFirstFileW(Encoding::ToWide(test_str).c_str(),
|
||||||
&findData);
|
&findData);
|
||||||
|
|
|
@ -13,7 +13,7 @@ SET(KWSYS_PLATFORM_TEST_FILE_C kwsysPlatformTestsC.c)
|
||||||
SET(KWSYS_PLATFORM_TEST_FILE_CXX kwsysPlatformTestsCXX.cxx)
|
SET(KWSYS_PLATFORM_TEST_FILE_CXX kwsysPlatformTestsCXX.cxx)
|
||||||
|
|
||||||
MACRO(KWSYS_PLATFORM_TEST lang var description invert)
|
MACRO(KWSYS_PLATFORM_TEST lang var description invert)
|
||||||
IF("${var}_COMPILED" MATCHES "^${var}_COMPILED$")
|
IF(NOT DEFINED ${var}_COMPILED)
|
||||||
MESSAGE(STATUS "${description}")
|
MESSAGE(STATUS "${description}")
|
||||||
TRY_COMPILE(${var}_COMPILED
|
TRY_COMPILE(${var}_COMPILED
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
@ -43,7 +43,7 @@ MACRO(KWSYS_PLATFORM_TEST lang var description invert)
|
||||||
MESSAGE(STATUS "${description} - no")
|
MESSAGE(STATUS "${description} - no")
|
||||||
ENDIF(${var}_COMPILED)
|
ENDIF(${var}_COMPILED)
|
||||||
ENDIF(${invert} MATCHES INVERT)
|
ENDIF(${invert} MATCHES INVERT)
|
||||||
ENDIF("${var}_COMPILED" MATCHES "^${var}_COMPILED$")
|
ENDIF()
|
||||||
IF(${invert} MATCHES INVERT)
|
IF(${invert} MATCHES INVERT)
|
||||||
IF(${var}_COMPILED)
|
IF(${var}_COMPILED)
|
||||||
SET(${var} 0)
|
SET(${var} 0)
|
||||||
|
@ -60,7 +60,7 @@ MACRO(KWSYS_PLATFORM_TEST lang var description invert)
|
||||||
ENDMACRO(KWSYS_PLATFORM_TEST)
|
ENDMACRO(KWSYS_PLATFORM_TEST)
|
||||||
|
|
||||||
MACRO(KWSYS_PLATFORM_TEST_RUN lang var description invert)
|
MACRO(KWSYS_PLATFORM_TEST_RUN lang var description invert)
|
||||||
IF("${var}" MATCHES "^${var}$")
|
IF(NOT DEFINED ${var})
|
||||||
MESSAGE(STATUS "${description}")
|
MESSAGE(STATUS "${description}")
|
||||||
TRY_RUN(${var} ${var}_COMPILED
|
TRY_RUN(${var} ${var}_COMPILED
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
@ -107,7 +107,7 @@ MACRO(KWSYS_PLATFORM_TEST_RUN lang var description invert)
|
||||||
MESSAGE(STATUS "${description} - failed to compile")
|
MESSAGE(STATUS "${description} - failed to compile")
|
||||||
ENDIF(${var}_COMPILED)
|
ENDIF(${var}_COMPILED)
|
||||||
ENDIF(${invert} MATCHES INVERT)
|
ENDIF(${invert} MATCHES INVERT)
|
||||||
ENDIF("${var}" MATCHES "^${var}$")
|
ENDIF()
|
||||||
|
|
||||||
IF(${invert} MATCHES INVERT)
|
IF(${invert} MATCHES INVERT)
|
||||||
IF(${var}_COMPILED)
|
IF(${var}_COMPILED)
|
||||||
|
|
|
@ -562,6 +562,55 @@ static bool CheckEnvironmentOperations()
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool CheckRelativePath(
|
||||||
|
const kwsys_stl::string& local,
|
||||||
|
const kwsys_stl::string& remote,
|
||||||
|
const kwsys_stl::string& expected)
|
||||||
|
{
|
||||||
|
kwsys_stl::string result = kwsys::SystemTools::RelativePath(local, remote);
|
||||||
|
if(expected != result)
|
||||||
|
{
|
||||||
|
kwsys_ios::cerr << "RelativePath(" << local << ", " << remote
|
||||||
|
<< ") yielded " << result << " instead of " << expected << kwsys_ios::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool CheckRelativePaths()
|
||||||
|
{
|
||||||
|
bool res = true;
|
||||||
|
res &= CheckRelativePath("/usr/share", "/bin/bash", "../../bin/bash");
|
||||||
|
res &= CheckRelativePath("/usr/./share/", "/bin/bash", "../../bin/bash");
|
||||||
|
res &= CheckRelativePath("/usr//share/", "/bin/bash", "../../bin/bash");
|
||||||
|
res &= CheckRelativePath("/usr/share/../bin/", "/bin/bash", "../../bin/bash");
|
||||||
|
res &= CheckRelativePath("/usr/share", "/usr/share//bin", "bin");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool CheckCollapsePath(
|
||||||
|
const kwsys_stl::string& path,
|
||||||
|
const kwsys_stl::string& expected)
|
||||||
|
{
|
||||||
|
kwsys_stl::string result = kwsys::SystemTools::CollapseFullPath(path);
|
||||||
|
if(expected != result)
|
||||||
|
{
|
||||||
|
kwsys_ios::cerr << "CollapseFullPath(" << path
|
||||||
|
<< ") yielded " << result << " instead of " << expected << kwsys_ios::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool CheckCollapsePath()
|
||||||
|
{
|
||||||
|
bool res = true;
|
||||||
|
res &= CheckCollapsePath("/usr/share/*", "/usr/share/*");
|
||||||
|
res &= CheckCollapsePath("C:/Windows/*", "C:/Windows/*");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
int testSystemTools(int, char*[])
|
int testSystemTools(int, char*[])
|
||||||
{
|
{
|
||||||
|
@ -593,5 +642,9 @@ int testSystemTools(int, char*[])
|
||||||
|
|
||||||
res &= CheckEnvironmentOperations();
|
res &= CheckEnvironmentOperations();
|
||||||
|
|
||||||
|
res &= CheckRelativePaths();
|
||||||
|
|
||||||
|
res &= CheckCollapsePath();
|
||||||
|
|
||||||
return res ? 0 : 1;
|
return res ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue