Thanks Alam for letting me know I was messing up!
* Search case is now handled via cvar instead of assumed based on system. * filemenusearch (previously strsystemstr) uses static char[] to prevent stack suffering. * New cvar for searching from start of string instead of anywhere in it! * Menu tweaked for the above. * Reverted slash from pathsep.
This commit is contained in:
parent
72baa4e2d0
commit
ba41d46587
|
@ -720,6 +720,8 @@ void D_RegisterClientCommands(void)
|
||||||
CV_RegisterVar(&cv_addons_folder);
|
CV_RegisterVar(&cv_addons_folder);
|
||||||
CV_RegisterVar(&cv_addons_md5);
|
CV_RegisterVar(&cv_addons_md5);
|
||||||
CV_RegisterVar(&cv_addons_showall);
|
CV_RegisterVar(&cv_addons_showall);
|
||||||
|
CV_RegisterVar(&cv_addons_search_type);
|
||||||
|
CV_RegisterVar(&cv_addons_search_case);
|
||||||
|
|
||||||
// WARNING: the order is important when initialising mouse2
|
// WARNING: the order is important when initialising mouse2
|
||||||
// we need the mouse2port
|
// we need the mouse2port
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
|
||||||
#define SUFFIX "*"
|
#define SUFFIX "*"
|
||||||
#define SLASH PATHSEP
|
#define SLASH "\\"
|
||||||
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||||
|
|
||||||
#ifndef INVALID_FILE_ATTRIBUTES
|
#ifndef INVALID_FILE_ATTRIBUTES
|
||||||
|
@ -319,6 +319,11 @@ consvar_t cv_addons_md5 = {"addons_md5", "Name", CV_SAVE, addons_md5_cons_t, NUL
|
||||||
|
|
||||||
consvar_t cv_addons_showall = {"addons_showall", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_addons_showall = {"addons_showall", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
|
consvar_t cv_addons_search_case = {"addons_search_case", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
|
static CV_PossibleValue_t addons_search_type_cons_t[] = {{0, "Start"}, {1, "Anywhere"}, {0, NULL}};
|
||||||
|
consvar_t cv_addons_search_type = {"addons_search_type", "Anywhere", CV_SAVE, addons_search_type_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
char menupath[1024];
|
char menupath[1024];
|
||||||
size_t menupathindex[menudepth];
|
size_t menupathindex[menudepth];
|
||||||
size_t menudepthleft = menudepth;
|
size_t menudepthleft = menudepth;
|
||||||
|
@ -519,23 +524,19 @@ char exttable[NUM_EXT_TABLE][5] = {
|
||||||
|
|
||||||
char filenamebuf[MAX_WADFILES][MAX_WADPATH];
|
char filenamebuf[MAX_WADFILES][MAX_WADPATH];
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WINDOWS)
|
|
||||||
#define CASEINSENSITIVE_FILESYSTEM
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CASEINSENSITIVE_FILESYSTEM
|
static boolean filemenusearch(char *haystack, char *needle)
|
||||||
static char *strsystemstr(char *haystack, char *needle)
|
|
||||||
{
|
{
|
||||||
char uprhaystack[128];
|
static char localhaystack[128];
|
||||||
strlcpy(uprhaystack, haystack, 128);
|
strlcpy(localhaystack, haystack, 128);
|
||||||
strupr(uprhaystack);
|
if (!cv_addons_search_case.value)
|
||||||
return strstr(uprhaystack, needle);
|
strupr(localhaystack);
|
||||||
|
return ((cv_addons_search_type.value)
|
||||||
|
? (strstr(localhaystack, needle) != 0)
|
||||||
|
: (!strncmp(localhaystack, needle, menusearch[0])));
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
#define strsystemstr(haystack, needle) strstr(haystack, needle)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define searchdir if (menusearch[0] && !strsystemstr(dent->d_name, localmenusearch))\
|
#define searchdir if (menusearch[0] && !filemenusearch(dent->d_name, localmenusearch))\
|
||||||
{\
|
{\
|
||||||
rejected++;\
|
rejected++;\
|
||||||
continue;\
|
continue;\
|
||||||
|
@ -573,9 +574,8 @@ boolean preparefilemenu(boolean samedepth)
|
||||||
if (menusearch[0])
|
if (menusearch[0])
|
||||||
{
|
{
|
||||||
strcpy(localmenusearch, menusearch+1);
|
strcpy(localmenusearch, menusearch+1);
|
||||||
#ifdef CASEINSENSITIVE_FILESYSTEM
|
if (!cv_addons_search_case.value)
|
||||||
strupr(localmenusearch);
|
strupr(localmenusearch);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include "d_netfil.h"
|
#include "d_netfil.h"
|
||||||
#include "m_menu.h" // MAXSTRINGLENGTH
|
#include "m_menu.h" // MAXSTRINGLENGTH
|
||||||
|
|
||||||
extern consvar_t cv_addons_option, cv_addons_folder, cv_addons_md5, cv_addons_showall;
|
extern consvar_t cv_addons_option, cv_addons_folder, cv_addons_md5, cv_addons_showall, cv_addons_search_case, cv_addons_search_type;
|
||||||
|
|
||||||
/** \brief The filesearch function
|
/** \brief The filesearch function
|
||||||
|
|
||||||
|
|
16
src/m_menu.c
16
src/m_menu.c
|
@ -1389,11 +1389,15 @@ static menuitem_t OP_EraseDataMenu[] =
|
||||||
|
|
||||||
static menuitem_t OP_AddonsOptionsMenu[] =
|
static menuitem_t OP_AddonsOptionsMenu[] =
|
||||||
{
|
{
|
||||||
{IT_HEADER, NULL, "Menu", NULL, 0},
|
{IT_HEADER, NULL, "Menu", NULL, 0},
|
||||||
{IT_STRING|IT_CVAR, NULL, "Location", &cv_addons_option, 6},
|
{IT_STRING|IT_CVAR, NULL, "Location", &cv_addons_option, 12},
|
||||||
{IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_addons_folder, 11},
|
{IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_addons_folder, 22},
|
||||||
{IT_STRING|IT_CVAR, NULL, "Identify loaded files via", &cv_addons_md5, 25},
|
{IT_STRING|IT_CVAR, NULL, "Identify loaded files via", &cv_addons_md5, 50},
|
||||||
{IT_STRING|IT_CVAR, NULL, "Show unsupported file types", &cv_addons_showall, 30},
|
{IT_STRING|IT_CVAR, NULL, "Show unsupported file types", &cv_addons_showall, 60},
|
||||||
|
|
||||||
|
{IT_HEADER, NULL, "Search", NULL, 78},
|
||||||
|
{IT_STRING|IT_CVAR, NULL, "Matching", &cv_addons_search_type, 90},
|
||||||
|
{IT_STRING|IT_CVAR, NULL, "Case-sensitive", &cv_addons_search_case, 100},
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -1906,7 +1910,7 @@ menu_t OP_ScreenshotOptionsDef =
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
menu_t OP_AddonsOptionsDef = DEFAULTSCROLLMENUSTYLE("M_ADDONS", OP_AddonsOptionsMenu, &OP_DataOptionsDef, 30, 30);
|
menu_t OP_AddonsOptionsDef = DEFAULTMENUSTYLE("M_ADDONS", OP_AddonsOptionsMenu, &OP_DataOptionsDef, 30, 30);
|
||||||
|
|
||||||
menu_t OP_EraseDataDef = DEFAULTMENUSTYLE("M_DATA", OP_EraseDataMenu, &OP_DataOptionsDef, 60, 30);
|
menu_t OP_EraseDataDef = DEFAULTMENUSTYLE("M_DATA", OP_EraseDataMenu, &OP_DataOptionsDef, 60, 30);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue