summaryrefslogtreecommitdiffstats
path: root/llvm/lib/System/Unix
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
commit4c24144ddf6cd1c35855bcc41ce96b99f2e7ca65 (patch)
treee13b5903f6d4efff13667191e24c66dc08c3aab3 /llvm/lib/System/Unix
parentaf48d8643debbca222fb868e8e4e8dce18271a9f (diff)
downloadbcm5719-llvm-4c24144ddf6cd1c35855bcc41ce96b99f2e7ca65.tar.gz
bcm5719-llvm-4c24144ddf6cd1c35855bcc41ce96b99f2e7ca65.zip
Fix eraseSuffix()
llvm-svn: 22355
Diffstat (limited to 'llvm/lib/System/Unix')
-rw-r--r--llvm/lib/System/Unix/Path.inc16
1 files changed, 6 insertions, 10 deletions
diff --git a/llvm/lib/System/Unix/Path.inc b/llvm/lib/System/Unix/Path.inc
index 7ced25ab8d0..79786358ac7 100644
--- a/llvm/lib/System/Unix/Path.inc
+++ b/llvm/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
OpenPOWER on IntegriCloud