shithub: choc

Download patch

ref: 26bafb10f03213a97a0628359265ec865f73fba5
parent: ea89b7c464576a18a8173d7da97d09eff2477edb
author: Simon Howard <fraggle@gmail.com>
date: Mon Feb 8 14:12:23 EST 2010

Add case-insensitive version of strstr(), and use this instead of
strstr() in dehacked code to determine when to map frame numbers.

Subversion-branch: /branches/raven-branch
Subversion-revision: 1861

--- a/src/heretic/deh_thing.c
+++ b/src/heretic/deh_thing.c
@@ -28,6 +28,7 @@
 #include <stdlib.h>
 
 #include "doomtype.h"
+#include "m_misc.h"
 
 #include "deh_defs.h"
 #include "deh_main.h"
@@ -117,7 +118,7 @@
     // undergo transformation from a Heretic 1.0 index to a
     // Heretic 1.3 index.
 
-    if (strstr(variable_name, "frame") != NULL)
+    if (M_StrCaseStr(variable_name, "frame") != NULL)
     {
         ivalue = DEH_MapHereticFrameNumber(ivalue);
     }
--- a/src/heretic/deh_weapon.c
+++ b/src/heretic/deh_weapon.c
@@ -29,6 +29,7 @@
 #include <string.h>
 
 #include "doomtype.h"
+#include "m_misc.h"
 
 #include "doomdef.h"
 
@@ -99,7 +100,7 @@
     // If this is a frame field, we need to map from Heretic 1.0 frame
     // numbers to Heretic 1.3 frame numbers.
 
-    if (strstr(variable_name, "frame") != NULL)
+    if (M_StrCaseStr(variable_name, "frame") != NULL)
     {
         ivalue = DEH_MapHereticFrameNumber(ivalue);
     }
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -255,3 +255,29 @@
     }
 }
 
+//
+// M_StrCaseStr
+//
+// Case-insensitive version of strstr()
+//
+
+char *M_StrCaseStr(char *haystack, char *needle)
+{
+    unsigned int needle_len;
+    unsigned int len;
+    unsigned int i;
+
+    needle_len = strlen(needle);
+    len = strlen(haystack) - needle_len;
+
+    for (i = 0; i <= len; ++i)
+    {
+        if (!strncasecmp(haystack + i, needle, needle_len))
+        {
+            return haystack + i;
+        }
+    }
+
+    return NULL;
+}
+
--- a/src/m_misc.h
+++ b/src/m_misc.h
@@ -42,7 +42,7 @@
 boolean M_StrToInt(const char *str, int *result);
 void M_ExtractFileBase(char *path, char *dest);
 void M_ForceUppercase(char *text);
-
+char *M_StrCaseStr(char *haystack, char *needle);
 
 #endif