summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2011-01-06 12:54:28 +0200
committerHans de Goede <hdegoede@redhat.com>2011-02-10 20:42:46 +0100
commit967a4a9cbbd5c20e3bf75258f3c8af1c82fed19f (patch)
tree536df89dc2771b807cbf0be88d03e6c3b666a563 /client
parentc55e5a5be3d870f43e3100357af77023bfe6a84f (diff)
downloadspice-967a4a9cbbd5c20e3bf75258f3c8af1c82fed19f.tar.gz
spice-967a4a9cbbd5c20e3bf75258f3c8af1c82fed19f.tar.xz
spice-967a4a9cbbd5c20e3bf75258f3c8af1c82fed19f.zip
client/cmd_line_parser: fix wrong reporting of bad argument in --bla=val case
We use get_opt_long, which allows non ambiguous abbreviations, but since we didn't like that we have code that checks for abbreviations and issues an error. But that code only handled separate argument and key like: --bla value and didn't handle them in the same arguemnts, like: --bla=value This patch fixes that, and gives a slightly better error report (it still contains the =value part though)
Diffstat (limited to 'client')
-rw-r--r--client/cmd_line_parser.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/client/cmd_line_parser.cpp b/client/cmd_line_parser.cpp
index a813629d..7c396ba1 100644
--- a/client/cmd_line_parser.cpp
+++ b/client/cmd_line_parser.cpp
@@ -346,10 +346,13 @@ int CmdLineParser::get_option(char** val)
}
#ifdef DISABLE_ABBREVIATE
- int name_pos = (opt_obj->type == REQUIRED_ARGUMENT) ? optind - 2 : optind - 1;
+ int name_pos =
+ (opt_obj->type == REQUIRED_ARGUMENT && optarg[-1] != '=')
+ ? optind - 2
+ : optind - 1;
std::string cmd_name(_argv[name_pos] + 2);
if (cmd_name.find(opt_obj->name) != 0) {
- Platform::term_printf("%s: invalid option '--%s'\n", _argv[0], cmd_name.c_str());
+ Platform::term_printf("%s: invalid abbreviated option '--%s'\n", _argv[0], cmd_name.c_str());
return OPTION_ERROR;
}
#endif