Fixed off-by-one error in the TString 'pop' function.
This commit is contained in:
@@ -74,10 +74,10 @@ void TStringPop(char buffer[8], TString* string) {
|
|||||||
if (!string) return;
|
if (!string) return;
|
||||||
if (string->ByteCount == 0) return;
|
if (string->ByteCount == 0) return;
|
||||||
|
|
||||||
for (int i = string->ByteCount; i >= 0; i--) {
|
for (int i = string->ByteCount - 1; i >= 0; i--) {
|
||||||
unsigned int width = GetGlyphByteWidth(string->Characters[i]);
|
unsigned int width = GetGlyphByteWidth(string->Characters[i]);
|
||||||
|
|
||||||
if (width) {
|
if (width > 0) {
|
||||||
//If we've been provided a buffer, then populate it with the glyph we're removing.
|
//If we've been provided a buffer, then populate it with the glyph we're removing.
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
memset(buffer, '\0', 8);
|
memset(buffer, '\0', 8);
|
||||||
@@ -132,6 +132,8 @@ void TStringRemoveRange(int startIndex, int count, TString* string) {
|
|||||||
memcpy(&string->Characters[startByte], buffer, remainder);
|
memcpy(&string->Characters[startByte], buffer, remainder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(&string->Characters[endByte], '\0', string->ByteCount - endByte);
|
||||||
|
|
||||||
string->Length -= glyphCount;
|
string->Length -= glyphCount;
|
||||||
string->ByteCount -= endByte - startByte;
|
string->ByteCount -= endByte - startByte;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user