summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-04-21 15:37:09 (GMT)
committerBrad King <brad.king@kitware.com>2009-04-21 15:37:09 (GMT)
commit13e454f8d38bb46bd55917d827ea603d1760c623 (patch)
treed4142a956338c22be6221217bc545b3c810058a1 /Source/cmSystemTools.cxx
parent714d2fc04ba0ba7b455ab30602aef4ebc69ecf1b (diff)
downloadCMake-13e454f8d38bb46bd55917d827ea603d1760c623.zip
CMake-13e454f8d38bb46bd55917d827ea603d1760c623.tar.gz
CMake-13e454f8d38bb46bd55917d827ea603d1760c623.tar.bz2
BUG: Avoid infinite loop at directory tree root
The system tools GetParentDirectory method no longer removes the root path component. This fixes cmSystemTools::FileExistsInParentDirectories to not infinitely loop at when GetParentDirectory stops at the root.
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx4
1 files changed, 3 insertions, 1 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index d0aedd9..23da1e3 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1104,7 +1104,8 @@ std::string cmSystemTools::FileExistsInParentDirectories(const char* fname,
SystemTools::ConvertToUnixSlashes(file);
std::string dir = directory;
SystemTools::ConvertToUnixSlashes(dir);
- while ( !dir.empty() )
+ std::string prevDir;
+ while(dir != prevDir)
{
std::string path = dir + "/" + file;
if ( SystemTools::FileExists(path.c_str()) )
@@ -1115,6 +1116,7 @@ std::string cmSystemTools::FileExistsInParentDirectories(const char* fname,
{
break;
}
+ prevDir = dir;
dir = SystemTools::GetParentDirectory(dir.c_str());
}
return "";