From ef27cf3c5f36d1ab48e04e832163a4c49bc27f0b Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Sun, 3 Apr 2016 21:26:58 +0300 Subject: [PATCH] Update the SToB function to convert the string to lowercase first and then perform the comparison. --- source/Base/Shared.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/source/Base/Shared.cpp b/source/Base/Shared.cpp index 1f1c3c72..91524963 100644 --- a/source/Base/Shared.cpp +++ b/source/Base/Shared.cpp @@ -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; } // ------------------------------------------------------------------------------------------------