projects
/
platform
/
upstream
/
zypper.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
414f985
)
Test for duplicate short option definition
author
Michael Andres
<ma@suse.de>
Fri, 11 Apr 2014 12:53:46 +0000
(14:53 +0200)
committer
Michael Andres
<ma@suse.de>
Fri, 11 Apr 2014 12:53:46 +0000
(14:53 +0200)
src/Zypper.cc
patch
|
blob
|
history
src/utils/getopt.cc
patch
|
blob
|
history
diff --git
a/src/Zypper.cc
b/src/Zypper.cc
index
fc943c1
..
b23ec88
100644
(file)
--- a/
src/Zypper.cc
+++ b/
src/Zypper.cc
@@
-970,6
+970,9
@@
void Zypper::safeDoCommand()
out().setVerbosity(tmp);
report_a_bug(out());
+ if ( ! exitCode() )
+ setExitCode( ZYPPER_EXIT_ERR_BUG );
+
}
}
diff --git
a/src/utils/getopt.cc
b/src/utils/getopt.cc
index
912aa9c
..
c19e17a
100644
(file)
--- a/
src/utils/getopt.cc
+++ b/
src/utils/getopt.cc
@@
-29,7
+29,10
@@
short2long_t make_short2long (const struct option *longopts) {
short2long_t result;
for (; longopts && longopts->name; ++longopts) {
if (!longopts->flag && longopts->val) {
- result[longopts->val] = longopts->name;
+ // on the fly check for duplicate short args
+ if ( ! result.insert( short2long_t::value_type( longopts->val, longopts->name ) ).second ) {
+ ZYPP_THROW(Exception(str::Str() << "duplicate short option -" << (char)longopts->val << " for --" << longopts->name << " and --" << result[longopts->val] ));
+ }
}
}
return result;