diff options
author | Brad King <brad.king@kitware.com> | 2009-04-21 15:37:09 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-04-21 15:37:09 (GMT) |
commit | 13e454f8d38bb46bd55917d827ea603d1760c623 (patch) | |
tree | d4142a956338c22be6221217bc545b3c810058a1 /Source/cmSystemTools.cxx | |
parent | 714d2fc04ba0ba7b455ab30602aef4ebc69ecf1b (diff) | |
download | CMake-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.cxx | 4 |
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 ""; |