1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-17 10:52:46 +00:00

Some cleanup and a vararg plString usage fix

This commit is contained in:
2012-11-12 22:43:32 -08:00
parent 9cc3f404af
commit 075c535e2c
13 changed files with 28 additions and 14 deletions

View File

@ -366,7 +366,7 @@ char * hsFormatStr(const char * fmt, ...); // You are responsible for returned
char * hsFormatStrV(const char * fmt, va_list args); // You are responsible for returned memory.
// Use "correct" stricmp based on the selected compiler / library
#if HS_BUILD_FOR_WIN32
#if _MSC_VER
# define stricmp _stricmp
# define strnicmp _strnicmp
# define wcsicmp _wcsicmp

View File

@ -45,6 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <cstring>
#include <cstdlib>
#include <wchar.h>
#include <memory>
const plString plString::Null;
@ -93,10 +94,17 @@ void plString::IConvertFromUtf8(const char *utf8, size_t size)
if ((int32_t)size < 0)
size = strnlen(utf8, -(int32_t)size);
operator=(plStringBuffer<char>(utf8, size));
}
plString &plString::operator=(const plStringBuffer<char> &init)
{
fUtf8Buffer = init;
#ifdef _DEBUG
// Check to make sure the string is actually valid UTF-8
const char *sp = utf8;
while (sp < utf8 + size) {
const char *sp = fUtf8Buffer.GetData();
while (sp < fUtf8Buffer.GetData() + fUtf8Buffer.GetSize()) {
unsigned char unichar = *sp++;
if ((unichar & 0xF8) == 0xF0) {
// Four bytes
@ -118,7 +126,7 @@ void plString::IConvertFromUtf8(const char *utf8, size_t size)
}
#endif
fUtf8Buffer = plStringBuffer<char>(utf8, size);
return *this;
}
void plString::IConvertFromUtf16(const uint16_t *utf16, size_t size)

View File

@ -45,7 +45,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include <stddef.h>
#include <vector>
/* NOTE & TODO:
* These macros are intentionally annoyingly named, to mark what code
@ -177,10 +176,12 @@ public:
//plString(const char *utf8) { IConvertFromUtf8(utf8, kSizeAuto, false); }
//plString(const wchar_t *wstr) { IConvertFromWchar(wstr, kSizeAuto); }
plString(const plString &copy) : fUtf8Buffer(copy.fUtf8Buffer) { }
plString(const plStringBuffer<char> &init) { operator=(init); }
//plString &operator=(const char *utf8) { IConvertFromUtf8(utf8, kSizeAuto, false); return *this; }
//plString &operator=(const wchar_t *wstr) { IConvertFromWchar(wstr, kSizeAuto); return *this; }
plString &operator=(const plString &copy) { fUtf8Buffer = copy.fUtf8Buffer; return *this; }
plString &operator=(const plStringBuffer<char> &init);
plString &operator+=(const plString &str) { return operator=(*this + str); }