aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/compiler/command_line_interface.cc
diff options
context:
space:
mode:
authorJisi Liu <jisi.liu@gmail.com>2016-04-28 14:34:59 -0700
committerJisi Liu <jisi.liu@gmail.com>2016-04-28 14:34:59 -0700
commitcf14183bcd5485b4a71541599ddce0b35eb71352 (patch)
tree12f6e5eb731d7a70cdac4cdafc8b3131629413e2 /src/google/protobuf/compiler/command_line_interface.cc
parentf00300d7f04f1c38a7d70e271f9232b94dd0e326 (diff)
downloadprotobuf-cf14183bcd5485b4a71541599ddce0b35eb71352.tar.gz
protobuf-cf14183bcd5485b4a71541599ddce0b35eb71352.tar.bz2
protobuf-cf14183bcd5485b4a71541599ddce0b35eb71352.zip
Down integrate from Google internal.
Diffstat (limited to 'src/google/protobuf/compiler/command_line_interface.cc')
-rw-r--r--src/google/protobuf/compiler/command_line_interface.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc
index 87843f62..fcad6b61 100644
--- a/src/google/protobuf/compiler/command_line_interface.cc
+++ b/src/google/protobuf/compiler/command_line_interface.cc
@@ -46,6 +46,7 @@
#include <unistd.h>
#endif
#include <errno.h>
+#include <fstream>
#include <iostream>
#include <ctype.h>
@@ -948,17 +949,23 @@ bool CommandLineInterface::MakeInputsBeProtoPathRelative(
return true;
}
+
CommandLineInterface::ParseArgumentStatus
CommandLineInterface::ParseArguments(int argc, const char* const argv[]) {
executable_name_ = argv[0];
+ vector<string> arguments;
+ for (int i = 1; i < argc; ++i) {
+ arguments.push_back(argv[i]);
+ }
+
// Iterate through all arguments and parse them.
- for (int i = 1; i < argc; i++) {
+ for (int i = 0; i < arguments.size(); ++i) {
string name, value;
- if (ParseArgument(argv[i], &name, &value)) {
+ if (ParseArgument(arguments[i].c_str(), &name, &value)) {
// Returned true => Use the next argument as the flag value.
- if (i + 1 == argc || argv[i+1][0] == '-') {
+ if (i + 1 == arguments.size() || arguments[i + 1][0] == '-') {
std::cerr << "Missing value for flag: " << name << std::endl;
if (name == "--decode") {
std::cerr << "To decode an unknown message, use --decode_raw."
@@ -967,7 +974,7 @@ CommandLineInterface::ParseArguments(int argc, const char* const argv[]) {
return PARSE_ARGUMENT_FAIL;
} else {
++i;
- value = argv[i];
+ value = arguments[i];
}
}