From 5f85e401936ad6580d4405c23e3d86a794e86551 Mon Sep 17 00:00:00 2001 From: arvidn Date: Mon, 18 Mar 2019 17:52:55 +0100 Subject: [PATCH] remove old, hacky and unused split_string() function --- include/libtorrent/string_util.hpp | 1 - src/string_util.cpp | 20 ----------------- test/test_file.cpp | 35 ------------------------------ 3 files changed, 56 deletions(-) diff --git a/include/libtorrent/string_util.hpp b/include/libtorrent/string_util.hpp index c7c339fee..2cb38caea 100644 --- a/include/libtorrent/string_util.hpp +++ b/include/libtorrent/string_util.hpp @@ -64,7 +64,6 @@ namespace libtorrent { TORRENT_EXTRA_EXPORT bool is_space(char c); TORRENT_EXTRA_EXPORT char to_lower(char c); - TORRENT_EXTRA_EXPORT int split_string(char const** tags, int buf_size, char* in); TORRENT_EXTRA_EXPORT bool string_begins_no_case(char const* s1, char const* s2); TORRENT_EXTRA_EXPORT bool string_equal_no_case(string_view s1, string_view s2); diff --git a/src/string_util.cpp b/src/string_util.cpp index 732549db5..b499a3c51 100644 --- a/src/string_util.cpp +++ b/src/string_util.cpp @@ -86,26 +86,6 @@ namespace libtorrent { return (c >= 'A' && c <= 'Z') ? c - 'A' + 'a' : c; } - int split_string(char const** tags, int buf_size, char* in) - { - int ret = 0; - char* i = in; - for (;*i; ++i) - { - if (!is_print(*i) || is_space(*i)) - { - *i = 0; - if (ret == buf_size) return ret; - continue; - } - if (i == in || i[-1] == 0) - { - tags[ret++] = i; - } - } - return ret; - } - bool string_begins_no_case(char const* s1, char const* s2) { TORRENT_ASSERT(s1 != nullptr); diff --git a/test/test_file.cpp b/test/test_file.cpp index 72705940d..9eaebf12d 100644 --- a/test/test_file.cpp +++ b/test/test_file.cpp @@ -33,7 +33,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/file.hpp" #include "libtorrent/aux_/path.hpp" #include "libtorrent/aux_/numeric_cast.hpp" -#include "libtorrent/string_util.hpp" // for split_string #include "libtorrent/string_view.hpp" #include "test.hpp" #include @@ -275,40 +274,6 @@ TORRENT_TEST(paths) TEST_EQUAL(complete("."), current_working_directory()); } -// test split_string -TORRENT_TEST(split_string) -{ - char const* tags[10]; - char tags_str[] = " this is\ta test\t string\x01to be split and it cannot " - "extend over the limit of elements \t"; - int ret = split_string(tags, 10, tags_str); - - TEST_CHECK(ret == 10); - TEST_CHECK(tags[0] == "this"_sv); - TEST_CHECK(tags[1] == "is"_sv); - TEST_CHECK(tags[2] == "a"_sv); - TEST_CHECK(tags[3] == "test"_sv); - TEST_CHECK(tags[4] == "string"_sv); - TEST_CHECK(tags[5] == "to"_sv); - TEST_CHECK(tags[6] == "be"_sv); - TEST_CHECK(tags[7] == "split"_sv); - TEST_CHECK(tags[8] == "and"_sv); - TEST_CHECK(tags[9] == "it"_sv); - - // replace_extension - std::string test = "foo.bar"; - replace_extension(test, "txt"); - TEST_EQUAL(test, "foo.txt"); - - test = "_"; - replace_extension(test, "txt"); - TEST_EQUAL(test, "_.txt"); - - test = "1.2.3/_"; - replace_extension(test, "txt"); - TEST_EQUAL(test, "1.2.3/_.txt"); -} - // file class TORRENT_TEST(file) {