Minor fixes
This was SVN commit r2625.
This commit is contained in:
parent
b4ad393ee4
commit
a10082d69b
@ -12,9 +12,6 @@
|
||||
#include "UnitManager.h"
|
||||
#include "Unit.h"
|
||||
|
||||
#include "ps/Xeromyces.h"
|
||||
#include "ps/XMLWriter.h"
|
||||
|
||||
#include "lib/res/file/vfs.h"
|
||||
|
||||
#include <sstream>
|
||||
|
@ -18,10 +18,10 @@
|
||||
|
||||
|
||||
// Only include these function definitions in the first instance of CStr.cpp:
|
||||
|
||||
CStrW::CStrW(const CStr8 &asciStr) : std::wstring(asciStr.begin(), asciStr.end()) {}
|
||||
CStr8::CStr8(const CStrW &wideStr) : std:: string(wideStr.begin(), wideStr.end()) {}
|
||||
|
||||
|
||||
// UTF conversion code adapted from http://www.unicode.org/Public/PROGRAMS/CVTUTF/ConvertUTF.c
|
||||
|
||||
static const unsigned char firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
|
||||
@ -130,8 +130,41 @@ CStrW CStr8::FromUTF8() const
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// built-in self test
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#if PERFORM_SELF_TEST
|
||||
namespace test {
|
||||
|
||||
static void test1()
|
||||
{
|
||||
const wchar_t chr_utf16[] = { 0x12, 0xff, 0x1234, 0x3456, 0x5678, 0x7890, 0x9abc, 0xbcde, 0xfffe };
|
||||
const unsigned char chr_utf8[] = { 0x12, 0xc3, 0xbf, 0xe1, 0x88, 0xb4, 0xe3, 0x91, 0x96, 0xe5, 0x99, 0xb8, 0xe7, 0xa2, 0x90, 0xe9, 0xaa, 0xbc, 0xeb, 0xb3, 0x9e, 0xef, 0xbf, 0xbe };
|
||||
CStrW str_utf16 (chr_utf16, sizeof(chr_utf16)/sizeof(wchar_t));
|
||||
CStr8 str_utf8 = str_utf16.ToUTF8();
|
||||
debug_assert(str_utf8.length() == sizeof(chr_utf8));
|
||||
debug_assert(memcmp(str_utf8.data(), chr_utf8, sizeof(chr_utf8)) == 0);
|
||||
debug_assert(str_utf8.FromUTF8() == str_utf16);
|
||||
}
|
||||
|
||||
|
||||
static int run_tests()
|
||||
{
|
||||
test1();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dummy = run_tests();
|
||||
|
||||
} // namespace test
|
||||
#endif // #if PERFORM_SELF_TEST
|
||||
|
||||
|
||||
#else
|
||||
|
||||
// The following code is compiled twice, as CStrW then as CStr8:
|
||||
|
||||
#include "CStr.h"
|
||||
using namespace std;
|
||||
|
||||
@ -585,37 +618,4 @@ uint CStr::GetSerializedLength() const
|
||||
#undef _totlower
|
||||
#undef _totupper
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// built-in self test
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#if PERFORM_SELF_TEST
|
||||
namespace test {
|
||||
|
||||
static void test1()
|
||||
{
|
||||
const wchar_t chr_utf16[] = { 0x12, 0xff, 0x1234, 0x3456, 0x5678, 0x7890, 0x9abc, 0xbcde, 0xfffe };
|
||||
const unsigned char chr_utf8[] = { 0x12, 0xc3, 0xbf, 0xe1, 0x88, 0xb4, 0xe3, 0x91, 0x96, 0xe5, 0x99, 0xb8, 0xe7, 0xa2, 0x90, 0xe9, 0xaa, 0xbc, 0xeb, 0xb3, 0x9e, 0xef, 0xbf, 0xbe };
|
||||
CStrW str_utf16 (chr_utf16, sizeof(chr_utf16)/sizeof(wchar_t));
|
||||
CStr8 str_utf8 = str_utf16.ToUTF8();
|
||||
debug_assert(str_utf8.length() == sizeof(chr_utf8));
|
||||
debug_assert(memcmp(str_utf8.data(), chr_utf8, sizeof(chr_utf8)) == 0);
|
||||
debug_assert(str_utf8.FromUTF8() == str_utf16);
|
||||
}
|
||||
|
||||
|
||||
static int run_tests()
|
||||
{
|
||||
test1();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dummy = run_tests();
|
||||
|
||||
} // namespace test
|
||||
#endif // #if PERFORM_SELF_TEST
|
||||
|
||||
|
||||
#endif // CStr_CPP_FIRST
|
||||
|
@ -71,4 +71,4 @@ CWorld::~CWorld()
|
||||
void CWorld::RewriteMap()
|
||||
{
|
||||
CMapWriter::RewriteAllMaps(&m_Terrain, &m_UnitManager, &g_LightEnv);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user