fix some warnings

This commit is contained in:
Megamouse
2023-12-29 18:33:29 +01:00
parent b1c48e66c9
commit 59c58aa3cf
72 changed files with 263 additions and 203 deletions
+11
View File
@@ -50,6 +50,17 @@ namespace cfg
return false;
}
bool _base::save(std::string_view cfg_name) const
{
if (fs::pending_file cfg_file(cfg_name); !!cfg_file.file)
{
cfg_file.file.write(to_string());
return cfg_file.commit();
}
return false;
}
// Emit YAML
static void encode(YAML::Emitter& out, const class _base& rhs);
+2
View File
@@ -101,6 +101,8 @@ namespace cfg
// Set multiple values. Implementation-specific, optional.
virtual bool from_list(std::vector<std::string>&&);
bool save(std::string_view cfg_name) const;
};
// Config tree node which contains another nodes
+7
View File
@@ -227,10 +227,17 @@ namespace fs
{
}
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4646)
#endif
[[noreturn]] stat_t file_base::get_stat()
{
fmt::throw_exception("fs::file::get_stat() not supported.");
}
#ifdef _MSC_VER
#pragma warning(pop)
#endif
void file_base::sync()
{
+4 -2
View File
@@ -495,7 +495,8 @@ namespace fs
{
std::basic_string<T> result;
result.resize(size() / sizeof(T));
if (seek(0), !read(result, result.size(), file, func, line, col)) xfail({line, col, file, func});
seek(0);
if (!read(result, result.size(), file, func, line, col)) xfail({line, col, file, func});
return result;
}
@@ -509,7 +510,8 @@ namespace fs
{
std::vector<T> result;
result.resize(size() / sizeof(T));
if (seek(0), !read(result, result.size(), file, func, line, col)) xfail({line, col, file, func});
seek(0);
if (!read(result, result.size(), file, func, line, col)) xfail({line, col, file, func});
return result;
}
+13 -6
View File
@@ -21,9 +21,10 @@ std::string wchar_to_utf8(std::wstring_view src)
{
#ifdef _WIN32
std::string utf8_string;
const auto tmp_size = WideCharToMultiByte(CP_UTF8, 0, src.data(), src.size(), nullptr, 0, nullptr, nullptr);
const int size = ::narrow<int>(src.size());
const auto tmp_size = WideCharToMultiByte(CP_UTF8, 0, src.data(), size, nullptr, 0, nullptr, nullptr);
utf8_string.resize(tmp_size);
WideCharToMultiByte(CP_UTF8, 0, src.data(), src.size(), utf8_string.data(), tmp_size, nullptr, nullptr);
WideCharToMultiByte(CP_UTF8, 0, src.data(), size, utf8_string.data(), tmp_size, nullptr, nullptr);
return utf8_string;
#else
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> converter{};
@@ -31,7 +32,10 @@ std::string wchar_to_utf8(std::wstring_view src)
#endif
}
#ifndef _MSC_VER
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4996)
#else
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
@@ -46,7 +50,9 @@ std::u16string utf8_to_utf16(std::string_view src)
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> converter{};
return converter.from_bytes(src.data());
}
#ifndef _MSC_VER
#ifdef _MSC_VER
#pragma warning(pop)
#else
#pragma GCC diagnostic pop
#endif
@@ -54,9 +60,10 @@ std::wstring utf8_to_wchar(std::string_view src)
{
#ifdef _WIN32
std::wstring wchar_string;
const auto tmp_size = MultiByteToWideChar(CP_UTF8, 0, src.data(), src.size(), nullptr, 0);
const int size = ::narrow<int>(src.size());
const auto tmp_size = MultiByteToWideChar(CP_UTF8, 0, src.data(), size, nullptr, 0);
wchar_string.resize(tmp_size);
MultiByteToWideChar(CP_UTF8, 0, src.data(), src.size(), wchar_string.data(), tmp_size);
MultiByteToWideChar(CP_UTF8, 0, src.data(), size, wchar_string.data(), tmp_size);
return wchar_string;
#else
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t> converter{};
+2 -2
View File
@@ -1031,12 +1031,12 @@ static usz apply_modification(std::basic_string<u32>& applied, patch_engine::pat
}
case patch_type::utf8:
{
memory_size = p.original_value.size();
memory_size = ::size32(p.original_value);
break;
}
case patch_type::c_utf8:
{
memory_size = utils::add_saturate<u32>(p.original_value.size(), 1);
memory_size = utils::add_saturate<u32>(::size32(p.original_value), 1);
break;
}
case patch_type::move_file: