Commit d9c23038 authored by Tim Rühsen's avatar Tim Rühsen

* libwget/utils.c: Cleanup wget_match_tail(_nocase)

parent 99e32c1b
Pipeline #41293263 passed with stages
in 19 minutes and 16 seconds
......@@ -346,10 +346,12 @@ int wget_percent_unescape(char *src)
*/
int wget_match_tail(const char *s, const char *tail)
{
if (strlen(s) < strlen(tail))
size_t s_len, tail_len;
if ((s_len = strlen(s)) < (tail_len = strlen(tail)))
return 0;
const char *p = s + (strlen(s) - strlen(tail));
const char *p = s + (s_len - tail_len);
return !strcmp(p, tail);
}
......@@ -364,10 +366,12 @@ int wget_match_tail(const char *s, const char *tail)
*/
int wget_match_tail_nocase(const char *s, const char *tail)
{
if (strlen(s) < strlen(tail))
size_t s_len, tail_len;
if ((s_len = strlen(s)) < (tail_len = strlen(tail)))
return 0;
const char *p = s + (strlen(s) - strlen(tail));
const char *p = s + (s_len - tail_len);
return !wget_strcasecmp_ascii(p, tail);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment