strcasestr implementation for mingw

This commit is contained in:
Raphael Assenat 2015-11-16 22:18:46 -05:00
parent 870e414cfc
commit 30b321dcea
3 changed files with 40 additions and 1 deletions

View File

@ -10,7 +10,7 @@ endif
ifeq ($(shell uname -o), Msys)
COMPAT_OBJS=sleep.o memmem.o
COMPAT_OBJS=sleep.o memmem.o strcasestr.o
endif
CFLAGS=-Wall -g `pkg-config $(HIDAPI_NAME) --cflags` --std=c99

33
tool/strcasestr.c Normal file
View File

@ -0,0 +1,33 @@
#include <string.h>
#ifdef TEST_IMPLEMENTATION
#include <stdio.h>
#define strcasestr my_strcasestr
char *strcasestr(const char *haystack, const char *needle);
int main(void)
{
const char *a = "sdfsdj kdkf23 34fjsdf lsdf ";
if (my_strcasestr(a, "11")) {
printf("Test 1 failed\n");
}
if (!my_strcasestr(a, "23")) {
printf("Test 2 failed\n");
}
}
#endif
char *strcasestr(const char *haystack, const char *needle)
{
while (*haystack) {
if (0==strncasecmp(haystack, needle, strlen(needle))) {
return (char*)haystack;
}
haystack++;
}
return NULL;
}

6
tool/strcasestr.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef _strcasestr_h__
#define _strcasestr_h_-
char *strcasestr(const char *haystack, const char *needle);
#endif // _strcasestr_h__