Changeset 6310


Ignore:
Timestamp:
Jul 9, 2008, 7:39:40 PM (13 years ago)
Author:
charles
Message:

(libT) avoid collisions between short & long getopts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/tr-getopt.c

    r6307 r6310  
    117117    const tr_option * o;
    118118
    119     for( o=opts; o->val; ++o )
    120     {
     119    /* try all the longopts first to avoid collisions between
     120       long options, and short options with args appended to them  */
     121    for( o=opts; o->val; ++o ) {
    121122        if( o->longName && (str[0]=='-') && (str[1]=='-') ) {
    122123            if( !strcmp( o->longName, str+2 ) ) {
     
    130131            }
    131132        }
    132        
     133    }
     134
     135    /* look for a matching shortopt */
     136    for( o=opts; o->val; ++o )
     137    {
    133138        if( o->shortName && (str[0]=='-') ) {
    134139            if( !strcmp( o->shortName, str+1 ) ) {
Note: See TracChangeset for help on using the changeset viewer.