- Use case insensitive search when checking for existing script names, since they're case

insensitive in the engine.

SVN r3366 (trunk)
This commit is contained in:
Randy Heit 2012-02-16 22:18:01 +00:00
parent c99a7cf35e
commit c10009b525
3 changed files with 45 additions and 1 deletions

View file

@ -560,7 +560,7 @@ static void OuterScript(void)
}
else if(tk_Token == TK_STRING)
{ // Named scripts start counting at -1 and go down from there.
scriptNumber = -1 - STR_FindInList(STRLIST_NAMEDSCRIPTS, tk_String);
scriptNumber = -1 - STR_FindInListInsensitive(STRLIST_NAMEDSCRIPTS, tk_String);
TK_NextToken();
}
else

View file

@ -17,6 +17,10 @@
// MACROS ------------------------------------------------------------------
#ifdef _WIN32
#define strcasecmp stricmp
#endif
// TYPES -------------------------------------------------------------------
typedef struct
@ -45,6 +49,7 @@ typedef struct
static int STR_PutStringInSomeList(stringList_t *list, int index, char *name);
static int STR_FindInSomeList(stringList_t *list, char *name);
static int STR_FindInSomeListInsensitive(stringList_t *list, char *name);
static void DumpStrings(stringList_t *list, int lenadr, boolean quad, boolean crypt);
static void Encrypt(void *data, int key, int len);
@ -175,6 +180,44 @@ static int STR_FindInSomeList(stringList_t *list, char *name)
return STR_PutStringInSomeList(list, i, name);
}
//==========================================================================
//
// STR_FindInListInsensitive
//
//==========================================================================
int STR_FindInListInsensitive(int list, char *name)
{
if (StringLists[list] == NULL)
{
StringLists[list] = MS_Alloc(sizeof(stringList_t), ERR_OUT_OF_MEMORY);
StringLists[list]->stringCount = 0;
NumStringLists++;
}
return STR_FindInSomeListInsensitive (StringLists[list], name);
}
//==========================================================================
//
// STR_FindInSomeListInsensitive
//
//==========================================================================
static int STR_FindInSomeListInsensitive(stringList_t *list, char *name)
{
int i;
for(i = 0; i < list->stringCount; i++)
{
if(strcasecmp(list->strings[i].name, name) == 0)
{
return i;
}
}
// Add to list
return STR_PutStringInSomeList(list, i, name);
}
//==========================================================================
//
// STR_GetString

View file

@ -25,6 +25,7 @@ void STR_WriteList(void);
int STR_FindLanguage(char *name);
int STR_FindInLanguage(int language, char *name);
int STR_FindInList(int list, char *name);
int STR_FindInListInsensitive(int list, char *name);
int STR_AppendToList(int list, char *name);
const char *STR_GetString(int list, int index);
void STR_WriteChunk(int language, boolean encrypt);