summaryrefslogtreecommitdiff
path: root/src/m_misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/m_misc.c')
-rw-r--r--src/m_misc.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/m_misc.c b/src/m_misc.c
index 5847f1a2..ed41b5f1 100644
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -255,3 +255,37 @@ void M_ForceUppercase(char *text)
}
}
+//
+// M_StrCaseStr
+//
+// Case-insensitive version of strstr()
+//
+
+char *M_StrCaseStr(char *haystack, char *needle)
+{
+ unsigned int haystack_len;
+ unsigned int needle_len;
+ unsigned int len;
+ unsigned int i;
+
+ haystack_len = strlen(haystack);
+ needle_len = strlen(needle);
+
+ if (haystack_len < needle_len)
+ {
+ return NULL;
+ }
+
+ len = haystack_len - needle_len;
+
+ for (i = 0; i <= len; ++i)
+ {
+ if (!strncasecmp(haystack + i, needle, needle_len))
+ {
+ return haystack + i;
+ }
+ }
+
+ return NULL;
+}
+