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
diff --git a/lib/System/Path.cpp b/lib/System/Path.cpp
index 8fc4153..5d8de65 100644
--- a/lib/System/Path.cpp
+++ b/lib/System/Path.cpp
@@ -196,6 +196,21 @@
}
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 1558868..b1d2ad2 100644
--- a/lib/System/Unix/Path.inc
+++ b/lib/System/Unix/Path.inc
@@ -638,18 +638,6 @@
}
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 ea6d463..2ead801 100644
--- a/lib/System/Win32/Path.inc
+++ b/lib/System/Win32/Path.inc
@@ -552,18 +552,6 @@
}
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());