X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fui-file.c;h=71b74bba19054d35555e25328a1d6fd84fdaddd5;hb=b9d8f5601bcfbe96ab0476286ae8e249ada10db5;hp=4139b5deffc47933e317700edb289d4360ca7a63;hpb=8a522c6cab56bd55f1454638786f999f6f636354;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/ui-file.c b/gdb/ui-file.c index 4139b5deff..71b74bba19 100644 --- a/gdb/ui-file.c +++ b/gdb/ui-file.c @@ -23,7 +23,8 @@ #include "ui-file.h" #include "gdb_obstack.h" #include "gdb_select.h" -#include "common/filestuff.h" +#include "gdbsupport/filestuff.h" +#include "cli/cli-style.h" null_file null_stream; @@ -106,8 +107,6 @@ ui_file_isatty (struct ui_file *file) static bool term_cli_styling () { - extern int cli_styling; - if (!cli_styling) return false; @@ -336,20 +335,13 @@ stderr_file::stderr_file (FILE *stream) -tee_file::tee_file (ui_file *one, bool close_one, - ui_file *two, bool close_two) +tee_file::tee_file (ui_file *one, ui_file_up &&two) : m_one (one), - m_two (two), - m_close_one (close_one), - m_close_two (close_two) + m_two (std::move (two)) {} tee_file::~tee_file () { - if (m_close_one) - delete m_one; - if (m_close_two) - delete m_two; } void @@ -403,3 +395,35 @@ tee_file::can_emit_style_escape () && m_one->term_out () && term_cli_styling ()); } + +/* See ui-file.h. */ + +void +no_terminal_escape_file::write (const char *buf, long length_buf) +{ + std::string copy (buf, length_buf); + this->puts (copy.c_str ()); +} + +/* See ui-file.h. */ + +void +no_terminal_escape_file::puts (const char *buf) +{ + while (*buf != '\0') + { + const char *esc = strchr (buf, '\033'); + if (esc == nullptr) + break; + + int n_read = 0; + if (!skip_ansi_escape (esc, &n_read)) + ++esc; + + this->stdio_file::write (buf, esc - buf); + buf = esc + n_read; + } + + if (*buf != '\0') + this->stdio_file::write (buf, strlen (buf)); +}