mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-14 03:58:18 +00:00
Forgot str_tokenize is not used now
This commit is contained in:
parent
698a3f1c5a
commit
867facfffc
|
@ -3051,27 +3051,6 @@ static const char *str_token_next(const char *str, const char *delim, size_t *le
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
int str_tokenize(const char *str, const char *delim, const char **state, char *buf, size_t bufsz)
|
|
||||||
{
|
|
||||||
const char *ret = NULL;
|
|
||||||
size_t len = 0;
|
|
||||||
|
|
||||||
if((!str && !state) || !buf)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
str = str ? str : *state;
|
|
||||||
|
|
||||||
if(!(ret = str_token_next(str, delim, &len)))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
*state = ret + len;
|
|
||||||
len = bufsz > len ? len : bufsz - 1;
|
|
||||||
mem_copy(buf, ret, len);
|
|
||||||
buf[len] = '\0';
|
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
int str_in_list(const char *list, const char *delim, const char *needle)
|
int str_in_list(const char *list, const char *delim, const char *needle)
|
||||||
{
|
{
|
||||||
const char *tok = list;
|
const char *tok = list;
|
||||||
|
|
|
@ -1831,25 +1831,6 @@ int str_utf16le_encode(char *ptr, int chr);
|
||||||
*/
|
*/
|
||||||
int str_utf8_check(const char *str);
|
int str_utf8_check(const char *str);
|
||||||
|
|
||||||
/*
|
|
||||||
Function: str_tokenize
|
|
||||||
Tokenizes a string.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
str - Pointer to string.
|
|
||||||
delim - Delimiter for tokenization.
|
|
||||||
state - Pointer to remaining string
|
|
||||||
buf - Buffer to store token in.
|
|
||||||
bufsz - Size of the buffer.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
The number of characters written to buf or -1 for end of string
|
|
||||||
|
|
||||||
Remarks:
|
|
||||||
- The token is always null-terminated.
|
|
||||||
*/
|
|
||||||
int str_tokenize(const char *str, const char *delim, const char **state, char *buf, size_t bufsz);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: str_in_list
|
Function: str_in_list
|
||||||
Checks if needle is in list delimited by delim
|
Checks if needle is in list delimited by delim
|
||||||
|
|
|
@ -136,23 +136,6 @@ TEST(Str, HexDecode)
|
||||||
EXPECT_EQ(str_hex_decode(aOut, 4, "41424344"), 0); EXPECT_STREQ(aOut, "ABCD");
|
EXPECT_EQ(str_hex_decode(aOut, 4, "41424344"), 0); EXPECT_STREQ(aOut, "ABCD");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Str, Tokenize)
|
|
||||||
{
|
|
||||||
char aTest[] = "GER,RUS,ZAF,BRA,CAN";
|
|
||||||
const char *aOut[] = {"GER", "RUS", "ZAF", "BRA", "CAN"};
|
|
||||||
const char *pState;
|
|
||||||
char aBuf[4];
|
|
||||||
|
|
||||||
int n = 0;
|
|
||||||
str_tokenize(aTest, ",", &pState, aBuf, sizeof aBuf);
|
|
||||||
do {
|
|
||||||
EXPECT_STREQ(aOut[n++], aBuf);
|
|
||||||
} while(str_tokenize(NULL, ",", &pState, aBuf, sizeof aBuf) >= 0);
|
|
||||||
|
|
||||||
char aTest2[] = "";
|
|
||||||
EXPECT_EQ(str_tokenize(aTest2, ",", &pState, aBuf, sizeof aBuf), -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(Str, InList)
|
TEST(Str, InList)
|
||||||
{
|
{
|
||||||
char aTest[] = "GER,RUS,ZAF,BRA,CAN";
|
char aTest[] = "GER,RUS,ZAF,BRA,CAN";
|
||||||
|
|
Loading…
Reference in a new issue