From: Jeff Cohen Date: Fri, 8 Jul 2005 04:49:16 +0000 (+0000) Subject: Fix eraseSuffix() X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=563a17fb35bc123835661985513fbe6c07c8f711;p=oota-llvm.git Fix eraseSuffix() git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22355 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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