mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
Return a pointer from str_endswith
as well
(cherry picked from commit 9fcf5480f8
)
This commit is contained in:
parent
e162ee085f
commit
185f353902
|
@ -1964,15 +1964,24 @@ const char *str_startswith(const char *str, const char *prefix)
|
|||
}
|
||||
}
|
||||
|
||||
int str_endswith(const char *str, const char *suffix)
|
||||
const char *str_endswith(const char *str, const char *suffix)
|
||||
{
|
||||
int strl = str_length(str);
|
||||
int suffixl = str_length(suffix);
|
||||
const char *strsuffix;
|
||||
if(strl < suffixl)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return str_comp(str + strl - suffixl, suffix) == 0;
|
||||
strsuffix = str + strl - suffixl;
|
||||
if(str_comp(strsuffix, suffix) == 0)
|
||||
{
|
||||
return strsuffix;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
const char *str_find_nocase(const char *haystack, const char *needle)
|
||||
|
|
|
@ -1039,13 +1039,13 @@ const char *str_startswith(const char *str, const char *prefix);
|
|||
suffix - Suffix to look for.
|
||||
|
||||
Returns:
|
||||
0 - String suffix is not a suffix of string str
|
||||
1 - String suffix is a suffix of string str
|
||||
A pointer to the beginning of the suffix in the string str, or
|
||||
0 if the string suffix isn't a suffix of the string str.
|
||||
|
||||
Remarks:
|
||||
- The strings are treated as zero-terminated strings.
|
||||
*/
|
||||
int str_endswith(const char *str, const char *suffix);
|
||||
const char *str_endswith(const char *str, const char *suffix);
|
||||
|
||||
/*
|
||||
Function: str_find_nocase
|
||||
|
|
Loading…
Reference in a new issue