summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Src/StringUtil.cpp
diff options
context:
space:
mode:
authorGlenn Rice <glennricster@gmail.com>2010-11-10 04:44:25 +0000
committerGlenn Rice <glennricster@gmail.com>2010-11-10 04:44:25 +0000
commit92a5b72b42c2880381826253048a252ef1dad9e1 (patch)
treeb6f2f3901b74109f9fbb6bc5a136c666b8f6c2be /Source/Core/Common/Src/StringUtil.cpp
parent26f84c1e74bd4df5c64edd675c8f89ab252cb052 (diff)
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
Diffstat (limited to 'Source/Core/Common/Src/StringUtil.cpp')
-rw-r--r--Source/Core/Common/Src/StringUtil.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/Source/Core/Common/Src/StringUtil.cpp b/Source/Core/Common/Src/StringUtil.cpp
index 7264085ac7..707d519577 100644
--- a/Source/Core/Common/Src/StringUtil.cpp
+++ b/Source/Core/Common/Src/StringUtil.cpp
@@ -66,15 +66,14 @@ std::string StringFromFormat(const char* format, ...)
writtenCount = vsnprintf(buf, newSize, format, 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)
- writtenCount = -1;
-
- // 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 = writtenCount;
+#else
newSize *= 2;
+#endif
}
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)
{
- if ('1' == str[0] || !stricmp("true", str.c_str()))
+ if ('1' == str[0] || !strcasecmp("true", str.c_str()))
*output = true;
- else if ('0' == str[0] || !stricmp("false", str.c_str()))
+ else if ('0' == str[0] || !strcasecmp("false", str.c_str()))
*output = false;
else
return false;