Linux build fix. stricmp does not exist on linux. Also a small tweak to the StringFromFormat routine.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6368 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
26f84c1e74
commit
92a5b72b42
|
@ -66,15 +66,14 @@ std::string StringFromFormat(const char* format, ...)
|
||||||
writtenCount = vsnprintf(buf, newSize, format, args);
|
writtenCount = vsnprintf(buf, newSize, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
// vsnprintf does not return -1 on truncation in linux!
|
||||||
|
// Instead it returns the size of the string we need.
|
||||||
if (writtenCount >= (int)newSize)
|
if (writtenCount >= (int)newSize)
|
||||||
writtenCount = -1;
|
newSize = writtenCount;
|
||||||
|
#else
|
||||||
// ARGH! vsnprintf does no longer return -1 on truncation in newer libc!
|
|
||||||
// WORKAROUND! let's fake the old behaviour (even though it's less efficient).
|
|
||||||
// TODO: figure out why the fix causes an invalid read in strlen called from vsnprintf :(
|
|
||||||
// if (writtenCount >= (int)newSize)
|
|
||||||
// writtenCount = -1;
|
|
||||||
newSize *= 2;
|
newSize *= 2;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
buf[writtenCount] = '\0';
|
buf[writtenCount] = '\0';
|
||||||
|
@ -152,9 +151,9 @@ bool TryParse(const std::string &str, u32 *const output)
|
||||||
|
|
||||||
bool TryParse(const std::string &str, bool *const output)
|
bool TryParse(const std::string &str, bool *const output)
|
||||||
{
|
{
|
||||||
if ('1' == str[0] || !stricmp("true", str.c_str()))
|
if ('1' == str[0] || !strcasecmp("true", str.c_str()))
|
||||||
*output = true;
|
*output = true;
|
||||||
else if ('0' == str[0] || !stricmp("false", str.c_str()))
|
else if ('0' == str[0] || !strcasecmp("false", str.c_str()))
|
||||||
*output = false;
|
*output = false;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue