diff options
-rw-r--r-- | src/heretic/deh_thing.c | 3 | ||||
-rw-r--r-- | src/heretic/deh_weapon.c | 3 | ||||
-rw-r--r-- | src/m_misc.c | 26 | ||||
-rw-r--r-- | src/m_misc.h | 2 |
4 files changed, 31 insertions, 3 deletions
diff --git a/src/heretic/deh_thing.c b/src/heretic/deh_thing.c index fe94f3b8..ffededf2 100644 --- 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 @@ static void DEH_ThingParseLine(deh_context_t *context, char *line, void *tag) // 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); } diff --git a/src/heretic/deh_weapon.c b/src/heretic/deh_weapon.c index 1daae766..28a90c68 100644 --- 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 @@ static void DEH_WeaponParseLine(deh_context_t *context, char *line, void *tag) // 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); } diff --git a/src/m_misc.c b/src/m_misc.c index 5847f1a2..9d3144b2 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -255,3 +255,29 @@ void M_ForceUppercase(char *text) } } +// +// 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; +} + diff --git a/src/m_misc.h b/src/m_misc.h index c92ddde8..c6be6ccb 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -42,7 +42,7 @@ long M_FileLength(FILE *handle); 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 |