From c8bae7493d2f2910b57f13ded012e86bdcfb0532 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 16:47:53 +0200 Subject: Adding upstream version 1:2.39.2. Signed-off-by: Daniel Baumann --- compat/strcasestr.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 compat/strcasestr.c (limited to 'compat/strcasestr.c') diff --git a/compat/strcasestr.c b/compat/strcasestr.c new file mode 100644 index 0000000..26896de --- /dev/null +++ b/compat/strcasestr.c @@ -0,0 +1,22 @@ +#include "../git-compat-util.h" + +char *gitstrcasestr(const char *haystack, const char *needle) +{ + int nlen = strlen(needle); + int hlen = strlen(haystack) - nlen + 1; + int i; + + for (i = 0; i < hlen; i++) { + int j; + for (j = 0; j < nlen; j++) { + unsigned char c1 = haystack[i+j]; + unsigned char c2 = needle[j]; + if (toupper(c1) != toupper(c2)) + goto next; + } + return (char *) haystack + i; + next: + ; + } + return NULL; +} -- cgit v1.2.3