diff options
author | Ken Martin <ken.martin@kitware.com> | 2007-02-01 19:11:06 (GMT) |
---|---|---|
committer | Ken Martin <ken.martin@kitware.com> | 2007-02-01 19:11:06 (GMT) |
commit | 3dd4a53d97e8b4726c732e39b67df1c0eb2cc7eb (patch) | |
tree | 8e26380ed4225cd794ef9f06509972baea54b5a8 /Source | |
parent | 0b4bd97210805a7f7a8db529f26d695224c74c56 (diff) | |
download | CMake-3dd4a53d97e8b4726c732e39b67df1c0eb2cc7eb.zip CMake-3dd4a53d97e8b4726c732e39b67df1c0eb2cc7eb.tar.gz CMake-3dd4a53d97e8b4726c732e39b67df1c0eb2cc7eb.tar.bz2 |
BUG: fix for bug number 3320
Diffstat (limited to 'Source')
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 8df1a65..1a5a421 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -2513,6 +2513,8 @@ void SystemTools::AddTranslationPath(const char * a, const char * b) if( SystemTools::FileIsDirectory( path_a.c_str() ) ) { // Make sure the path is a full path and does not contain no '..' + // Ken--the following code is incorrect. .. can be in a valid path + // for example /home/martink/MyHubba...Hubba/Src if( SystemTools::FileIsFullPath(path_b.c_str()) && path_b.find("..") == kwsys_stl::string::npos ) { @@ -2605,6 +2607,9 @@ kwsys_stl::string SystemTools::CollapseFullPath(const char* in_path, // Split the input path components. kwsys_stl::vector<kwsys_stl::string> path_components; SystemTools::SplitPath(in_path, path_components); + + // clean the input path to remove any /./ + // If the input path is relative, start with a base path. if(path_components[0].length() == 0) { @@ -2640,11 +2645,36 @@ kwsys_stl::string SystemTools::CollapseFullPath(const char* in_path, path_components.begin(), path_components.end()); + // remove any . components as they do nothing + kwsys_stl::vector<kwsys_stl::string> clean_components; + kwsys_stl::vector<kwsys_stl::string>::iterator i = + out_components.begin(); + for (; i != out_components.end(); ++i) + { + if (*i != ".") + { + clean_components.push_back(*i); + } + } + + // Transform the path back to a string. - kwsys_stl::string newPath = SystemTools::JoinPath(out_components); + kwsys_stl::string newPath = SystemTools::JoinPath(clean_components); + + // Update the translation table with this potentially new path. I am not + // sure why this line is here, it seems really questionable, but yet I + // would put good money that if I remove it something will break, basically + // from what I can see it created a mapping from the collapsed path, to be + // replaced by the input path, which almost completely does the opposite of + // this function, the only thing preventing this from happening a lot is + // that if the in_path has a .. in it, then it is not added to the + // translation table. So for most calls this either does nothing due to the + // .. or it adds a translation between identical paths as nothing was + // collapsed, so I am going to try to comment it out, and see what hits the + // fan, hopefully quickly. + // Commented out line below: + //SystemTools::AddTranslationPath(newPath.c_str(), in_path); - // Update the translation table with this potentially new path. - SystemTools::AddTranslationPath(newPath.c_str(), in_path); SystemTools::CheckTranslationPath(newPath); #ifdef _WIN32 newPath = SystemTools::GetActualCaseForPath(newPath.c_str()); |