Support color printing strings with zero bytes
This is a clean up after #1351.
This commit is contained in:
parent
96f91428c6
commit
7fd7ef32c2
@ -503,8 +503,7 @@ void vprint(std::FILE* f, const text_style& ts, const S& format,
|
||||
basic_format_args<buffer_context<Char> > args) {
|
||||
basic_memory_buffer<Char> buf;
|
||||
internal::vformat_to(buf, ts, to_string_view(format), args);
|
||||
buf.push_back(Char(0));
|
||||
internal::fputs(buf.data(), f);
|
||||
std::fwrite(buf.data(), 1, buf.size(), f);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -45,6 +45,8 @@ TEST(ColorsTest, ColorsPrint) {
|
||||
EXPECT_WRITE(stdout,
|
||||
fmt::print(bg(fmt::terminal_color::bright_magenta), "tbmagenta"),
|
||||
"\x1b[105mtbmagenta\x1b[0m");
|
||||
EXPECT_WRITE(stdout, fmt::print(fmt::emphasis::bold, "{}", std::string("a\0b", 3)),
|
||||
std::string("\x1b[1ma\0b\x1b[0m", 11));
|
||||
}
|
||||
|
||||
TEST(ColorsTest, Format) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user