diff options
author | Jeff Cohen <jeffc@jolt-lang.org> | 2005-07-08 04:49:16 +0000 |
---|---|---|
committer | Jeff Cohen <jeffc@jolt-lang.org> | 2005-07-08 04:49:16 +0000 |
commit | 563a17fb35bc123835661985513fbe6c07c8f711 (patch) | |
tree | 4310fea1c0defbc5dc4cf8cc83952b1f973356eb | |
parent | a229c5cce75209047db32c6039aa0b0fd481f049 (diff) | |
download | external_llvm-563a17fb35bc123835661985513fbe6c07c8f711.zip external_llvm-563a17fb35bc123835661985513fbe6c07c8f711.tar.gz external_llvm-563a17fb35bc123835661985513fbe6c07c8f711.tar.bz2 |
Fix eraseSuffix()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22355 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/System/Unix/Path.inc | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/System/Unix/Path.inc b/lib/System/Unix/Path.inc index 7ced25a..7978635 100644 --- a/lib/System/Unix/Path.inc +++ b/lib/System/Unix/Path.inc @@ -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 (!isValid()) { - path = save; - return false; + if (dotpos != std::string::npos) { + if (slashpos == std::string::npos || dotpos > slashpos) { + path.erase(dotpos, path.size()-dotpos); + return true; + } } - return true; + return false; } bool |