remove old, hacky and unused split_string() function

This commit is contained in:
arvidn 2019-03-18 17:52:55 +01:00 committed by Arvid Norberg
parent 28d5b7d427
commit 5f85e40193
3 changed files with 0 additions and 56 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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 <vector>
@ -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)
{