Fix eraseSuffix()
authorJeff Cohen <jeffc@jolt-lang.org>
Fri, 8 Jul 2005 04:49:16 +0000 (04:49 +0000)
committerJeff Cohen <jeffc@jolt-lang.org>
Fri, 8 Jul 2005 04:49:16 +0000 (04:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22355 91177308-0d34-0410-b5e6-96231b3b80d8

lib/System/Unix/Path.inc

index 7ced25ab8d0141fe32ffbe0b7d0cba2bf1cae5fa..79786358ac70cabd0bc759473a5fe54d69a5c143 100644 (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 (!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