diff options
author | Jose <jose@zeroc.com> | 2018-08-13 19:09:02 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2018-08-13 19:09:02 +0200 |
commit | 347075d9bb7cd91c2d98a52ae03f4e0ce194bbcc (patch) | |
tree | 090f1dffbefd9e29faf0b1c813aeac220267a13d /cpp/src | |
parent | Revert "Fix incorrectly parsing of multiple short options" (diff) | |
download | ice-347075d9bb7cd91c2d98a52ae03f4e0ce194bbcc.tar.bz2 ice-347075d9bb7cd91c2d98a52ae03f4e0ce194bbcc.tar.xz ice-347075d9bb7cd91c2d98a52ae03f4e0ce194bbcc.zip |
IceUtil Options incorrectly paring multiple short options
Fixes #168
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/IceUtil/Options.cpp | 27 |
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; } } } |