mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-05 02:27:45 +00:00
Avoid magic constants
This commit is contained in:
parent
17960dd3d3
commit
316b05cf34
12
format.cc
12
format.cc
@ -444,16 +444,16 @@ class BasicArgFormatter : public ArgVisitor<Impl, void> {
|
|||||||
typedef typename BasicWriter<Char>::CharPtr CharPtr;
|
typedef typename BasicWriter<Char>::CharPtr CharPtr;
|
||||||
Char fill = internal::CharTraits<Char>::cast(spec_.fill());
|
Char fill = internal::CharTraits<Char>::cast(spec_.fill());
|
||||||
CharPtr out = CharPtr();
|
CharPtr out = CharPtr();
|
||||||
if (spec_.width_ > 1) {
|
enum { CHAR_WIDTH = 1 };
|
||||||
|
if (spec_.width_ > CHAR_WIDTH) {
|
||||||
out = writer_.grow_buffer(spec_.width_);
|
out = writer_.grow_buffer(spec_.width_);
|
||||||
if (spec_.align_ == ALIGN_RIGHT) {
|
if (spec_.align_ == ALIGN_RIGHT) {
|
||||||
std::fill_n(out, spec_.width_ - 1, fill);
|
std::fill_n(out, spec_.width_ - CHAR_WIDTH, fill);
|
||||||
out += spec_.width_ - 1;
|
out += spec_.width_ - CHAR_WIDTH;
|
||||||
} else if (spec_.align_ == ALIGN_CENTER) {
|
} else if (spec_.align_ == ALIGN_CENTER) {
|
||||||
// coverity[suspicious_sizeof]
|
out = writer_.fill_padding(out, spec_.width_, CHAR_WIDTH, fill);
|
||||||
out = writer_.fill_padding(out, spec_.width_, 1, fill);
|
|
||||||
} else {
|
} else {
|
||||||
std::fill_n(out + 1, spec_.width_ - 1, fill);
|
std::fill_n(out + CHAR_WIDTH, spec_.width_ - CHAR_WIDTH, fill);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
out = writer_.grow_buffer(1);
|
out = writer_.grow_buffer(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user