diff --git a/Utilities/StrFmt.cpp b/Utilities/StrFmt.cpp index a8c77bcc3d..51ff654c17 100644 --- a/Utilities/StrFmt.cpp +++ b/Utilities/StrFmt.cpp @@ -286,6 +286,15 @@ struct fmt::cfmt_src return 0; } + + static constexpr std::size_t size_char = 1; + static constexpr std::size_t size_short = 2; + static constexpr std::size_t size_int = 0; + static constexpr std::size_t size_long = sizeof(ulong); + static constexpr std::size_t size_llong = sizeof(ullong); + static constexpr std::size_t size_size = sizeof(std::size_t); + static constexpr std::size_t size_max = sizeof(std::uintmax_t); + static constexpr std::size_t size_diff = sizeof(std::ptrdiff_t); }; void fmt::raw_append(std::string& out, const char* fmt, const fmt_type_info* sup, const u64* args) noexcept diff --git a/Utilities/cfmt.h b/Utilities/cfmt.h index 3fe0002d66..90de3c9a06 100644 --- a/Utilities/cfmt.h +++ b/Utilities/cfmt.h @@ -204,11 +204,11 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) else if (fmt[0] == 'h') { fmt++, ctx.size++; - ctx.type = sizeof(char); + ctx.type = src.size_char; } else { - ctx.type = sizeof(short); + ctx.type = src.size_short; } break; @@ -223,11 +223,11 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) else if (fmt[0] == 'l') { fmt++, ctx.size++; - ctx.type = sizeof(llong); + ctx.type = src.size_llong; } else { - ctx.type = sizeof(long); + ctx.type = src.size_long; } break; @@ -241,7 +241,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) } else { - ctx.type = sizeof(std::size_t); + ctx.type = src.size_size; } break; @@ -255,7 +255,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) } else { - ctx.type = sizeof(std::intmax_t); + ctx.type = src.size_max; } break; @@ -269,7 +269,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) } else { - ctx.type = sizeof(std::ptrdiff_t); + ctx.type = src.size_diff; } break; @@ -339,6 +339,11 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) if (!ctx.type) { ctx.type = (u8)src.type(ctx.args); + + if (!ctx.type) + { + ctx.type = src.size_int; + } } // Sign-extended argument expected @@ -396,6 +401,11 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) if (!ctx.type) { ctx.type = (u8)src.type(ctx.args); + + if (!ctx.type) + { + ctx.type = src.size_int; + } } const u64 mask = @@ -447,6 +457,11 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) if (!ctx.type) { ctx.type = (u8)src.type(ctx.args); + + if (!ctx.type) + { + ctx.type = src.size_int; + } } const u64 mask = @@ -505,6 +520,11 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) if (!ctx.type) { ctx.type = (u8)src.type(ctx.args); + + if (!ctx.type) + { + ctx.type = src.size_int; + } } const u64 mask = diff --git a/rpcs3/Emu/Cell/Modules/sys_libc_.cpp b/rpcs3/Emu/Cell/Modules/sys_libc_.cpp index e8e109461a..490eea1abb 100644 --- a/rpcs3/Emu/Cell/Modules/sys_libc_.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_libc_.cpp @@ -42,6 +42,15 @@ struct ps3_fmt_src { return 0; } + + static constexpr std::size_t size_char = 1; + static constexpr std::size_t size_short = 2; + static constexpr std::size_t size_int = 4; + static constexpr std::size_t size_long = 4; + static constexpr std::size_t size_llong = 8; + static constexpr std::size_t size_size = 4; + static constexpr std::size_t size_max = 8; + static constexpr std::size_t size_diff = 4; }; template <>