From 196e10bbea8c6692530945a518ab1369cddd4dc3 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Fri, 2 Jan 2015 18:58:55 -0800 Subject: [PATCH 1/3] Don't store the '\0' as part of the string when constructing literals --- Sources/Plasma/CoreLib/plString.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Plasma/CoreLib/plString.h b/Sources/Plasma/CoreLib/plString.h index efad1b0f..536031ea 100644 --- a/Sources/Plasma/CoreLib/plString.h +++ b/Sources/Plasma/CoreLib/plString.h @@ -279,7 +279,7 @@ public: * conversion from ISO-8859-1 8-bit data, use FromIso8859_1(). */ template - plString(const char (&literal)[_Sz]) { IConvertFromUtf8(literal, _Sz); } + plString(const char (&literal)[_Sz]) { IConvertFromUtf8(literal, _Sz - 1); } /** Copy constructor. */ plString(const plString ©) : fUtf8Buffer(copy.fUtf8Buffer) { } @@ -304,7 +304,7 @@ public: /** Assignment operator. Same as plString(const char (&)[_Sz]). */ template - plString &operator=(const char (&literal)[_Sz]) { IConvertFromUtf8(literal, _Sz); return *this; } + plString &operator=(const char (&literal)[_Sz]) { IConvertFromUtf8(literal, _Sz - 1); return *this; } /** Assignment operator. Same as plString(const plString &). */ plString &operator=(const plString ©) { fUtf8Buffer = copy.fUtf8Buffer; return *this; } From 3f39a19d4a7b5b8869dfcdcec579c2f90713c9d2 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Fri, 2 Jan 2015 19:00:45 -0800 Subject: [PATCH 2/3] No need to duplicate this code. --- Sources/Plasma/CoreLib/plFormat.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Sources/Plasma/CoreLib/plFormat.cpp b/Sources/Plasma/CoreLib/plFormat.cpp index 110f9b32..6a67eea5 100644 --- a/Sources/Plasma/CoreLib/plFormat.cpp +++ b/Sources/Plasma/CoreLib/plFormat.cpp @@ -530,9 +530,7 @@ PL_FORMAT_IMPL(const std::string &) PL_FORMAT_IMPL(const std::wstring &) { - plStringBuffer utf8 = plString::FromWchar(value.c_str()).ToUtf8(); - _formatString(format, output, utf8.GetData(), utf8.GetSize(), - plFormat_Private::kAlignLeft); + PL_FORMAT_FORWARD(value.c_str()); } PL_FORMAT_IMPL(bool) From c5f610e3b1937b00034892ee4643a750df1b1241 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Fri, 2 Jan 2015 19:42:35 -0800 Subject: [PATCH 3/3] Fix extra character being reserved in plString::Fill --- Sources/Plasma/CoreLib/plString.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Plasma/CoreLib/plString.cpp b/Sources/Plasma/CoreLib/plString.cpp index 512e7db2..9b179949 100644 --- a/Sources/Plasma/CoreLib/plString.cpp +++ b/Sources/Plasma/CoreLib/plString.cpp @@ -838,7 +838,7 @@ std::vector plString::Split(const char *split, size_t maxSplits) const plString plString::Fill(size_t count, char c) { plStringBuffer buf; - char *data = buf.CreateWritableBuffer(count + 1); + char *data = buf.CreateWritableBuffer(count); memset(data, c, count); data[count] = 0; return buf;