SCM: Use std::string.

Those macros may be defined, or not. We should support both cases, so use std::string as it also defines the length of the string.
This commit is contained in:
degasus
2016-05-04 23:47:23 +02:00
parent dbd67c6b06
commit 2030ad4577
11 changed files with 31 additions and 32 deletions

View File

@ -7,13 +7,14 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
// Git version number
extern const char* scm_desc_str;
extern const char* scm_branch_str;
extern const char* scm_rev_str;
extern const char* scm_rev_git_str;
extern const char* netplay_dolphin_ver;
extern const std::string scm_desc_str;
extern const std::string scm_branch_str;
extern const std::string scm_rev_str;
extern const std::string scm_rev_git_str;
extern const std::string netplay_dolphin_ver;
// Force enable logging in the right modes. For some reason, something had changed
// so that debugfast no longer logged.

View File

@ -77,6 +77,7 @@ public:
std::fstream::pos_type start_pos = m_file.tellg();
std::streamoff file_size = end_pos - start_pos;
m_header.Init();
if (m_file.is_open() && ValidateHeader())
{
// good header, read some key/value pairs
@ -180,18 +181,17 @@ private:
struct Header
{
Header()
: key_t_size(sizeof(K))
, value_t_size(sizeof(V))
void Init()
{
// Null-terminator is intentionally not copied.
std::memcpy(&id, "DCAC", sizeof(u32));
std::memcpy(ver, scm_rev_git_str, 40);
std::memcpy(ver, scm_rev_git_str.c_str(), std::min(scm_rev_git_str.size(), sizeof(ver)));
}
u32 id;
const u16 key_t_size, value_t_size;
char ver[40];
const u16 key_t_size = sizeof(K);
const u16 value_t_size = sizeof(V);
char ver[40] = {};
} m_header;

View File

@ -13,7 +13,7 @@
#define BUILD_TYPE_STR ""
#endif
const char* scm_rev_str = "Dolphin "
const std::string scm_rev_str = "Dolphin "
#if !SCM_IS_MASTER
"[" SCM_BRANCH_STR "] "
#endif
@ -25,14 +25,14 @@ const char* scm_rev_str = "Dolphin "
#endif
#ifdef _WIN32
const char* netplay_dolphin_ver = SCM_DESC_STR " Win";
const std::string netplay_dolphin_ver = SCM_DESC_STR " Win";
#elif __APPLE__
const char* netplay_dolphin_ver = SCM_DESC_STR " Mac";
const std::string netplay_dolphin_ver = SCM_DESC_STR " Mac";
#else
const char* netplay_dolphin_ver = SCM_DESC_STR " Lin";
const std::string netplay_dolphin_ver = SCM_DESC_STR " Lin";
#endif
const char* scm_rev_git_str = SCM_REV_STR;
const std::string scm_rev_git_str = SCM_REV_STR;
const char* scm_desc_str = SCM_DESC_STR;
const char* scm_branch_str = SCM_BRANCH_STR;
const std::string scm_desc_str = SCM_DESC_STR;
const std::string scm_branch_str = SCM_BRANCH_STR;