mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-12 22:20:05 +00:00
Fix more warnings.
This commit is contained in:
parent
88972f487b
commit
563a575c0c
12
format.cc
12
format.cc
@ -136,10 +136,11 @@ typename fmt::BasicWriter<Char>::CharPtr
|
||||
unsigned total_size, std::size_t content_size, wchar_t fill) {
|
||||
std::size_t padding = total_size - content_size;
|
||||
std::size_t left_padding = padding / 2;
|
||||
std::fill_n(buffer, left_padding, fill);
|
||||
Char fill_char = static_cast<Char>(fill);
|
||||
std::fill_n(buffer, left_padding, fill_char);
|
||||
buffer += left_padding;
|
||||
CharPtr content = buffer;
|
||||
std::fill_n(buffer + content_size, padding - left_padding, fill);
|
||||
std::fill_n(buffer + content_size, padding - left_padding, fill_char);
|
||||
return content;
|
||||
}
|
||||
|
||||
@ -179,12 +180,13 @@ typename fmt::BasicWriter<Char>::CharPtr
|
||||
CharPtr p = GrowBuffer(width);
|
||||
CharPtr end = p + width;
|
||||
Alignment align = spec.align();
|
||||
Char fill = static_cast<Char>(spec.fill());
|
||||
if (align == ALIGN_LEFT) {
|
||||
*p = sign;
|
||||
p += size;
|
||||
std::fill(p, end, spec.fill());
|
||||
std::fill(p, end, fill);
|
||||
} else if (align == ALIGN_CENTER) {
|
||||
p = FillPadding(p, width, size, spec.fill());
|
||||
p = FillPadding(p, width, size, fill);
|
||||
*p = sign;
|
||||
p += size;
|
||||
} else {
|
||||
@ -196,7 +198,7 @@ typename fmt::BasicWriter<Char>::CharPtr
|
||||
} else {
|
||||
*(end - size) = sign;
|
||||
}
|
||||
std::fill(p, end - size, spec.fill());
|
||||
std::fill(p, end - size, fill);
|
||||
p = end;
|
||||
}
|
||||
return p - 1;
|
||||
|
7
format.h
7
format.h
@ -558,13 +558,14 @@ typename BasicWriter<Char>::CharPtr BasicWriter<Char>::FormatString(
|
||||
CharPtr out = CharPtr();
|
||||
if (spec.width() > size) {
|
||||
out = GrowBuffer(spec.width());
|
||||
Char fill = static_cast<Char>(spec.fill());
|
||||
if (spec.align() == ALIGN_RIGHT) {
|
||||
std::fill_n(out, spec.width() - size, spec.fill());
|
||||
std::fill_n(out, spec.width() - size, fill);
|
||||
out += spec.width() - size;
|
||||
} else if (spec.align() == ALIGN_CENTER) {
|
||||
out = FillPadding(out, spec.width(), size, spec.fill());
|
||||
out = FillPadding(out, spec.width(), size, fill);
|
||||
} else {
|
||||
std::fill_n(out + size, spec.width() - size, spec.fill());
|
||||
std::fill_n(out + size, spec.width() - size, fill);
|
||||
}
|
||||
} else {
|
||||
out = GrowBuffer(size);
|
||||
|
Loading…
Reference in New Issue
Block a user