1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-02-21 20:27:13 +01:00

Fix issue where the command arguments would always fallback to string because the identified variable was not set to true.

Fix issue with boolean argument types where more data then necessary was copied from the argument string which could cause it to fail if anything other than the null terminator was following the boolean argument.
Few other minor adjustments to keep the code style consistent.
This commit is contained in:
Sandu Liviu Catalin 2016-07-14 22:19:10 +03:00
parent 34feeb7903
commit cd6e185d65

View File

@ -695,7 +695,7 @@ bool Controller::Parse(Context & ctx)
// Get the object from the stack and add it to the argument list along with it's type
ctx.mArgv.emplace_back(CMDARG_INTEGER, Var< Object >(DefaultVM::Get(), -1).value);
// We've identified the correct value type
identified = false;
identified = true;
}
}
// Attempt to treat the value as an floating point number if possible
@ -719,7 +719,7 @@ bool Controller::Parse(Context & ctx)
// Get the object from the stack and add it to the argument list along with it's type
ctx.mArgv.emplace_back(CMDARG_FLOAT, Var< Object >(DefaultVM::Get(), -1).value);
// We've identified the correct value type
identified = false;
identified = true;
}
}
@ -728,13 +728,16 @@ bool Controller::Parse(Context & ctx)
{
// Allocate memory for enough data to form a boolean value
CharT lc[6];
// Don't modify the original string or buffer pointer
CStr bptr = lc;
CSStr sptr = str;
// Fill the temporary buffer with data from the internal buffer
std::snprintf(lc, 6, "%.5s", str);
// Convert all characters to lowercase
for (Uint32 i = 0; i < 5; ++i)
for (; sptr < end; ++sptr, ++bptr)
{
lc[i] = std::tolower(lc[i]);
*bptr = std::tolower(*sptr);
}
// Terminate the copied string portion
*bptr = '\0';
// Remember the current stack size
const StackGuard sg;
// Is this a boolean true value?
@ -959,7 +962,7 @@ void Listener::ProcSpec(CSStr str)
else if (*str != ',')
{
// Ignore non-alphabetic characters
while (*str != 0 && !isalpha(*str))
while (*str != '\0' && !std::isalpha(*str))
{
++str;
}