1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 10:42:36 +01:00

cfmt improved

This commit is contained in:
Nekotekina 2017-05-16 14:29:07 +03:00
parent bd8dfac713
commit d5107aab47
3 changed files with 45 additions and 7 deletions

View File

@ -286,6 +286,15 @@ struct fmt::cfmt_src
return 0; 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 void fmt::raw_append(std::string& out, const char* fmt, const fmt_type_info* sup, const u64* args) noexcept

View File

@ -204,11 +204,11 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
else if (fmt[0] == 'h') else if (fmt[0] == 'h')
{ {
fmt++, ctx.size++; fmt++, ctx.size++;
ctx.type = sizeof(char); ctx.type = src.size_char;
} }
else else
{ {
ctx.type = sizeof(short); ctx.type = src.size_short;
} }
break; break;
@ -223,11 +223,11 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
else if (fmt[0] == 'l') else if (fmt[0] == 'l')
{ {
fmt++, ctx.size++; fmt++, ctx.size++;
ctx.type = sizeof(llong); ctx.type = src.size_llong;
} }
else else
{ {
ctx.type = sizeof(long); ctx.type = src.size_long;
} }
break; break;
@ -241,7 +241,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
} }
else else
{ {
ctx.type = sizeof(std::size_t); ctx.type = src.size_size;
} }
break; break;
@ -255,7 +255,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
} }
else else
{ {
ctx.type = sizeof(std::intmax_t); ctx.type = src.size_max;
} }
break; break;
@ -269,7 +269,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
} }
else else
{ {
ctx.type = sizeof(std::ptrdiff_t); ctx.type = src.size_diff;
} }
break; break;
@ -339,6 +339,11 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
if (!ctx.type) if (!ctx.type)
{ {
ctx.type = (u8)src.type(ctx.args); ctx.type = (u8)src.type(ctx.args);
if (!ctx.type)
{
ctx.type = src.size_int;
}
} }
// Sign-extended argument expected // Sign-extended argument expected
@ -396,6 +401,11 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
if (!ctx.type) if (!ctx.type)
{ {
ctx.type = (u8)src.type(ctx.args); ctx.type = (u8)src.type(ctx.args);
if (!ctx.type)
{
ctx.type = src.size_int;
}
} }
const u64 mask = const u64 mask =
@ -447,6 +457,11 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
if (!ctx.type) if (!ctx.type)
{ {
ctx.type = (u8)src.type(ctx.args); ctx.type = (u8)src.type(ctx.args);
if (!ctx.type)
{
ctx.type = src.size_int;
}
} }
const u64 mask = const u64 mask =
@ -505,6 +520,11 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
if (!ctx.type) if (!ctx.type)
{ {
ctx.type = (u8)src.type(ctx.args); ctx.type = (u8)src.type(ctx.args);
if (!ctx.type)
{
ctx.type = src.size_int;
}
} }
const u64 mask = const u64 mask =

View File

@ -42,6 +42,15 @@ struct ps3_fmt_src
{ {
return 0; 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 <> template <>