|
|
|
@ -34,6 +34,7 @@ |
|
|
|
|
|
|
|
|
|
#include "google/protobuf/compiler/command_line_interface.h" |
|
|
|
|
|
|
|
|
|
#include "absl/container/btree_map.h" |
|
|
|
|
#include "absl/container/flat_hash_map.h" |
|
|
|
|
|
|
|
|
|
#include "google/protobuf/stubs/platform_macros.h" |
|
|
|
@ -427,7 +428,7 @@ class CommandLineInterface::GeneratorContextImpl : public GeneratorContext { |
|
|
|
|
// The files_ field maps from path keys to file content values. It's a map
|
|
|
|
|
// instead of an unordered_map so that files are written in order (good when
|
|
|
|
|
// writing zips).
|
|
|
|
|
absl::flat_hash_map<std::string, std::string> files_; |
|
|
|
|
absl::btree_map<std::string, std::string> files_; |
|
|
|
|
const std::vector<const FileDescriptor*>& parsed_files_; |
|
|
|
|
bool had_error_; |
|
|
|
|
}; |
|
|
|
@ -805,7 +806,8 @@ CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
it->second.swap(data_); |
|
|
|
|
} else { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
// This was an OpenForInsert().
|
|
|
|
|
|
|
|
|
|
// If the data doesn't end with a clean line break, add one.
|
|
|
|
@ -815,8 +817,7 @@ CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() { |
|
|
|
|
|
|
|
|
|
// Find the file we are going to insert into.
|
|
|
|
|
if (!already_present) { |
|
|
|
|
std::cerr << filename_ |
|
|
|
|
<< ": Tried to insert into file that doesn't exist." |
|
|
|
|
std::cerr << filename_ << ": Tried to insert into file that doesn't exist." |
|
|
|
|
<< std::endl; |
|
|
|
|
directory_->had_error_ = true; |
|
|
|
|
return; |
|
|
|
@ -862,7 +863,8 @@ CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() { |
|
|
|
|
// No indent. This makes things easier.
|
|
|
|
|
target->insert(pos, data_); |
|
|
|
|
UpdateMetadata(data_, pos, data_.size(), 0); |
|
|
|
|
} else { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
// Calculate how much space we need.
|
|
|
|
|
int indent_size = 0; |
|
|
|
|
for (int i = 0; i < data_.size(); i++) { |
|
|
|
@ -889,11 +891,10 @@ CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() { |
|
|
|
|
target_ptr += line_length; |
|
|
|
|
data_pos += line_length; |
|
|
|
|
} |
|
|
|
|
UpdateMetadata(data_, pos, data_.size() + indent_size, indent_.size()); |
|
|
|
|
|
|
|
|
|
GOOGLE_CHECK_EQ(target_ptr, &(*target)[pos] + data_.size() + indent_size); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UpdateMetadata(data_, pos, data_.size() + indent_size, indent_.size()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// ===================================================================
|
|
|
|
|