1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Update the SToB function to convert the string to lowercase first and then perform the comparison.

This commit is contained in:
Sandu Liviu Catalin 2016-04-03 21:26:58 +03:00
parent 6f4ea3b06d
commit ef27cf3c5f

View File

@ -187,8 +187,20 @@ StackStrF::~StackStrF()
// ------------------------------------------------------------------------------------------------
bool SToB(CSStr str)
{
return (strcmp(str, "true") == 0 || strcmp(str, "yes") == 0 ||
strcmp(str, "on") == 0 || strcmp(str, "1") == 0) ? true : false;
// Temporary buffer to store the lowercase string
SQChar buffer[8];
// The currently processed character
unsigned i = 0;
// Convert only the necessary characters to lowercase
while (i < 8 && *str != '\0')
{
buffer[i++] = static_cast< SQChar >(std::tolower(*(str++)));
}
// Add the null terminator
buffer[i] = '\0';
// Compare the lowercase string and return the result
return (std::strcmp(buffer, "true") == 0 || std::strcmp(buffer, "yes") == 0 ||
std::strcmp(buffer, "on") == 0 || std::strcmp(buffer, "1") == 0) ? true : false;
}
// ------------------------------------------------------------------------------------------------