VERY experimental Nintendo Switch 2 emulator
C++
Removed uses of raw c-string manipulation functions.
archshift7fa4dbd0c6e8
diff --git a/src/common/emu_window.h b/src/common/emu_window.hindex 34cecb40bc..4d09acb8b1 100644--- a/src/common/emu_window.h+++ b/src/common/emu_window.h@@ -6,7 +6,7 @@#include "common/common.h"#include "common/scm_rev.h"-+#include "common/string_util.h"#include "common/key_map.h"// Abstraction class used to provide an interface between emulation code and the frontend (e.g. SDL,@@ -75,11 +75,11 @@ public:}protected:- EmuWindow() : m_client_area_width(640), m_client_area_height(480) {- char window_title[255];- sprintf(window_title, "Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc);- m_window_title = window_title;- }+ EmuWindow():+ m_client_area_width(640),+ m_client_area_height(480),+ m_window_title(Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc))+ {}virtual ~EmuWindow() {}std::string m_window_title; ///< Current window title, should be used by window impl.diff --git a/src/common/string_util.cpp b/src/common/string_util.cppindex 9199e30bce..61f0939c4b 100644--- a/src/common/string_util.cpp+++ b/src/common/string_util.cpp@@ -186,9 +186,9 @@ bool TryParse(const std::string &str, u32 *const output)bool TryParse(const std::string &str, bool *const output){- if ("1" == str || !strcasecmp("true", str.c_str()))+ if ("1" == str || "true" == ToLower(str))*output = true;- else if ("0" == str || !strcasecmp("false", str.c_str()))+ else if ("0" == str || "false" == ToLower(str))*output = false;elsereturn false;@@ -196,13 +196,6 @@ bool TryParse(const std::string &str, bool *const output)return true;}-std::string StringFromInt(int value)-{- char temp[16];- sprintf(temp, "%i", value);- return temp;-}-std::string StringFromBool(bool value){return value ? "True" : "False";diff --git a/src/common/string_util.h b/src/common/string_util.hindex 16ce39bc1d..a41ccc6916 100644--- a/src/common/string_util.h+++ b/src/common/string_util.h@@ -54,7 +54,6 @@ std::string ThousandSeparate(I value, int spaces = 0)return oss.str();}-std::string StringFromInt(int value);std::string StringFromBool(bool value);bool TryParse(const std::string &str, bool *output);diff --git a/src/common/timer.cpp b/src/common/timer.cppindex f8e1fadca2..ded4a344e5 100644--- a/src/common/timer.cpp+++ b/src/common/timer.cpp@@ -169,7 +169,6 @@ std::string Timer::GetTimeFormatted(){time_t sysTime;struct tm * gmTime;- char formattedTime[13];char tmp[13];time(&sysTime);@@ -181,14 +180,12 @@ std::string Timer::GetTimeFormatted()#ifdef _WIN32struct timeb tp;(void)::ftime(&tp);- sprintf(formattedTime, "%s:%03i", tmp, tp.millitm);+ return StringFromFormat("%s:%03i", tmp, tp.millitm);#elsestruct timeval t;(void)gettimeofday(&t, NULL);- sprintf(formattedTime, "%s:%03d", tmp, (int)(t.tv_usec / 1000));+ return StringFromFormat("%s:%03d", tmp, (int)(t.tv_usec / 1000));#endif-- return std::string(formattedTime);}// Returns a timestamp with decimals for precise time comparisons