Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 24, 2006, 4:28:02 PM (18 years ago)
Author:
rennerc
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/preferences/src/lib/parser/cmdline_parser/cmdline_parser.cc

    r7241 r7243  
    5757 
    5858  for ( int i = 1; i<argc; i++ )
    59     args.push_back( argv[i] );
     59  {
     60    std::string s = argv[i];
     61   
     62    if ( s.find( "=" ) == std::string::npos )
     63    {
     64      args.push_back(s);
     65    }
     66    else
     67    {
     68      std::string op = s;
     69      std::string ar = s;
     70      op.erase( op.find("=") );
     71      ar.erase( 0, ar.find("=")+1);
     72     
     73      PRINTF(0)("'%s' '%s'\n", op.c_str(), ar.c_str());
     74      args.push_back( op );
     75      args.push_back( ar );
     76    }
     77  }
    6078 
    6179  int i = 0;
     
    7694        if ( it->numArgs + i >= args.size() )
    7795        {
    78           PRINTF(1)( "%s needs %d arguments!", args[i].c_str(), it->numArgs );
     96          PRINTF(1)( "%s needs %d arguments!\n", args[i].c_str(), it->numArgs );
     97          return false;
    7998        }
    8099       
    81         std::vector<std::string> argArgs;
     100        std::vector<MultiType> argArgs;
    82101       
    83         for ( int j = 0; j < it->numArgs; j++ )
     102        for ( int j = 1; j <= it->numArgs; j++ )
    84103          argArgs.push_back( args[i+j] );
    85104       
     
    87106          return false;
    88107       
    89         i += it->numArgs;
     108        i += it->numArgs + 1;
    90109       
    91110        if ( finish )
     
    121140      arg.erase( 0, 2 );
    122141     
    123       if ( arg.find('%') != std::string::npos )
     142      if ( entry.longOption.find('%') != std::string::npos )
    124143      {
    125144        //TODO implement bether match algo
    126         assert( arg.find('%') == arg.length()-1 );
    127         arg.erase( arg.length()-1, 1 );
    128         return entry.longOption.find( arg ) == 0;
     145        assert( entry.longOption.find('%') == entry.longOption.length()-1 );
     146        std::string lo = entry.longOption;
     147        lo.erase( lo.length()-1, 1 );
     148        PRINTF(0)("%s %s\n", arg.c_str(), lo.c_str());
     149        return arg.find( lo ) == 0;
    129150      }
    130151      else
    131152      {
    132         return entry.longOption == arg;
     153        return arg.find( entry.longOption ) != std::string::npos;
    133154      }
    134155    }
     
    140161        return false;
    141162      }
    142       finish = false;
     163      finish = arg.length()==2;
    143164      return arg.find(entry.shortOption) != std::string::npos;
    144165    }
Note: See TracChangeset for help on using the changeset viewer.