diff options
author | mikhnenko <mikhnenko@yandex-team.com> | 2024-06-25 08:50:35 +0300 |
---|---|---|
committer | mikhnenko <mikhnenko@yandex-team.com> | 2024-06-25 09:00:27 +0300 |
commit | 509c9fc9e7b9c3b8be7307d72a4c966e5f9aa194 (patch) | |
tree | 4b8a6a44009906ac852e59efa0bc78bb12043a5b /contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc | |
parent | 7688f2313619a39a60ef3c2734d8efbc49a0a6db (diff) | |
download | ydb-509c9fc9e7b9c3b8be7307d72a4c966e5f9aa194.tar.gz |
Update protobuf to 3.20.2 and pyprotobuf to 3.20.3
Если это pull-request что-то сломал, то:
- если это тест с канонизацией и еще нет pr с переканонизацией, то переканонизируйте пожалуйста сами
- проверьте, что тест не флапает
- приходите в [DEVTOOLSSUPPORT](https://st.yandex-team.ru/createTicket?queue=DEVTOOLSSUPPORT) - там вам обязательно помогут
987be5ed151f827f7f292f32420470b04b71a91d
Diffstat (limited to 'contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc')
-rw-r--r-- | contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc b/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc index 7731c611d1..e1cbfee896 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc @@ -53,10 +53,11 @@ #endif #include <ctype.h> #include <errno.h> + #include <fstream> #include <iostream> -#include <limits.h> //For PATH_MAX +#include <limits.h> // For PATH_MAX #include <memory> @@ -68,7 +69,6 @@ #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/logging.h> -#include <google/protobuf/stubs/stringprintf.h> #include <google/protobuf/compiler/subprocess.h> #include <google/protobuf/compiler/zip_writer.h> #include <google/protobuf/compiler/plugin.pb.h> @@ -81,12 +81,14 @@ #include <google/protobuf/dynamic_message.h> #include <google/protobuf/text_format.h> #include <google/protobuf/stubs/strutil.h> +#include <google/protobuf/stubs/stringprintf.h> #include <google/protobuf/stubs/substitute.h> #include <google/protobuf/io/io_win32.h> #include <google/protobuf/stubs/map_util.h> #include <google/protobuf/stubs/stl_util.h> +// Must be included last. #include <google/protobuf/port_def.inc> namespace google { @@ -195,7 +197,7 @@ bool TryCreateParentDirectory(const TProtoStringType& prefix, bool GetProtocAbsolutePath(TProtoStringType* path) { #ifdef _WIN32 char buffer[MAX_PATH]; - int len = GetModuleFileNameA(NULL, buffer, MAX_PATH); + int len = GetModuleFileNameA(nullptr, buffer, MAX_PATH); #elif defined(__APPLE__) char buffer[PATH_MAX]; int len = 0; @@ -210,7 +212,7 @@ bool GetProtocAbsolutePath(TProtoStringType* path) { char buffer[PATH_MAX]; size_t len = PATH_MAX; int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; - if (sysctl(mib, 4, &buffer, &len, NULL, 0) != 0) { + if (sysctl(mib, 4, &buffer, &len, nullptr, 0) != 0) { len = 0; } #else @@ -289,12 +291,12 @@ class CommandLineInterface::ErrorPrinter public io::ErrorCollector, public DescriptorPool::ErrorCollector { public: - ErrorPrinter(ErrorFormat format, DiskSourceTree* tree = NULL) + ErrorPrinter(ErrorFormat format, DiskSourceTree* tree = nullptr) : format_(format), tree_(tree), found_errors_(false), found_warnings_(false) {} - ~ErrorPrinter() {} + ~ErrorPrinter() override {} // implements MultiFileErrorCollector ------------------------------ void AddError(const TProtoStringType& filename, int line, int column, @@ -341,8 +343,8 @@ class CommandLineInterface::ErrorPrinter std::ostream& out) { // Print full path when running under MSVS TProtoStringType dfile; - if (format_ == CommandLineInterface::ERROR_FORMAT_MSVS && tree_ != NULL && - tree_->VirtualFileToDiskFile(filename, &dfile)) { + if (format_ == CommandLineInterface::ERROR_FORMAT_MSVS && + tree_ != nullptr && tree_->VirtualFileToDiskFile(filename, &dfile)) { out << dfile; } else { out << filename; @@ -434,7 +436,7 @@ class CommandLineInterface::MemoryOutputStream const TProtoStringType& filename, const TProtoStringType& insertion_point, const google::protobuf::GeneratedCodeInfo& info); - virtual ~MemoryOutputStream(); + ~MemoryOutputStream() override; // implements ZeroCopyOutputStream --------------------------------- bool Next(void** data, int* size) override { @@ -1116,7 +1118,7 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { FileDescriptorProto file; file.set_name("empty_message.proto"); file.add_message_type()->set_name("EmptyMessage"); - GOOGLE_CHECK(pool.BuildFile(file) != NULL); + GOOGLE_CHECK(pool.BuildFile(file) != nullptr); codec_type_ = "EmptyMessage"; if (!EncodeOrDecode(&pool)) { return 1; @@ -1270,7 +1272,7 @@ bool CommandLineInterface::ParseInputFiles( // Import the file. const FileDescriptor* parsed_file = descriptor_pool->FindFileByName(input_file); - if (parsed_file == NULL) { + if (parsed_file == nullptr) { result = false; break; } @@ -1496,7 +1498,7 @@ CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments( for (std::vector<OutputDirective>::const_iterator j = output_directives_.begin(); j != output_directives_.end(); ++j) { - if (j->generator == NULL) { + if (j->generator == nullptr) { TProtoStringType plugin_name = PluginName(plugin_prefix_, j->name); if (plugin_name == i->first) { foundImplicitPlugin = true; @@ -1613,7 +1615,7 @@ bool CommandLineInterface::ParseArgument(const char* arg, TProtoStringType* name // Two dashes: Multi-character name, with '=' separating name and // value. const char* equals_pos = strchr(arg, '='); - if (equals_pos != NULL) { + if (equals_pos != nullptr) { *name = TProtoStringType(arg, equals_pos - arg); *value = equals_pos + 1; parsed_value = true; @@ -1681,8 +1683,9 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name, // On Windows, the shell (typically cmd.exe) does not expand wildcards in // file names (e.g. foo\*.proto), so we do it ourselves. switch (google::protobuf::io::win32::ExpandWildcards( - value, - [this](const string& path) { this->input_files_.push_back(path); })) { + value, [this](const TProtoStringType& path) { + this->input_files_.push_back(path); + })) { case google::protobuf::io::win32::ExpandWildcardsResult::kSuccess: break; case google::protobuf::io::win32::ExpandWildcardsResult:: @@ -1982,11 +1985,11 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name, // Some other flag. Look it up in the generators list. const GeneratorInfo* generator_info = FindOrNull(generators_by_flag_name_, name); - if (generator_info == NULL && + if (generator_info == nullptr && (plugin_prefix_.empty() || !HasSuffixString(name, "_out"))) { // Check if it's a generator option flag. generator_info = FindOrNull(generators_by_option_name_, name); - if (generator_info != NULL) { + if (generator_info != nullptr) { TProtoStringType* parameters = &generator_parameters_[generator_info->flag_name]; if (!parameters->empty()) { @@ -2015,8 +2018,8 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name, OutputDirective directive; directive.name = name; - if (generator_info == NULL) { - directive.generator = NULL; + if (generator_info == nullptr) { + directive.generator = nullptr; } else { directive.generator = generator_info->generator; } @@ -2176,7 +2179,7 @@ bool CommandLineInterface::GenerateOutput( GeneratorContext* generator_context) { // Call the generator. TProtoStringType error; - if (output_directive.generator == NULL) { + if (output_directive.generator == nullptr) { // This is a plugin. GOOGLE_CHECK(HasPrefixString(output_directive.name, "--") && HasSuffixString(output_directive.name, "_out")) @@ -2344,7 +2347,7 @@ bool CommandLineInterface::GeneratePluginOutput( if (!output_file.insertion_point().empty()) { TProtoStringType filename = output_file.name(); // Open a file for insert. - // We reset current_output to NULL first so that the old file is closed + // We reset current_output to nullptr first so that the old file is closed // before the new one is opened. current_output.reset(); current_output.reset( @@ -2353,11 +2356,11 @@ bool CommandLineInterface::GeneratePluginOutput( output_file.generated_code_info())); } else if (!output_file.name().empty()) { // Starting a new file. Open it. - // We reset current_output to NULL first so that the old file is closed + // We reset current_output to nullptr first so that the old file is closed // before the new one is opened. current_output.reset(); current_output.reset(generator_context->Open(output_file.name())); - } else if (current_output == NULL) { + } else if (current_output == nullptr) { *error = strings::Substitute( "$0: First file chunk returned by plugin did not specify a file " "name.", @@ -2387,7 +2390,7 @@ bool CommandLineInterface::GeneratePluginOutput( bool CommandLineInterface::EncodeOrDecode(const DescriptorPool* pool) { // Look up the type. const Descriptor* type = pool->FindMessageTypeByName(codec_type_); - if (type == NULL) { + if (type == nullptr) { std::cerr << "Type not defined: " << codec_type_ << std::endl; return false; } @@ -2650,7 +2653,8 @@ void FormatFreeFieldNumbers(const TProtoStringType& name, StringAppendF(&output, " %d", next_free_number); } else { // Range - StringAppendF(&output, " %d-%d", next_free_number, i->first - 1); + StringAppendF(&output, " %d-%d", next_free_number, + i->first - 1); } } next_free_number = i->second; |