summaryrefslogtreecommitdiff
path: root/cpp/src/IceUtil/Options.cpp
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2005-03-14 03:42:04 +0000
committerMichi Henning <michi@zeroc.com>2005-03-14 03:42:04 +0000
commit8b7813cafd58d1f9b9691356c097e271a6b02565 (patch)
tree7da648c0dcebb8e53faae6d2592e0d4f069e8688 /cpp/src/IceUtil/Options.cpp
parentFixed bad name. (diff)
downloadice-8b7813cafd58d1f9b9691356c097e271a6b02565.tar.bz2
ice-8b7813cafd58d1f9b9691356c097e271a6b02565.tar.xz
ice-8b7813cafd58d1f9b9691356c097e271a6b02565.zip
Merged fix for http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=172 from
2_1_branch.
Diffstat (limited to 'cpp/src/IceUtil/Options.cpp')
-rwxr-xr-xcpp/src/IceUtil/Options.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/cpp/src/IceUtil/Options.cpp b/cpp/src/IceUtil/Options.cpp
index fb87c556b2f..6654bee98fe 100755
--- a/cpp/src/IceUtil/Options.cpp
+++ b/cpp/src/IceUtil/Options.cpp
@@ -97,14 +97,16 @@ IceUtil::Options::parse(int argc, char* argv[])
if(parseCalled)
{
- throw APIError("Cannot call parse() more than once on the same Option instance");
+ throw APIError("cannot call parse() more than once on the same Option instance");
}
parseCalled = true;
+ vector<string> result;
+
int i;
- for(i = 1; i < argc && *argv[i] == '-'; ++i)
+ for(i = 1; i < argc; ++i)
{
- if(argv[i][1] == '\0' || strcmp(argv[i], "--") == 0)
+ if(strcmp(argv[i], "-") == 0 || strcmp(argv[i], "--") == 0)
{
++i;
break; // "-" and "--" indicate end of options.
@@ -114,7 +116,7 @@ IceUtil::Options::parse(int argc, char* argv[])
ValidOpts::iterator pos;
bool argDone = false;
- if(argv[i][1] == '-')
+ if(strncmp(argv[i], "--", 2) == 0)
{
//
// Long option. If the option has an argument, it can either be separated by '='
@@ -152,7 +154,7 @@ IceUtil::Options::parse(int argc, char* argv[])
argDone = true;
}
}
- else
+ else if(*argv[i] == '-')
{
//
// Short option.
@@ -177,6 +179,11 @@ IceUtil::Options::parse(int argc, char* argv[])
}
}
}
+ else
+ {
+ result.push_back(argv[i]); // Not an option or option argument.
+ argDone = true;
+ }
if(!argDone)
{
@@ -202,7 +209,6 @@ IceUtil::Options::parse(int argc, char* argv[])
}
}
- vector<string> result;
while(i < argc)
{
result.push_back(argv[i++]);
@@ -273,7 +279,6 @@ IceUtil::Options::argVec(const string& opt) const
err.push_back('-');
}
err += opt + "': is a non-repeating option -- use optArg() to get its argument";
- cerr << "p7" << endl;
throw APIError(err);
}