Fix eraseSuffix()

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22355 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jeff Cohen 2005-07-08 04:49:16 +00:00
parent a229c5cce7
commit 563a17fb35

View File

@ -504,19 +504,15 @@ Path::appendSuffix(const std::string& suffix) {
bool
Path::eraseSuffix() {
std::string save(path);
size_t dotpos = path.rfind('.',path.size());
size_t slashpos = path.rfind('/',path.size());
if (slashpos != std::string::npos &&
dotpos != std::string::npos &&
dotpos > slashpos) {
path.erase(dotpos, path.size()-dotpos);
if (dotpos != std::string::npos) {
if (slashpos == std::string::npos || dotpos > slashpos) {
path.erase(dotpos, path.size()-dotpos);
return true;
}
}
if (!isValid()) {
path = save;
return false;
}
return true;
return false;
}
bool