diff --git a/src/base/system.c b/src/base/system.c index 9a5878eb3..626acc2ba 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -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) diff --git a/src/base/system.h b/src/base/system.h index ed27da081..fff31dd61 100644 --- a/src/base/system.h +++ b/src/base/system.h @@ -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