summaryrefslogtreecommitdiff
path: root/cpp/src/IceUtil
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2018-08-13 10:12:56 +0200
committerJose <jose@zeroc.com>2018-08-13 17:00:31 +0200
commit2e3f80cbc9a64872011f3f6e92c51c66e3e8f88a (patch)
tree91ea349b501e21aaf14307d96539ef556d5c5d35 /cpp/src/IceUtil
parentFixes for strerror_r usage (diff)
downloadice-2e3f80cbc9a64872011f3f6e92c51c66e3e8f88a.tar.bz2
ice-2e3f80cbc9a64872011f3f6e92c51c66e3e8f88a.tar.xz
ice-2e3f80cbc9a64872011f3f6e92c51c66e3e8f88a.zip
Revert "Fix incorrectly parsing of multiple short options"
This reverts commit 868387969b99396630a72965374178eb207ca415.
Diffstat (limited to 'cpp/src/IceUtil')
-rw-r--r--cpp/src/IceUtil/Options.cpp49
1 files changed, 22 insertions, 27 deletions
diff --git a/cpp/src/IceUtil/Options.cpp b/cpp/src/IceUtil/Options.cpp
index 3da1256697b..c93154496a4 100644
--- a/cpp/src/IceUtil/Options.cpp
+++ b/cpp/src/IceUtil/Options.cpp
@@ -662,40 +662,35 @@ IceUtilInternal::Options::parse(const StringVector& args)
//
// Short option.
//
- opt = args[i][1];
- pos = checkOpt(opt, ShortOpt);
-
- if(pos->second->repeat == NoRepeat)
+ for(string::size_type p = 1; p < args[i].size(); ++p)
{
- set<string>::iterator seenPos = seenNonRepeatableOpts.find(opt);
- if(seenPos != seenNonRepeatableOpts.end())
- {
- string err = "`-";
- err += opt + ":' option cannot be repeated";
- throw BadOptException(__FILE__, __LINE__, err);
- }
- seenNonRepeatableOpts.insert(seenPos, opt);
- string synonym = getSynonym(opt);
- if(!synonym.empty())
+ opt.clear();
+ opt.push_back(args[i][p]);
+ pos = checkOpt(opt, ShortOpt);
+
+ if(pos->second->repeat == NoRepeat)
{
- seenNonRepeatableOpts.insert(synonym);
+ set<string>::iterator seenPos = seenNonRepeatableOpts.find(opt);
+ if(seenPos != seenNonRepeatableOpts.end())
+ {
+ string err = "`-";
+ err += opt + ":' option cannot be repeated";
+ throw BadOptException(__FILE__, __LINE__, err);
+ }
+ seenNonRepeatableOpts.insert(seenPos, opt);
+ string synonym = getSynonym(opt);
+ if(!synonym.empty())
+ {
+ seenNonRepeatableOpts.insert(synonym);
+ }
}
- }
- if(args[i].size() > 2)
- {
- if(pos->second->arg == NeedArg)
+ if(pos->second->arg == NeedArg && p != args[i].size() - 1)
{
- string optArg = args[i].substr(2);
+ string optArg = args[i].substr(p + 1);
setOpt(opt, "", optArg, pos->second->repeat);
argDone = true;
- }
- else
- {
- string err = "invalid option: `-";
- err += args[i].substr(1);
- err.push_back('\'');
- throw BadOptException(__FILE__, __LINE__, err);
+ break;
}
}
}