Skip to content

Commit

Permalink
Fix bool to int logic
Browse files Browse the repository at this point in the history
  • Loading branch information
leo60228 committed Nov 22, 2021
1 parent 333bb73 commit a6a66ae
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions Source/Core/Common/StringUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@
#include <type_traits>
#include <vector>

#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"

#ifndef _WIN32
#include <strings.h>
#endif

#ifdef _MSC_VER
#include <filesystem>
#define HAS_STD_FILESYSTEM
Expand Down Expand Up @@ -60,10 +65,16 @@ bool TryParse(const std::string& str, T* output, int base = 0)
{
char* end_ptr = nullptr;

if (str == "true")
return 1;
else if (str == "false")
return 0;
if (!strcasecmp("true", str.c_str()))
{
*output = static_cast<T>(1);
return true;
}
else if (!strcasecmp("false", str.c_str()))
{
*output = static_cast<T>(0);
return true;
}

// Set errno to a clean slate.
errno = 0;
Expand Down

0 comments on commit a6a66ae

Please sign in to comment.