mirror of
https://github.com/matrix-construct/construct
synced 2024-06-02 18:18:56 +02:00
ircd::fmt: Add missing float alignment policies.
This commit is contained in:
parent
20162fd7d5
commit
0293924544
43
ircd/fmt.cc
43
ircd/fmt.cc
|
@ -1085,7 +1085,7 @@ const
|
|||
bool
|
||||
ircd::fmt::float_specifier::operator()(char *&out,
|
||||
const size_t &max,
|
||||
const spec &s,
|
||||
const spec &spec,
|
||||
const arg &val)
|
||||
const
|
||||
{
|
||||
|
@ -1098,7 +1098,7 @@ const
|
|||
}};
|
||||
|
||||
thread_local uint _precision_;
|
||||
_precision_ = s.precision;
|
||||
_precision_ = spec.precision;
|
||||
|
||||
const auto closure([&](const double &floating)
|
||||
{
|
||||
|
@ -1127,19 +1127,52 @@ const
|
|||
,"floating point real"
|
||||
};
|
||||
|
||||
_r1_type width;
|
||||
_r2_type pad;
|
||||
karma::rule<char *, double(ushort, char)> aligned_left
|
||||
{
|
||||
karma::left_align(width, pad)[rule]
|
||||
,"left aligned"
|
||||
};
|
||||
|
||||
karma::rule<char *, double(ushort, char)> aligned_right
|
||||
{
|
||||
karma::right_align(width, pad)[rule]
|
||||
,"right aligned"
|
||||
};
|
||||
|
||||
karma::rule<char *, double(ushort, char)> aligned_center
|
||||
{
|
||||
karma::center(width, pad)[rule]
|
||||
,"center aligned"
|
||||
};
|
||||
|
||||
generator(): generator::base_type{rule} {}
|
||||
}
|
||||
static const generator;
|
||||
|
||||
static const auto ep
|
||||
{
|
||||
eps[throw_illegal]
|
||||
};
|
||||
|
||||
bool ret;
|
||||
mutable_buffer buf
|
||||
{
|
||||
out, max
|
||||
};
|
||||
|
||||
const auto ret
|
||||
if(!spec.width)
|
||||
ret = fmt::generate(buf, generator | ep, floating);
|
||||
|
||||
else if(spec.sign == '-')
|
||||
{
|
||||
fmt::generate(buf, generator | eps[throw_illegal], floating)
|
||||
};
|
||||
const auto &g(generator.aligned_left(spec.width, spec.pad));
|
||||
ret = fmt::generate(buf, g | ep, floating);
|
||||
} else {
|
||||
const auto &g(generator.aligned_right(spec.width, spec.pad));
|
||||
ret = fmt::generate(buf, g | ep, floating);
|
||||
}
|
||||
|
||||
out = data(buf);
|
||||
return ret;
|
||||
|
|
Loading…
Reference in a new issue