mirror of
https://github.com/raphnet/gc_n64_usb-v3
synced 2025-01-30 23:00:11 -05:00
strcasestr implementation for mingw
This commit is contained in:
parent
870e414cfc
commit
30b321dcea
@ -10,7 +10,7 @@ endif
|
|||||||
|
|
||||||
|
|
||||||
ifeq ($(shell uname -o), Msys)
|
ifeq ($(shell uname -o), Msys)
|
||||||
COMPAT_OBJS=sleep.o memmem.o
|
COMPAT_OBJS=sleep.o memmem.o strcasestr.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS=-Wall -g `pkg-config $(HIDAPI_NAME) --cflags` --std=c99
|
CFLAGS=-Wall -g `pkg-config $(HIDAPI_NAME) --cflags` --std=c99
|
||||||
|
33
tool/strcasestr.c
Normal file
33
tool/strcasestr.c
Normal 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
6
tool/strcasestr.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef _strcasestr_h__
|
||||||
|
#define _strcasestr_h_-
|
||||||
|
|
||||||
|
char *strcasestr(const char *haystack, const char *needle);
|
||||||
|
|
||||||
|
#endif // _strcasestr_h__
|
Loading…
Reference in New Issue
Block a user