summaryrefslogtreecommitdiff
path: root/cpp/src/IceUtil/Options.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/IceUtil/Options.cpp')
-rw-r--r--cpp/src/IceUtil/Options.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/cpp/src/IceUtil/Options.cpp b/cpp/src/IceUtil/Options.cpp
index c93154496a4..25379394aaf 100644
--- a/cpp/src/IceUtil/Options.cpp
+++ b/cpp/src/IceUtil/Options.cpp
@@ -646,13 +646,20 @@ IceUtilInternal::Options::parse(const StringVector& args)
if(p != string::npos)
{
- if(pos->second->arg == NoArg && p != args[i].size() - 1)
+ if(pos->second->arg == NoArg)
{
string err = "`";
- err += args[i];
+ err += opt;
err += "': option does not take an argument";
throw BadOptException(__FILE__, __LINE__, err);
}
+ else if(pos->second->arg == NeedArg && p == args[i].size() - 1)
+ {
+ string err = "`";
+ err += opt;
+ err += "': option requires an argument";
+ throw BadOptException(__FILE__, __LINE__, err);
+ }
setOpt(opt, "", args[i].substr(p + 1), pos->second->repeat);
argDone = true;
}
@@ -685,12 +692,20 @@ IceUtilInternal::Options::parse(const StringVector& args)
}
}
- if(pos->second->arg == NeedArg && p != args[i].size() - 1)
+ if(pos->second->arg == NeedArg)
+ {
+ if(p != args[i].size() - 1)
+ {
+ string optArg = args[i].substr(p + 1);
+ setOpt(opt, "", optArg, pos->second->repeat);
+ argDone = true;
+ break;
+ }
+ }
+ else
{
- string optArg = args[i].substr(p + 1);
- setOpt(opt, "", optArg, pos->second->repeat);
+ setOpt(opt, "", "1", pos->second->repeat);
argDone = true;
- break;
}
}
}