Get rid of stack overflow code because filesystem case insensitivity is Windows exlcusive, so we can just create a wrapper function for there instead of rolling our own.
This commit is contained in:
parent
b2cbbb63c6
commit
afe24bd4f0
|
@ -170,10 +170,6 @@ size_t strlcat(char *dst, const char *src, size_t siz);
|
||||||
size_t strlcpy(char *dst, const char *src, size_t siz);
|
size_t strlcpy(char *dst, const char *src, size_t siz);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 1 // don't know what systems don't have this
|
|
||||||
char* stristr(char* haystack, const char* needle);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Macro for use with char foo[FOOSIZE+1] type buffers.
|
// Macro for use with char foo[FOOSIZE+1] type buffers.
|
||||||
// Never use this with a buffer that is a "char *" or passed
|
// Never use this with a buffer that is a "char *" or passed
|
||||||
// into the function as an argument.
|
// into the function as an argument.
|
||||||
|
|
|
@ -510,7 +510,19 @@ char exttable[NUM_EXT_TABLE][5] = {
|
||||||
|
|
||||||
char filenamebuf[MAX_WADFILES][MAX_WADPATH];
|
char filenamebuf[MAX_WADFILES][MAX_WADPATH];
|
||||||
|
|
||||||
#define searchdir if (menusearch[0] && !stristr(dent->d_name, menusearch+1))\
|
#ifdef _WIN32
|
||||||
|
static char *strsystemstr(char *haystack, char *needle)
|
||||||
|
{
|
||||||
|
char uprhaystack[128];
|
||||||
|
strlcpy(uprhaystack, haystack, 128);
|
||||||
|
strupr(uprhaystack);
|
||||||
|
return strstr(uprhaystack, needle);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define strsystemstr(haystack, needle) strstr(haystack, needle)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define searchdir if (menusearch[0] && !strsystemstr(dent->d_name, localmenusearch))\
|
||||||
{\
|
{\
|
||||||
rejected++;\
|
rejected++;\
|
||||||
continue;\
|
continue;\
|
||||||
|
@ -524,6 +536,7 @@ boolean preparefilemenu(boolean samedepth)
|
||||||
size_t pos = 0, folderpos = 0, numfolders = 0, rejected = 0;
|
size_t pos = 0, folderpos = 0, numfolders = 0, rejected = 0;
|
||||||
char *tempname = NULL;
|
char *tempname = NULL;
|
||||||
boolean noresults = false;
|
boolean noresults = false;
|
||||||
|
char localmenusearch[MAXSTRINGLENGTH] = "";
|
||||||
|
|
||||||
if (samedepth)
|
if (samedepth)
|
||||||
{
|
{
|
||||||
|
@ -544,6 +557,14 @@ boolean preparefilemenu(boolean samedepth)
|
||||||
if (dirhandle == NULL)
|
if (dirhandle == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (menusearch[0])
|
||||||
|
{
|
||||||
|
strcpy(localmenusearch, menusearch+1);
|
||||||
|
#ifdef _WIN32
|
||||||
|
strupr(localmenusearch);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
menupath[menupathindex[menudepthleft]] = 0;
|
menupath[menupathindex[menudepthleft]] = 0;
|
||||||
|
@ -651,7 +672,7 @@ boolean preparefilemenu(boolean samedepth)
|
||||||
filenamebuf[i][MAX_WADPATH - 1] = '\0';
|
filenamebuf[i][MAX_WADPATH - 1] = '\0';
|
||||||
nameonly(filenamebuf[i]);
|
nameonly(filenamebuf[i]);
|
||||||
}
|
}
|
||||||
if (strcasecmp(dent->d_name, filenamebuf[i]))
|
if (strcmp(dent->d_name, filenamebuf[i]))
|
||||||
continue;
|
continue;
|
||||||
if (checkfilemd5(menupath, wadfiles[i]->md5sum))
|
if (checkfilemd5(menupath, wadfiles[i]->md5sum))
|
||||||
ext |= EXT_LOADED;
|
ext |= EXT_LOADED;
|
||||||
|
|
38
src/string.c
38
src/string.c
|
@ -50,41 +50,3 @@ size_t strlcpy(char *dst, const char *src, size_t siz)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 1 // i don't know what specific OSes are missing this, oh well
|
|
||||||
|
|
||||||
// stack overflow, eep...
|
|
||||||
char* stristr(char* haystack, const char* needle)
|
|
||||||
{
|
|
||||||
char* p1 = haystack;
|
|
||||||
const char* p2 = needle;
|
|
||||||
char* r = ((*p2 == 0) ? haystack : 0);
|
|
||||||
|
|
||||||
while (*p1 != 0 && *p2 != 0)
|
|
||||||
{
|
|
||||||
if (tolower(*p1) == tolower(*p2))
|
|
||||||
{
|
|
||||||
if (r == 0)
|
|
||||||
r = p1;
|
|
||||||
|
|
||||||
p2++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
p2 = needle;
|
|
||||||
if (tolower(*p1) == tolower(*p2))
|
|
||||||
{
|
|
||||||
r = p1;
|
|
||||||
p2++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
r = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
p1++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ((*p2 == 0) ? r : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue