From 563a17fb35bc123835661985513fbe6c07c8f711 Mon Sep 17 00:00:00 2001 From: Jeff Cohen Date: Fri, 8 Jul 2005 04:49:16 +0000 Subject: [PATCH] Fix eraseSuffix() git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22355 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/System/Unix/Path.inc | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/System/Unix/Path.inc b/lib/System/Unix/Path.inc index 7ced25ab8d0..79786358ac7 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 -- 2.34.1