modify argc and argv

This commit is contained in:
Jarryd Beck 2014-10-09 11:16:34 +11:00
parent 8701a5d7ca
commit 07fa58d397
2 changed files with 7 additions and 1 deletions

View File

@ -154,7 +154,7 @@ Options::parse(int& argc, char**& argv)
{ {
int current = 1; int current = 1;
std::set<int> consumed; int nextKeep = 1;
while (current != argc) while (current != argc)
{ {
@ -172,6 +172,8 @@ Options::parse(int& argc, char**& argv)
} }
else else
{ {
argv[nextKeep] = argv[current];
++nextKeep;
} }
//if we return from here then it was parsed successfully, so continue //if we return from here then it was parsed successfully, so continue
} }
@ -262,6 +264,8 @@ Options::parse(int& argc, char**& argv)
++current; ++current;
} }
argc = nextKeep;
} }
} }

View File

@ -71,6 +71,8 @@ int main(int argc, char* argv[])
<< std::endl; << std::endl;
} }
std::cout << argc << std::endl;
} catch (const cxxopts::OptionException& e) } catch (const cxxopts::OptionException& e)
{ {
std::cout << "error parsing options: " << e.what() << std::endl; std::cout << "error parsing options: " << e.what() << std::endl;