From 37704b8b8bb32926819385b7c22b22d10c805ff2 Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Thu, 28 May 2009 16:04:14 +0000 Subject: [PATCH] * Ensure that ends_with() actually tests against the end of the string. --- utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils.c b/utils.c index 4844e43..a3ea9f3 100644 --- a/utils.c +++ b/utils.c @@ -29,8 +29,8 @@ int ends_with(const char * haystack, const char * needle) { - const char *found = strcasestr(haystack, needle); - return (found && found[strlen(needle)] == '\0'); + const char * end = strrchr(haystack, *needle); + return (strcasecmp(end?end:"", needle) ? 0 : 1); } char *