mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 10:42:36 +01:00
Fmt fix
This commit is contained in:
parent
b61ac15c47
commit
3cd2f735a7
@ -38,67 +38,67 @@ void fmt_class_string<std::vector<char>>::format(std::string& out, u64 arg)
|
|||||||
template<>
|
template<>
|
||||||
void fmt_class_string<char>::format(std::string& out, u64 arg)
|
void fmt_class_string<char>::format(std::string& out, u64 arg)
|
||||||
{
|
{
|
||||||
fmt::append(out, "0x%hhx", static_cast<char>(arg));
|
fmt::append(out, "%#hhx", static_cast<char>(arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void fmt_class_string<uchar>::format(std::string& out, u64 arg)
|
void fmt_class_string<uchar>::format(std::string& out, u64 arg)
|
||||||
{
|
{
|
||||||
fmt::append(out, "0x%hhx", static_cast<uchar>(arg));
|
fmt::append(out, "%#hhx", static_cast<uchar>(arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void fmt_class_string<schar>::format(std::string& out, u64 arg)
|
void fmt_class_string<schar>::format(std::string& out, u64 arg)
|
||||||
{
|
{
|
||||||
fmt::append(out, "0x%hhx", static_cast<schar>(arg));
|
fmt::append(out, "%#hhx", static_cast<schar>(arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void fmt_class_string<short>::format(std::string& out, u64 arg)
|
void fmt_class_string<short>::format(std::string& out, u64 arg)
|
||||||
{
|
{
|
||||||
fmt::append(out, "0x%hx", static_cast<short>(arg));
|
fmt::append(out, "%#hx", static_cast<short>(arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void fmt_class_string<ushort>::format(std::string& out, u64 arg)
|
void fmt_class_string<ushort>::format(std::string& out, u64 arg)
|
||||||
{
|
{
|
||||||
fmt::append(out, "0x%hx", static_cast<ushort>(arg));
|
fmt::append(out, "%#hx", static_cast<ushort>(arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void fmt_class_string<int>::format(std::string& out, u64 arg)
|
void fmt_class_string<int>::format(std::string& out, u64 arg)
|
||||||
{
|
{
|
||||||
fmt::append(out, "0x%x", static_cast<int>(arg));
|
fmt::append(out, "%#x", static_cast<int>(arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void fmt_class_string<uint>::format(std::string& out, u64 arg)
|
void fmt_class_string<uint>::format(std::string& out, u64 arg)
|
||||||
{
|
{
|
||||||
fmt::append(out, "0x%x", static_cast<uint>(arg));
|
fmt::append(out, "%#x", static_cast<uint>(arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void fmt_class_string<long>::format(std::string& out, u64 arg)
|
void fmt_class_string<long>::format(std::string& out, u64 arg)
|
||||||
{
|
{
|
||||||
fmt::append(out, "0x%lx", static_cast<long>(arg));
|
fmt::append(out, "%#lx", static_cast<long>(arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void fmt_class_string<ulong>::format(std::string& out, u64 arg)
|
void fmt_class_string<ulong>::format(std::string& out, u64 arg)
|
||||||
{
|
{
|
||||||
fmt::append(out, "0x%lx", static_cast<ulong>(arg));
|
fmt::append(out, "%#lx", static_cast<ulong>(arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void fmt_class_string<llong>::format(std::string& out, u64 arg)
|
void fmt_class_string<llong>::format(std::string& out, u64 arg)
|
||||||
{
|
{
|
||||||
fmt::append(out, "0x%llx", static_cast<llong>(arg));
|
fmt::append(out, "%#llx", static_cast<llong>(arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void fmt_class_string<ullong>::format(std::string& out, u64 arg)
|
void fmt_class_string<ullong>::format(std::string& out, u64 arg)
|
||||||
{
|
{
|
||||||
fmt::append(out, "0x%llx", static_cast<ullong>(arg));
|
fmt::append(out, "%#llx", static_cast<ullong>(arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
@ -116,7 +116,7 @@ void fmt_class_string<double>::format(std::string& out, u64 arg)
|
|||||||
template<>
|
template<>
|
||||||
void fmt_class_string<bool>::format(std::string& out, u64 arg)
|
void fmt_class_string<bool>::format(std::string& out, u64 arg)
|
||||||
{
|
{
|
||||||
out += arg ? "true" : "false"; // TODO?
|
out += arg ? "true" : "false";
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
@ -166,24 +166,19 @@ struct fmt::cfmt_src
|
|||||||
return out.size() - start;
|
return out.size() - start;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns type size (0 if unknown, pointer, assumed max)
|
// Returns type size (0 if unknown, pointer, unsigned, assumed max)
|
||||||
std::size_t type(std::size_t extra) const
|
std::size_t type(std::size_t extra) const
|
||||||
{
|
{
|
||||||
// Hack: use known function pointers to determine type
|
// Hack: use known function pointers to determine type
|
||||||
#define TYPE(type)\
|
#define TYPE(type)\
|
||||||
if (sup[extra].fmt_string == &fmt_class_string<type>::format) return sizeof(type);
|
if (sup[extra].fmt_string == &fmt_class_string<type>::format) return sizeof(type);
|
||||||
|
|
||||||
TYPE(char);
|
|
||||||
TYPE(schar);
|
|
||||||
TYPE(uchar);
|
|
||||||
TYPE(short);
|
|
||||||
TYPE(ushort);
|
|
||||||
TYPE(int);
|
TYPE(int);
|
||||||
TYPE(uint);
|
|
||||||
TYPE(long);
|
|
||||||
TYPE(ulong);
|
|
||||||
TYPE(llong);
|
TYPE(llong);
|
||||||
TYPE(ullong);
|
TYPE(schar);
|
||||||
|
TYPE(short);
|
||||||
|
if (std::is_signed<char>::value) TYPE(char);
|
||||||
|
TYPE(long);
|
||||||
|
|
||||||
#undef TYPE
|
#undef TYPE
|
||||||
|
|
||||||
|
@ -340,15 +340,15 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
|||||||
ctx.type = (u8)src.type(ctx.args);
|
ctx.type = (u8)src.type(ctx.args);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sign-extended argument expected: no special conversion
|
// Sign-extended argument expected
|
||||||
const u64 val = src.template get<u64>(ctx.args);
|
const u64 val = src.template get<u64>(ctx.args);
|
||||||
const s64 sval = val;
|
const bool negative = ctx.type && static_cast<s64>(val) < 0;
|
||||||
|
|
||||||
const std::size_t start = out.size();
|
const std::size_t start = out.size();
|
||||||
|
|
||||||
if (!ctx.dot || ctx.prec)
|
if (!ctx.dot || ctx.prec)
|
||||||
{
|
{
|
||||||
if (sval < 0)
|
if (negative)
|
||||||
{
|
{
|
||||||
out.push_back('-');
|
out.push_back('-');
|
||||||
}
|
}
|
||||||
@ -361,7 +361,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
|||||||
out.push_back(' ');
|
out.push_back(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
write_decimal(sval < 0 ? 0 - val : val, ctx.prec);
|
write_decimal(negative ? 0 - val : val, ctx.prec);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::size_t size2 = out.size() - start;
|
const std::size_t size2 = out.size() - start;
|
||||||
@ -371,7 +371,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
|||||||
// Add padding if necessary
|
// Add padding if necessary
|
||||||
if (ctx.zeros && !ctx.left && !ctx.dot)
|
if (ctx.zeros && !ctx.left && !ctx.dot)
|
||||||
{
|
{
|
||||||
out.insert(out.begin() + start + (sval < 0 || ctx.sign || ctx.space), ctx.width - size2, '0');
|
out.insert(out.begin() + start + (negative || ctx.sign || ctx.space), ctx.width - size2, '0');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -402,6 +402,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
|||||||
ctx.type == 2 ? 0xffffull :
|
ctx.type == 2 ? 0xffffull :
|
||||||
ctx.type == 4 ? 0xffffffffull : 0xffffffffffffffffull;
|
ctx.type == 4 ? 0xffffffffull : 0xffffffffffffffffull;
|
||||||
|
|
||||||
|
// Trunc sign-extended signed types
|
||||||
const u64 val = src.template get<u64>(ctx.args) & mask;
|
const u64 val = src.template get<u64>(ctx.args) & mask;
|
||||||
|
|
||||||
const std::size_t start = out.size();
|
const std::size_t start = out.size();
|
||||||
@ -452,6 +453,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
|||||||
ctx.type == 2 ? 0xffffull :
|
ctx.type == 2 ? 0xffffull :
|
||||||
ctx.type == 4 ? 0xffffffffull : 0xffffffffffffffffull;
|
ctx.type == 4 ? 0xffffffffull : 0xffffffffffffffffull;
|
||||||
|
|
||||||
|
// Trunc sign-extended signed types
|
||||||
const u64 val = src.template get<u64>(ctx.args) & mask;
|
const u64 val = src.template get<u64>(ctx.args) & mask;
|
||||||
|
|
||||||
const std::size_t start = out.size();
|
const std::size_t start = out.size();
|
||||||
@ -509,6 +511,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
|||||||
ctx.type == 2 ? 0xffffull :
|
ctx.type == 2 ? 0xffffull :
|
||||||
ctx.type == 4 ? 0xffffffffull : 0xffffffffffffffffull;
|
ctx.type == 4 ? 0xffffffffull : 0xffffffffffffffffull;
|
||||||
|
|
||||||
|
// Trunc sign-extended signed types
|
||||||
const u64 val = src.template get<u64>(ctx.args) & mask;
|
const u64 val = src.template get<u64>(ctx.args) & mask;
|
||||||
|
|
||||||
const std::size_t start = out.size();
|
const std::size_t start = out.size();
|
||||||
|
Loading…
Reference in New Issue
Block a user