aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc
diff options
context:
space:
mode:
authormdldml <mdldml@yandex-team.ru>2022-02-10 16:47:32 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:32 +0300
commitc6c46dbbfbb6bf6153631790f5248c8cfd84e27a (patch)
treec6241637987789bb5da7b99f09054fdf8b8c0a19 /contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc
parent40d35c046ee3a61ee2a581f42499c5ce56ac589a (diff)
downloadydb-c6c46dbbfbb6bf6153631790f5248c8cfd84e27a.tar.gz
Restoring authorship annotation for <mdldml@yandex-team.ru>. Commit 1 of 2.
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.cc132
1 files changed, 66 insertions, 66 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 7663ea0085..d78adb82d7 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
@@ -1573,13 +1573,13 @@ CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments(
<< std::endl;
return PARSE_ARGUMENT_FAIL;
}
- if (mode_ != MODE_DECODE && mode_ != MODE_ENCODE &&
- (!encode_decode_input_.empty() || !encode_decode_output_.empty())) {
- std::cerr << "--encode-decode-input and --encode-decode-output are used "
- << "only together with --encode or --decode modes."
- << std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
+ if (mode_ != MODE_DECODE && mode_ != MODE_ENCODE &&
+ (!encode_decode_input_.empty() || !encode_decode_output_.empty())) {
+ std::cerr << "--encode-decode-input and --encode-decode-output are used "
+ << "only together with --encode or --decode modes."
+ << std::endl;
+ return PARSE_ARGUMENT_FAIL;
+ }
if (!dependency_out_name_.empty() && input_files_.size() > 1) {
std::cerr
<< "Can only process one input file when using --dependency_out=FILE."
@@ -1889,35 +1889,35 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name,
codec_type_ = value;
- } else if (name == "--encode-decode-input") {
- if (!encode_decode_input_.empty()) {
- std::cerr << name << " may only be passed once." << std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
- if (value.empty()) {
- std::cerr << name << " requires a non-empty value." << std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
- if (access(value.c_str(), F_OK) < 0) {
- std::cerr << value << ": encode/decode input file does not exist."
- << std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
-
- encode_decode_input_ = value;
-
- } else if (name == "--encode-decode-output") {
- if (!encode_decode_output_.empty()) {
- std::cerr << name << " may only be passed once." << std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
- if (value.empty()) {
- std::cerr << name << " requires a non-empty value." << std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
-
- encode_decode_output_ = value;
-
+ } else if (name == "--encode-decode-input") {
+ if (!encode_decode_input_.empty()) {
+ std::cerr << name << " may only be passed once." << std::endl;
+ return PARSE_ARGUMENT_FAIL;
+ }
+ if (value.empty()) {
+ std::cerr << name << " requires a non-empty value." << std::endl;
+ return PARSE_ARGUMENT_FAIL;
+ }
+ if (access(value.c_str(), F_OK) < 0) {
+ std::cerr << value << ": encode/decode input file does not exist."
+ << std::endl;
+ return PARSE_ARGUMENT_FAIL;
+ }
+
+ encode_decode_input_ = value;
+
+ } else if (name == "--encode-decode-output") {
+ if (!encode_decode_output_.empty()) {
+ std::cerr << name << " may only be passed once." << std::endl;
+ return PARSE_ARGUMENT_FAIL;
+ }
+ if (value.empty()) {
+ std::cerr << name << " requires a non-empty value." << std::endl;
+ return PARSE_ARGUMENT_FAIL;
+ }
+
+ encode_decode_output_ = value;
+
} else if (name == "--deterministic_output") {
deterministic_output_ = true;
@@ -2395,40 +2395,40 @@ bool CommandLineInterface::EncodeOrDecode(const DescriptorPool* pool) {
DynamicMessageFactory dynamic_factory(pool);
std::unique_ptr<Message> message(dynamic_factory.GetPrototype(type)->New());
- int in_fd = STDIN_FILENO;
- if (!encode_decode_input_.empty()) {
- do {
- in_fd = open(encode_decode_input_.c_str(), O_RDONLY | O_BINARY);
- } while (in_fd < 0 && errno == EINTR);
- if (in_fd < 0) {
- int error = errno;
- std::cerr << encode_decode_input_ << ": " << strerror(error) << std::endl;
- return false;
- }
- }
-
- int out_fd = STDOUT_FILENO;
- if (!encode_decode_output_.empty()) {
- do {
- out_fd = open(encode_decode_output_.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
- } while (out_fd < 0 && errno == EINTR);
- if (out_fd < 0) {
- int error = errno;
- std::cerr << encode_decode_output_ << ": " << strerror(error) << std::endl;;
- return false;
- }
- }
-
+ int in_fd = STDIN_FILENO;
+ if (!encode_decode_input_.empty()) {
+ do {
+ in_fd = open(encode_decode_input_.c_str(), O_RDONLY | O_BINARY);
+ } while (in_fd < 0 && errno == EINTR);
+ if (in_fd < 0) {
+ int error = errno;
+ std::cerr << encode_decode_input_ << ": " << strerror(error) << std::endl;
+ return false;
+ }
+ }
+
+ int out_fd = STDOUT_FILENO;
+ if (!encode_decode_output_.empty()) {
+ do {
+ out_fd = open(encode_decode_output_.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
+ } while (out_fd < 0 && errno == EINTR);
+ if (out_fd < 0) {
+ int error = errno;
+ std::cerr << encode_decode_output_ << ": " << strerror(error) << std::endl;;
+ return false;
+ }
+ }
+
if (mode_ == MODE_ENCODE) {
- SetFdToTextMode(in_fd);
- SetFdToBinaryMode(out_fd);
+ SetFdToTextMode(in_fd);
+ SetFdToBinaryMode(out_fd);
} else {
- SetFdToBinaryMode(in_fd);
- SetFdToTextMode(out_fd);
+ SetFdToBinaryMode(in_fd);
+ SetFdToTextMode(out_fd);
}
- io::FileInputStream in(in_fd);
- io::FileOutputStream out(out_fd);
+ io::FileInputStream in(in_fd);
+ io::FileOutputStream out(out_fd);
if (mode_ == MODE_ENCODE) {
// Input is text.