aboutsummaryrefslogtreecommitdiffstats
path: root/lib/System
diff options
context:
space:
mode:
authorJeff Cohen <jeffc@jolt-lang.org>2005-07-08 04:49:16 +0000
committerJeff Cohen <jeffc@jolt-lang.org>2005-07-08 04:49:16 +0000
commit563a17fb35bc123835661985513fbe6c07c8f711 (patch)
tree4310fea1c0defbc5dc4cf8cc83952b1f973356eb /lib/System
parenta229c5cce75209047db32c6039aa0b0fd481f049 (diff)
downloadexternal_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
Diffstat (limited to 'lib/System')
-rw-r--r--lib/System/Unix/Path.inc16
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