From 9abb5c0e6230af2d21126f1a513406f0802c8a75 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 25 Nov 2022 16:30:11 -0800 Subject: [PATCH] Fix instances of lump searching not being case insensitive --- src/w_wad.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index e81879114..fb828cf81 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1070,16 +1070,11 @@ UINT16 W_CheckNumForMapPwad(const char *name, UINT32 hash, UINT16 wad, UINT16 st UINT16 W_CheckNumForNamePwad(const char *name, UINT16 wad, UINT16 startlump) { UINT16 i; - static char uname[8 + 1]; - UINT32 hash; + UINT32 hash = quickncasehash(name, 8); if (!TestValidLump(wad,0)) return INT16_MAX; - strlcpy(uname, name, sizeof uname); - strupr(uname); - hash = quickncasehash(uname, 8); - // // scan forward // start at 'startlump', useful parameter when there are multiple @@ -1092,7 +1087,7 @@ UINT16 W_CheckNumForNamePwad(const char *name, UINT16 wad, UINT16 startlump) { if (lump_p->hash != hash) continue; - if (strncmp(lump_p->name, uname, sizeof(uname) - 1)) + if (strncasecmp(lump_p->name, name, 8)) continue; return i; } @@ -1111,16 +1106,11 @@ UINT16 W_CheckNumForNamePwad(const char *name, UINT16 wad, UINT16 startlump) UINT16 W_CheckNumForLongNamePwad(const char *name, UINT16 wad, UINT16 startlump) { UINT16 i; - static char uname[256 + 1]; - UINT32 hash; + UINT32 hash = quickncasehash(name, 8); // Not a mistake, legacy system for short lumpnames if (!TestValidLump(wad,0)) return INT16_MAX; - strlcpy(uname, name, sizeof uname); - strupr(uname); - hash = quickncasehash(uname, 8); // Not a mistake, legacy system for short lumpnames - // // scan forward // start at 'startlump', useful parameter when there are multiple @@ -1133,7 +1123,7 @@ UINT16 W_CheckNumForLongNamePwad(const char *name, UINT16 wad, UINT16 startlump) { if (lump_p->hash != hash) continue; - if (strcmp(lump_p->longname, uname)) + if (strcasecmp(lump_p->longname, name)) continue; return i; } @@ -1227,7 +1217,7 @@ lumpnum_t W_CheckNumForName(const char *name) { if (!lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].lumpname[8] && lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].lumphash == hash - && strncmp(lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].lumpname, name, 8) == 0) + && strncasecmp(lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].lumpname, name, 8) == 0) { lumpnumcacheindex = i & (LUMPNUMCACHESIZE - 1); return lumpnumcache[lumpnumcacheindex].lumpnum; @@ -1282,7 +1272,7 @@ lumpnum_t W_CheckNumForLongName(const char *name) for (i = lumpnumcacheindex + LUMPNUMCACHESIZE; i > lumpnumcacheindex; i--) { if (lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].lumphash == hash - && strcmp(lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].lumpname, name) == 0) + && strcasecmp(lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].lumpname, name) == 0) { lumpnumcacheindex = i & (LUMPNUMCACHESIZE - 1); return lumpnumcache[lumpnumcacheindex].lumpnum;