From 92a5b72b42c2880381826253048a252ef1dad9e1 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Wed, 10 Nov 2010 04:44:25 +0000 Subject: [PATCH] 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 --- Source/Core/Common/Src/StringUtil.cpp | 17 ++++++++--------- 1 file 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;