Skip to content

Instantly share code, notes, and snippets.

@vvs
Created March 4, 2010 22:21
Show Gist options
  • Select an option

  • Save vvs/322185 to your computer and use it in GitHub Desktop.

Select an option

Save vvs/322185 to your computer and use it in GitHub Desktop.
diff --git a/argparser.cpp b/argparser.cpp
index cec153b..f703ce5 100644
--- a/argparser.cpp
+++ b/argparser.cpp
@@ -205,7 +205,7 @@ bool ArgParser::parseArgs(int argc, char *argv[]) {
#define CHECK_ARG \
it++; \
- if (it == args.end() || it->at(0) == '-') { \
+ if (it == args.end() || it->length() == 0 || it->at(0) == '-') { \
logErr(false, true, "Argument is missing for \"%s\" option.", (--it)->c_str()); \
return false; \
} \
@@ -227,7 +227,7 @@ bool ArgParser::parseArgs(int argc, char *argv[]) {
for (list<string>::iterator it = args.begin(); it != args.end(); INCR) {
if (doneScanning) {
progArgs.push_back(*it);
- } else if (it->compare("--") == 0 || it->at(0) != '-') {
+ } else if (it->compare("--") == 0 || it->length() == 0 || it->at(0) != '-') {
progArgs.push_back(*it);
doneScanning = true;
} else if (it->compare(ARG_NAME_SEPAR_PROC) == 0) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment