SDL: fix crash with fm2 and fcm->fcm conversion
This commit is contained in:
parent
7836d6254e
commit
5d95228971
|
@ -1,4 +1,5 @@
|
|||
---version 2.0.4 yet to be released---
|
||||
28-mar-2009 - shinydoofy - sdl - fix fm2 playback and fcm->fm2 conversion crash at the cost of ugly 0x00 bytes behind the author's comment line
|
||||
28-mar-2009 - adelikat - Lua - added FCEU.poweron() and FCEU.softreset()
|
||||
27-mar-2009 - shinydoofy - sdl - added --no-config
|
||||
23-mar-2009 - adelikat - Win32 - blocked "hotkey explosion" by rshift on some laptops
|
||||
|
|
|
@ -585,38 +585,35 @@ namespace UtfConverter
|
|||
size_t widesize = utf8string.length();
|
||||
if (sizeof(wchar_t) == 2)
|
||||
{
|
||||
wchar_t* widestringnative = new wchar_t[widesize+1];
|
||||
std::wstring resultstring;
|
||||
resultstring.resize(widesize+1, L'\0');
|
||||
const UTF8* sourcestart = reinterpret_cast<const UTF8*>(utf8string.c_str());
|
||||
const UTF8* sourceend = sourcestart + widesize;
|
||||
UTF16* targetstart = reinterpret_cast<UTF16*>(widestringnative);
|
||||
UTF16* targetend = targetstart + widesize+1;
|
||||
UTF16* targetstart = reinterpret_cast<UTF16*>(&resultstring[0]);
|
||||
UTF16* targetend = targetstart + widesize;
|
||||
ConversionResult res = ConvertUTF8toUTF16(&sourcestart, sourceend, &targetstart, targetend, strictConversion);
|
||||
if (res != conversionOK)
|
||||
{
|
||||
delete [] widestringnative;
|
||||
throw std::exception();
|
||||
}
|
||||
*targetstart = 0;
|
||||
std::wstring resultstring(widestringnative);
|
||||
delete [] widestringnative;
|
||||
return resultstring;
|
||||
}
|
||||
else if (sizeof(wchar_t) == 4)
|
||||
{
|
||||
wchar_t* widestringnative = new wchar_t[widesize];
|
||||
std::wstring resultstring;
|
||||
resultstring.resize(widesize+1, L'\0');
|
||||
const UTF8* sourcestart = reinterpret_cast<const UTF8*>(utf8string.c_str());
|
||||
const UTF8* sourceend = sourcestart + widesize;
|
||||
UTF32* targetstart = reinterpret_cast<UTF32*>(widestringnative);
|
||||
UTF32* targetstart = reinterpret_cast<UTF32*>(&resultstring[0]);
|
||||
UTF32* targetend = targetstart + widesize;
|
||||
ConversionResult res = ConvertUTF8toUTF32(&sourcestart, sourceend, &targetstart, targetend, strictConversion);
|
||||
if (res != conversionOK)
|
||||
{
|
||||
delete [] widestringnative;
|
||||
throw std::exception();
|
||||
}
|
||||
*targetstart = 0;
|
||||
std::wstring resultstring(widestringnative);
|
||||
delete [] widestringnative;
|
||||
resultstring = resultstring.substr(0, 23);
|
||||
return resultstring;
|
||||
}
|
||||
else
|
||||
|
@ -633,39 +630,35 @@ namespace UtfConverter
|
|||
if (sizeof(wchar_t) == 2)
|
||||
{
|
||||
size_t utf8size = 3 * widesize + 1;
|
||||
char* utf8stringnative = new char[utf8size];
|
||||
std::string resultstring;
|
||||
resultstring.resize(utf8size, '\0');
|
||||
const UTF16* sourcestart = reinterpret_cast<const UTF16*>(widestring.c_str());
|
||||
const UTF16* sourceend = sourcestart + widesize;
|
||||
UTF8* targetstart = reinterpret_cast<UTF8*>(utf8stringnative);
|
||||
UTF8* targetstart = reinterpret_cast<UTF8*>(&resultstring[0]);
|
||||
UTF8* targetend = targetstart + utf8size;
|
||||
ConversionResult res = ConvertUTF16toUTF8(&sourcestart, sourceend, &targetstart, targetend, strictConversion);
|
||||
if (res != conversionOK)
|
||||
{
|
||||
delete [] utf8stringnative;
|
||||
throw std::exception();
|
||||
}
|
||||
*targetstart = 0;
|
||||
std::string resultstring(utf8stringnative);
|
||||
delete [] utf8stringnative;
|
||||
return resultstring;
|
||||
}
|
||||
else if (sizeof(wchar_t) == 4)
|
||||
{
|
||||
size_t utf8size = 4 * widesize + 1;
|
||||
char* utf8stringnative = new char[utf8size];
|
||||
std::string resultstring;
|
||||
resultstring.resize(utf8size, '\0');
|
||||
const UTF32* sourcestart = reinterpret_cast<const UTF32*>(widestring.c_str());
|
||||
const UTF32* sourceend = sourcestart + widesize;
|
||||
UTF8* targetstart = reinterpret_cast<UTF8*>(utf8stringnative);
|
||||
UTF8* targetstart = reinterpret_cast<UTF8*>(&resultstring[0]);
|
||||
UTF8* targetend = targetstart + utf8size;
|
||||
ConversionResult res = ConvertUTF32toUTF8(&sourcestart, sourceend, &targetstart, targetend, strictConversion);
|
||||
if (res != conversionOK)
|
||||
{
|
||||
delete [] utf8stringnative;
|
||||
throw std::exception();
|
||||
}
|
||||
*targetstart = 0;
|
||||
std::string resultstring(utf8stringnative);
|
||||
delete [] utf8stringnative;
|
||||
return resultstring;
|
||||
}
|
||||
else
|
||||
|
@ -705,4 +698,4 @@ std::string getExtension(const char* input) {
|
|||
for(k=0;k<extlen;k++)
|
||||
ext[k]=tolower(ext[k]);
|
||||
return ext;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue