You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2014/10/24 02:07:08 UTC
[2/2] git commit: Revert "Switched path::join() to be variadic".
Revert "Switched path::join() to be variadic".
This reverts commit b08fccf8f5ea325b8c38055b5f2c03509744dd9b.
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/26baf553
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/26baf553
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/26baf553
Branch: refs/heads/master
Commit: 26baf5531eb9547461e429a702a698da2189e0b4
Parents: 1e15ff1
Author: Benjamin Mahler <bm...@twitter.com>
Authored: Thu Oct 23 16:47:50 2014 -0700
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Thu Oct 23 16:49:39 2014 -0700
----------------------------------------------------------------------
3rdparty/libprocess/3rdparty/Makefile.am | 1 -
3rdparty/libprocess/3rdparty/stout/Makefile.am | 1 -
.../3rdparty/stout/include/stout/path.hpp | 77 ++++++++++++--------
.../3rdparty/stout/include/stout/strings.hpp | 4 +-
.../3rdparty/stout/tests/path_tests.cpp | 39 ----------
5 files changed, 47 insertions(+), 75 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/26baf553/3rdparty/libprocess/3rdparty/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/Makefile.am b/3rdparty/libprocess/3rdparty/Makefile.am
index 895ac6b..1e24886 100644
--- a/3rdparty/libprocess/3rdparty/Makefile.am
+++ b/3rdparty/libprocess/3rdparty/Makefile.am
@@ -162,7 +162,6 @@ stout_tests_SOURCES = \
$(STOUT)/tests/none_tests.cpp \
$(STOUT)/tests/option_tests.cpp \
$(STOUT)/tests/os_tests.cpp \
- $(STOUT)/tests/path_tests.cpp \
$(STOUT)/tests/protobuf_tests.cpp \
$(STOUT)/tests/protobuf_tests.pb.cc \
$(STOUT)/tests/protobuf_tests.pb.h \
http://git-wip-us.apache.org/repos/asf/mesos/blob/26baf553/3rdparty/libprocess/3rdparty/stout/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/Makefile.am b/3rdparty/libprocess/3rdparty/stout/Makefile.am
index 16cab5a..4136062 100644
--- a/3rdparty/libprocess/3rdparty/stout/Makefile.am
+++ b/3rdparty/libprocess/3rdparty/stout/Makefile.am
@@ -29,7 +29,6 @@ EXTRA_DIST = \
tests/net_tests.cpp \
tests/none_tests.cpp \
tests/option_tests.cpp \
- tests/path_tests.cpp \
tests/os_tests.cpp \
tests/os/sendfile_tests.cpp \
tests/os/setns_tests.cpp \
http://git-wip-us.apache.org/repos/asf/mesos/blob/26baf553/3rdparty/libprocess/3rdparty/stout/include/stout/path.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/path.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/path.hpp
index 63433ef..bc6920a 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/path.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/path.hpp
@@ -15,34 +15,59 @@
#define __STOUT_PATH_HPP__
#include <string>
-#include <utility>
#include <vector>
#include "strings.hpp"
namespace path {
+inline std::string join(const std::string& path1, const std::string& path2)
+{
+ return
+ strings::remove(path1, "/", strings::SUFFIX) + "/" +
+ strings::remove(path2, "/", strings::PREFIX);
+}
-template<typename ...T>
-std::string join(const std::string& path, T&&... tail)
+
+inline std::string join(
+ const std::string& path1,
+ const std::string& path2,
+ const std::string& path3)
{
- std::string tailJoined = strings::join(
- "/",
- strings::trim(std::forward<T>(tail), "/")...);
-
- // The first path chunk is special in that if it starts with a '/',
- // we want to keep that.
- if (path.empty()) {
- return tailJoined;
- }
+ return join(path1, join(path2, path3));
+}
- // If the first chunk ends with a '/', don't append another using
- // join. This also handles the case with the first path part is just
- // '/'.
- if (path.back() == '/') {
- return path + tailJoined;
- }
- return strings::join("/", path, tailJoined);
+
+inline std::string join(
+ const std::string& path1,
+ const std::string& path2,
+ const std::string& path3,
+ const std::string& path4)
+{
+ return join(path1, join(path2, path3, path4));
+}
+
+
+inline std::string join(
+ const std::string& path1,
+ const std::string& path2,
+ const std::string& path3,
+ const std::string& path4,
+ const std::string& path5)
+{
+ return join(path1, join(path2, join(path3, join(path4, path5))));
+}
+
+
+inline std::string join(
+ const std::string& path1,
+ const std::string& path2,
+ const std::string& path3,
+ const std::string& path4,
+ const std::string& path5,
+ const std::string& path6)
+{
+ return join(path1, join(path2, path3, path4, path5, path6));
}
@@ -54,19 +79,7 @@ inline std::string join(const std::vector<std::string>& paths)
std::string result = paths[0];
for (size_t i = 1; i < paths.size(); ++i) {
- const std::string &path = paths[i];
-
- // Don't insert extra '/' for empty paths.
- if (path.empty()) {
- continue;
- }
-
- // If result is empty, fill it.
- if (result.empty()) {
- result = path;
- continue;
- }
- result = join(result, path);
+ result = join(result, paths[i]);
}
return result;
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/26baf553/3rdparty/libprocess/3rdparty/stout/include/stout/strings.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/strings.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/strings.hpp
index 01e47ff..7976f22 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/strings.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/strings.hpp
@@ -287,8 +287,8 @@ std::string join(
// Ensure std::string doesn't fall into the iterable case
-inline std::string join(const std::string &seperator, const std::string &str) {
- return str;
+inline std::string join(const std::string &seperator, const std::string &s) {
+ return s;
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/26baf553/3rdparty/libprocess/3rdparty/stout/tests/path_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/path_tests.cpp b/3rdparty/libprocess/3rdparty/stout/tests/path_tests.cpp
deleted file mode 100644
index aedf935..0000000
--- a/3rdparty/libprocess/3rdparty/stout/tests/path_tests.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <gtest/gtest.h>
-
-#include <string>
-#include <vector>
-
-#include <stout/path.hpp>
-
-using std::string;
-using std::vector;
-
-
-TEST(PathTest, Join)
-{
- EXPECT_EQ("a/b/c", path::join("a", "b", "c"));
- EXPECT_EQ("a/b/c", path::join(string("a"), string("b"), string("c")));
- EXPECT_EQ("a/b/c", path::join(string("a"), "b", string("c")));
- EXPECT_EQ("a/b/c", path::join(vector<string>({"a", "b", "c"})));
- EXPECT_EQ("", path::join(vector<string>()));
- EXPECT_EQ("", path::join(vector<string>({"", "", ""})));
- EXPECT_EQ("/asdf", path::join("/", "asdf"));
- EXPECT_EQ("/", path::join("", "/", ""));
- EXPECT_EQ("a/b/c", path::join("a/", "b/", "c/"));
- EXPECT_EQ("/a/b/c", path::join("/a", "/b", "/c"));
- EXPECT_EQ("/a/b/c", path::join("/a/", "/b/", "/c/"));
- EXPECT_EQ("a/b/c", path::join("a/", "/b/", "/c/"));
-}