diff --git a/include/tclap/SwitchArg.h b/include/tclap/SwitchArg.h index eca1650..da04feb 100644 --- a/include/tclap/SwitchArg.h +++ b/include/tclap/SwitchArg.h @@ -150,7 +150,8 @@ inline bool SwitchArg::combinedSwitchesMatch(std::string& combinedSwitches ) // ok, we're not specifying a ValueArg, so we know that we have // a combined switch list. for ( unsigned int i = 1; i < combinedSwitches.length(); i++ ) - if ( combinedSwitches[i] == _flag[0] ) + if ( combinedSwitches[i] == _flag[0] && + _flag[0] != Arg::flagStartString()[0] ) { // update the combined switches so this one is no longer present // this is necessary so that no unlabeled args are matched diff --git a/tests/Makefile.am b/tests/Makefile.am index 8f9335c..0ac90dc 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -59,7 +59,8 @@ TESTS = test1.sh \ test57.sh \ test58.sh \ test59.sh \ - test60.sh + test60.sh \ + test61.sh EXTRA_DIST = $(TESTS) \ test1.out \ @@ -121,6 +122,7 @@ EXTRA_DIST = $(TESTS) \ test57.out \ test58.out \ test59.out \ - test60.out + test60.out \ + test61.out CLEANFILES = tmp.out diff --git a/tests/test61.out b/tests/test61.out new file mode 100644 index 0000000..66777a6 --- /dev/null +++ b/tests/test61.out @@ -0,0 +1,7 @@ +for float we got : 3.7 +for int we got : 10 +for string we got : hello +for ulabeled we got : -1 -1 +for bool A we got : 0 +for bool B we got : 0 +for bool C we got : 0 diff --git a/tests/test61.sh b/tests/test61.sh new file mode 100755 index 0000000..a402880 --- /dev/null +++ b/tests/test61.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# this tests a bug in handling of - chars in Unlabeled args +# success +../examples/test2 -i 10 -s hello "-1 -1" > tmp.out 2>&1 + +if cmp -s tmp.out $srcdir/test61.out; then + exit 0 +else + exit 1 +fi +