diff options
author | Mikhail Glushenkov <foldr@codedgers.com> | 2010-11-02 22:18:37 +0000 |
---|---|---|
committer | Mikhail Glushenkov <foldr@codedgers.com> | 2010-11-02 22:18:37 +0000 |
commit | bd6e0323b94361559e125b07cb244629b0da0281 (patch) | |
tree | 20edcd2bac3083804311db31740c9ecd913e373d /lib/System | |
parent | ed724fd43a2388f93460ca397c69948d346ec4db (diff) |
appendSuffix: don't append a dot when the suffix is empty.
Additionally, move the implementation of appendSuffix to Path.cpp: it is
platform-independent.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118089 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System')
-rw-r--r-- | lib/System/Path.cpp | 15 | ||||
-rw-r--r-- | lib/System/Unix/Path.inc | 12 | ||||
-rw-r--r-- | lib/System/Win32/Path.inc | 12 |
3 files changed, 15 insertions, 24 deletions
diff --git a/lib/System/Path.cpp b/lib/System/Path.cpp index 8fc4153acb..5d8de65661 100644 --- a/lib/System/Path.cpp +++ b/lib/System/Path.cpp @@ -196,6 +196,21 @@ StringRef Path::GetDLLSuffix() { } bool +Path::appendSuffix(StringRef suffix) { + if (!suffix.empty()) { + std::string save(path); + path.append("."); + path.append(suffix); + if (!isValid()) { + path = save; + return false; + } + } + + return true; +} + +bool Path::isBitcodeFile() const { std::string actualMagic; if (!getMagicNumber(actualMagic, 4)) diff --git a/lib/System/Unix/Path.inc b/lib/System/Unix/Path.inc index 15588689f9..b1d2ad2446 100644 --- a/lib/System/Unix/Path.inc +++ b/lib/System/Unix/Path.inc @@ -638,18 +638,6 @@ Path::eraseComponent() { } bool -Path::appendSuffix(StringRef suffix) { - std::string save(path); - path.append("."); - path.append(suffix); - if (!isValid()) { - path = save; - return false; - } - return true; -} - -bool Path::eraseSuffix() { std::string save = path; size_t dotpos = path.rfind('.',path.size()); diff --git a/lib/System/Win32/Path.inc b/lib/System/Win32/Path.inc index ea6d4639ba..2ead80127b 100644 --- a/lib/System/Win32/Path.inc +++ b/lib/System/Win32/Path.inc @@ -552,18 +552,6 @@ Path::eraseComponent() { } bool -Path::appendSuffix(StringRef suffix) { - std::string save(path); - path.append("."); - path.append(suffix); - if (!isValid()) { - path = save; - return false; - } - return true; -} - -bool Path::eraseSuffix() { size_t dotpos = path.rfind('.',path.size()); size_t slashpos = path.rfind('/',path.size()); |