Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid conflict with the macro CHAR_WIDTH #616

Merged
merged 1 commit into from
Nov 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Avoid conflict with the macro CHAR_WIDTH
It looks like CHAR_WIDTH is a macro in glibc. See
https://sourceware.org/ml/libc-alpha/2016-09/msg00225.html
aroig committed Nov 25, 2017

Verified

This commit was signed with the committer’s verified signature. The key has expired.
jeff-mccoy Megamind
commit 93f7045e57e69ef1624d156d6aa297b153b6b567
16 changes: 8 additions & 8 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
@@ -1983,21 +1983,21 @@ class arg_formatter_base {
using pointer_type = typename basic_writer<Char>::pointer_type;
Char fill = internal::char_traits<Char>::cast(specs_.fill());
pointer_type out = pointer_type();
const unsigned CHAR_WIDTH = 1;
if (specs_.width_ > CHAR_WIDTH) {
const unsigned character_width = 1;
if (specs_.width_ > character_width) {
out = writer_.grow_buffer(specs_.width_);
if (specs_.align_ == ALIGN_RIGHT) {
std::uninitialized_fill_n(out, specs_.width_ - CHAR_WIDTH, fill);
out += specs_.width_ - CHAR_WIDTH;
std::uninitialized_fill_n(out, specs_.width_ - character_width, fill);
out += specs_.width_ - character_width;
} else if (specs_.align_ == ALIGN_CENTER) {
out = writer_.fill_padding(out, specs_.width_,
internal::const_check(CHAR_WIDTH), fill);
internal::const_check(character_width), fill);
} else {
std::uninitialized_fill_n(out + CHAR_WIDTH,
specs_.width_ - CHAR_WIDTH, fill);
std::uninitialized_fill_n(out + character_width,
specs_.width_ - character_width, fill);
}
} else {
out = writer_.grow_buffer(CHAR_WIDTH);
out = writer_.grow_buffer(character_width);
}
*out = internal::char_traits<Char>::cast(value);
}