Ticket #545: program_options.patch

File program_options.patch, 1.7 KB (added by christian.blichmann@…, 12 years ago)

Patch for parsing options with same name-prefix

  • libs/program_options/src/options_description.cpp

    diff -dur boost_1_43_0.orig/libs/program_options/src/options_description.cpp boost_1_43_0/libs/program_options/src/options_description.cpp
    old new  
    305305                                      bool long_ignore_case,
    306306                                      bool short_ignore_case) const
    307307    {
    308         shared_ptr<option_description> found;
     308        shared_ptr<option_description> found_approx;
     309        shared_ptr<option_description> found_full;
    309310        vector<string> approximate_matches;
    310311        vector<string> full_matches;
    311312       
     
    323324            if (r == option_description::full_match)
    324325            {               
    325326                full_matches.push_back(m_options[i]->key(name));
     327                found_full = m_options[i];
    326328            }
    327329            else
    328330            {                       
    329331                // FIXME: the use of 'key' here might not
    330332                // be the best approach.
    331333                approximate_matches.push_back(m_options[i]->key(name));
     334                found_approx = m_options[i];
    332335            }
    333 
    334             found = m_options[i];
    335336        }
    336337        if (full_matches.size() > 1)
    337338            boost::throw_exception(
     
    346347            boost::throw_exception(
    347348                ambiguous_option(name, approximate_matches));
    348349
    349         return found.get();
     350        if (!full_matches.empty())
     351            return found_full.get();
     352        return found_approx.get();
    350353    }
    351354
    352355    BOOST_PROGRAM_OPTIONS_DECL