1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 01:27:28 +00:00

(libT) avoid collisions between short & long getopts

This commit is contained in:
Charles Kerr 2008-07-09 19:39:40 +00:00
parent f5dbaca440
commit 7ea35b8afa

View file

@ -116,8 +116,9 @@ findOption( const tr_option * opts,
size_t len;
const tr_option * o;
for( o=opts; o->val; ++o )
{
/* try all the longopts first to avoid collisions between
long options, and short options with args appended to them */
for( o=opts; o->val; ++o ) {
if( o->longName && (str[0]=='-') && (str[1]=='-') ) {
if( !strcmp( o->longName, str+2 ) ) {
if( nested ) *nested = NULL;
@ -129,7 +130,11 @@ findOption( const tr_option * opts,
return o;
}
}
}
/* look for a matching shortopt */
for( o=opts; o->val; ++o )
{
if( o->shortName && (str[0]=='-') ) {
if( !strcmp( o->shortName, str+1 ) ) {
if( nested ) *nested = NULL;