ResultRetriever::on_entry_end()
{
if (m_dest_file_type == FileType::stderr_output) {
- Util::send_to_stderr(m_dest_data, m_ctx.args_info.strip_diagnostics_colors);
+ Util::send_to_stderr(m_ctx, m_dest_data);
} else if (m_dest_file_type == FileType::dependency && !m_dest_path.empty()) {
write_dependency_file();
}
}
void
-send_to_stderr(const std::string& text, bool strip_colors)
+send_to_stderr(const Context& ctx, const std::string& text)
{
const std::string* text_to_send = &text;
- std::string stripped_text;
+ std::string modified_text;
- if (strip_colors) {
+ if (ctx.args_info.strip_diagnostics_colors) {
try {
- stripped_text = Util::strip_ansi_csi_seqs(text);
- text_to_send = &stripped_text;
+ modified_text = strip_ansi_csi_seqs(text);
+ text_to_send = &modified_text;
} catch (const Error&) {
// Fall through
}
const std::string& canonical_program_name);
// Send `text` to STDERR_FILENO, optionally stripping ANSI color sequences if
-// `strip_colors` is true. Throws `Error` on error.
-void send_to_stderr(const std::string& text, bool strip_colors);
+// `ctx.args_info.strip_diagnostics_colors` is true. Throws `Error` on error.
+void send_to_stderr(const Context& ctx, const std::string& text);
// Set the FD_CLOEXEC on file descriptor `fd`. This is a NOP on Windows.
void set_cloexec_flag(int fd);
log("Compiler gave exit status {}", status);
// We can output stderr immediately instead of rerunning the compiler.
- Util::send_to_stderr(Util::read_file(tmp_stderr_path),
- ctx.args_info.strip_diagnostics_colors);
+ Util::send_to_stderr(ctx, Util::read_file(tmp_stderr_path));
throw Failure(STATS_STATUS, status);
}
}
// Everything OK.
- Util::send_to_stderr(Util::read_file(tmp_stderr_path),
- ctx.args_info.strip_diagnostics_colors);
+ Util::send_to_stderr(ctx, Util::read_file(tmp_stderr_path));
}
// Find the result name by running the compiler in preprocessor mode and