Index: third_party/protobuf/src/google/protobuf/io/printer.cc |
=================================================================== |
--- third_party/protobuf/src/google/protobuf/io/printer.cc (revision 216642) |
+++ third_party/protobuf/src/google/protobuf/io/printer.cc (working copy) |
@@ -35,7 +35,6 @@ |
#include <google/protobuf/io/printer.h> |
#include <google/protobuf/io/zero_copy_stream.h> |
#include <google/protobuf/stubs/common.h> |
-#include <google/protobuf/stubs/strutil.h> |
namespace google { |
namespace protobuf { |
@@ -51,8 +50,8 @@ |
} |
Printer::~Printer() { |
- // Only BackUp() if we're sure we've successfully called Next() at least once. |
- if (buffer_size_ > 0) { |
+ // Only BackUp() if we have called Next() at least once and never failed. |
+ if (buffer_size_ > 0 && !failed_) { |
output_->BackUp(buffer_size_); |
} |
} |
@@ -169,7 +168,7 @@ |
if (failed_) return; |
if (size == 0) return; |
- if (at_start_of_line_) { |
+ if (at_start_of_line_ && (size > 0) && (data[0] != '\n')) { |
// Insert an indent. |
at_start_of_line_ = false; |
WriteRaw(indent_.data(), indent_.size()); |