diff options
author | Andras Becsi <andras.becsi@digia.com> | 2014-05-22 18:24:25 +0200 |
---|---|---|
committer | Andras Becsi <andras.becsi@digia.com> | 2014-06-04 16:32:40 +0200 |
commit | 4ce69f7403811819800e7c5ae1318b2647e778d1 (patch) | |
tree | 2ec3a98b5abef002670a0916354eb7e0abfe2aa2 /ninja/src/line_printer.cc | |
parent | a6dd70e0328d155d5df8d6df48afbab690b08fb6 (diff) | |
download | qtwebengine-chromium-4ce69f7403811819800e7c5ae1318b2647e778d1.tar.gz |
Update Chromium snapshot to stable version 33.0.1750.170
This is meant as a baseline commit hence it does not
include the patches we need to apply for QtWebEngine.
All patches should be rebased on top of this commit
so we can get rid of the external patches directory.
In future these baseline commits always have to include
the exact Chromium version returned by version_resolver.py's
currentVersion() in their first line, so that we can
retrieve the patches on top to apply on the upstream
repository. This also includes a ninja update.
Change-Id: I60abeadb785a3b7d149c58b65ddb5a823fed3083
Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'ninja/src/line_printer.cc')
-rw-r--r-- | ninja/src/line_printer.cc | 51 |
1 files changed, 45 insertions, 6 deletions
diff --git a/ninja/src/line_printer.cc b/ninja/src/line_printer.cc index 3537e886e69..ef1609c28f5 100644 --- a/ninja/src/line_printer.cc +++ b/ninja/src/line_printer.cc @@ -26,7 +26,7 @@ #include "util.h" -LinePrinter::LinePrinter() : have_blank_line_(true) { +LinePrinter::LinePrinter() : have_blank_line_(true), console_locked_(false) { #ifndef _WIN32 const char* term = getenv("TERM"); smart_terminal_ = isatty(1) && term && string(term) != "dumb"; @@ -43,6 +43,12 @@ LinePrinter::LinePrinter() : have_blank_line_(true) { } void LinePrinter::Print(string to_print, LineType type) { + if (console_locked_) { + line_buffer_ = to_print; + line_type_ = type; + return; + } + #ifdef _WIN32 CONSOLE_SCREEN_BUFFER_INFO csbi; GetConsoleScreenBufferInfo(console_, &csbi); @@ -101,13 +107,46 @@ void LinePrinter::Print(string to_print, LineType type) { } } -void LinePrinter::PrintOnNewLine(const string& to_print) { - if (!have_blank_line_) - printf("\n"); - if (!to_print.empty()) { +void LinePrinter::PrintOrBuffer(const char* data, size_t size) { + if (console_locked_) { + output_buffer_.append(data, size); + } else { // Avoid printf and C strings, since the actual output might contain null // bytes like UTF-16 does (yuck). - fwrite(&to_print[0], sizeof(char), to_print.size(), stdout); + fwrite(data, 1, size, stdout); + } +} + +void LinePrinter::PrintOnNewLine(const string& to_print) { + if (console_locked_ && !line_buffer_.empty()) { + output_buffer_.append(line_buffer_); + output_buffer_.append(1, '\n'); + line_buffer_.clear(); + } + if (!have_blank_line_) { + PrintOrBuffer("\n", 1); + } + if (!to_print.empty()) { + PrintOrBuffer(&to_print[0], to_print.size()); } have_blank_line_ = to_print.empty() || *to_print.rbegin() == '\n'; } + +void LinePrinter::SetConsoleLocked(bool locked) { + if (locked == console_locked_) + return; + + if (locked) + PrintOnNewLine(""); + + console_locked_ = locked; + + if (!locked) { + PrintOnNewLine(output_buffer_); + if (!line_buffer_.empty()) { + Print(line_buffer_, line_type_); + } + output_buffer_.clear(); + line_buffer_.clear(); + } +} |