1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-15 22:57:12 +02:00

Updated the exception system in the main plugin to also include the location in the source files in debug builds.

Moved the functions that extract base types from strings as static functions under the associated type.
Revised some of the base shared code.
Fixed some of the functions in the String library that did not take into account the null terminator.
This commit is contained in:
Sandu Liviu Catalin
2016-03-21 22:37:58 +02:00
parent e3315430ea
commit 8088ba94c2
50 changed files with 648 additions and 493 deletions

View File

@ -72,7 +72,7 @@ void AES256::Init(CSStr key)
const Uint32 size = (strlen(key) * sizeof(SQChar));
// See if the key size is accepted
if (size > sizeof(m_Buffer))
SqThrowF("The specified key is out of bounds: %u > %u", size, sizeof(m_Buffer));
STHROWF("The specified key is out of bounds: %u > %u", size, sizeof(m_Buffer));
// Initialize the key buffer to 0
memset(m_Buffer, 0, sizeof(m_Buffer));
// Copy the key into the key buffer

View File

@ -25,7 +25,7 @@ CSStr LeftStr(CSStr t, SQChar f, Uint32 w)
if (!w)
return _SC("");
// Allocate a buffer with the requested width
Buffer b(w);
Buffer b(w + 1); // + null terminator
// Is the specified string valid?
if (!t || *t == 0)
// Insert only the fill character
@ -52,9 +52,9 @@ CSStr LeftStr(CSStr t, SQChar f, Uint32 w, Uint32 o)
return _SC("");
// Is the specified offset within width range?
else if (o > w)
SqThrowF("Offset is out of bounds");
STHROWF("Offset is out of bounds");
// Allocate a buffer with the requested width
Buffer b(w);
Buffer b(w + 1); // + null terminator
// Is the specified string valid?
if (!t || *t == 0)
// Insert only the fill character
@ -81,7 +81,7 @@ CSStr RightStr(CSStr t, SQChar f, Uint32 w)
if (!w)
return _SC("");
// Allocate a buffer with the requested width
Buffer b(w);
Buffer b(w + 1); // + null terminator
// Is the specified string valid?
if (!t || *t == 0)
// Insert only the fill character
@ -111,9 +111,9 @@ CSStr RightStr(CSStr t, SQChar f, Uint32 w, Uint32 o)
return _SC("");
// Is the specified offset within width range?
else if (o > w)
SqThrowF("Offset is out of bounds");
STHROWF("Offset is out of bounds");
// Allocate a buffer with the requested width
Buffer b(w);
Buffer b(w + 1); // + null terminator
// Is the specified string valid?
if (!t || *t == 0)
// Insert only the fill character
@ -143,7 +143,7 @@ CSStr CenterStr(CSStr t, SQChar f, Uint32 w)
if (!w)
return _SC("");
// Allocate a buffer with the requested width
Buffer b(w);
Buffer b(w + 1); // + null terminator
// Is the specified string valid?
if (!t || *t == 0)
// Insert only the fill character
@ -172,13 +172,13 @@ CSStr StrJustAlphaNum(CSStr str)
// Calculate the string length
Uint32 size = strlen(str);
// Obtain a temporary buffer
Buffer b(size);
Buffer b(size + 1); // + null terminator
// Resulted string size
Uint32 n = 0;
// Currently processed character
SQChar c = 0;
// Process characters
while ((c = *(str++)) != 0)
while ((c = *(str++)) != '\0')
{
// Is this an alpha-numeric character?
if (isalnum(c) != 0)
@ -200,13 +200,13 @@ CSStr StrToLowercase(CSStr str)
// Calculate the string length
Uint32 size = strlen(str);
// Obtain a temporary buffer
Buffer b(size);
Buffer b(size + 1); // + null terminator
// Resulted string size
Uint32 n = 0;
// Currently processed character
SQChar c = 0;
// Process characters
while ((c = *(str++)) != 0)
while ((c = *(str++)) != '\0')
// Convert it and move to the next one
b.At(n++) = tolower(c);
// End the resulted string
@ -222,9 +222,9 @@ CSStr StrToUppercase(CSStr str)
if(!str || *str == 0)
return _SC("");
// Calculate the string length
Uint32 size = strlen(str);
Uint32 size = strlen(str); // + null terminator
// Obtain a temporary buffer
Buffer b(size);
Buffer b(size + 1); // + null terminator
// Resulted string size
Uint32 n = 0;
// Currently processed character

View File

@ -360,7 +360,7 @@ SysPath & SysPath::Assign(CSStr path, Style style)
ParseDynamic(path, path + strlen(path));
break;
default:
SqThrowF("Unknown system path style");
STHROWF("Unknown system path style");
}
}
// Allow chaining
@ -394,7 +394,7 @@ SysPath & SysPath::Assign(const Buffer & path, Int32 size)
}
else
{
SqThrowF("The specified path size is out of range: %u >= %u", size, path.Capacity());
STHROWF("The specified path size is out of range: %u >= %u", size, path.Capacity());
}
// Allow chaining
return *this;
@ -434,7 +434,7 @@ SysPath & SysPath::Assign(const Buffer & path, Style style, Int32 size)
ParseDynamic(path.Data(), &path.Cursor());
break;
default:
SqThrowF("Unknown system path style");
STHROWF("Unknown system path style");
}
}
else if (static_cast< Uint32 >(size) < path.Capacity())
@ -462,12 +462,12 @@ SysPath & SysPath::Assign(const Buffer & path, Style style, Int32 size)
ParseDynamic(path.Data(), path.Data() + size);
break;
default:
SqThrowF("Unknown system path style");
STHROWF("Unknown system path style");
}
}
else
{
SqThrowF("The specified path size is out of range: %u >= %u", size, path.Capacity());
STHROWF("The specified path size is out of range: %u >= %u", size, path.Capacity());
}
// Allow chaining
return *this;
@ -528,7 +528,7 @@ SysPath & SysPath::Assign(const String & path, Style style)
ParseDynamic(path.data(), path.data() + path.size());
break;
default:
SqThrowF("Unknown system path style");
STHROWF("Unknown system path style");
}
}
// Allow chaining