add TextIsEqualCase and use in IsFileExtension

This commit is contained in:
MyLegGuy 2020-01-03 23:07:05 -05:00
parent c20ccfe274
commit 6885f53fbb
No known key found for this signature in database
GPG Key ID: 4AC4E4C143A94169
3 changed files with 19 additions and 1 deletions

View File

@ -1845,7 +1845,7 @@ bool IsFileExtension(const char *fileName, const char *ext)
for (int i = 0; i < extCount; i++)
{
if (strcmp(fileExt, checkExts[i] + 1) == 0)
if (TextIsEqualCase(fileExt, checkExts[i] + 1))
{
result = true;
break;

View File

@ -1196,6 +1196,7 @@ RLAPI int GetGlyphIndex(Font font, int codepoint);
// Text strings management functions (no utf8 strings, only byte chars)
// NOTE: Some strings allocate memory internally for returned strings, just be careful!
RLAPI bool TextIsEqual(const char *text1, const char *text2); // Check if two text string are equal
RLAPI bool TextIsEqualCase(const char *text1, const char *text2); // Check if two text strings are equal ignoring case
RLAPI unsigned int TextLength(const char *text); // Get text length, checks for '\0' ending
RLAPI const char *TextFormat(const char *text, ...); // Text formatting with variables (sprintf style)
RLAPI const char *TextSubtext(const char *text, int position, int length); // Get a piece of a text string

View File

@ -1108,6 +1108,23 @@ bool TextIsEqual(const char *text1, const char *text2)
return result;
}
// Check if two text string are equal ignoring case
// REQUIRES: tolower()
bool TextIsEqualCase(const char *text1, const char *text2)
{
bool result = false;
while (tolower((unsigned char)(*text1)) == tolower((unsigned char)(*text2++)))
{
if(*text1++ == '\0')
{
result = true;
break;
}
}
return result;
}
// Get text length in bytes, check for \0 character
unsigned int TextLength(const char *text)