Ticket #9329: suncc_po.diff

File suncc_po.diff, 3.7 KB (added by vz-boost@…, 9 years ago)

Proposed patch to fix the build with Sun CC

  • libs/program_options/src/options_description.cpp

    diff --git a/libs/program_options/src/options_description.cpp b/libs/program_options/src/options_description.cpp
    index 343bd30..22aaeb3 100644
    a b namespace boost { namespace program_options {  
    419419            else
    420420            {
    421421                // only one tab per paragraph allowed
    422                 if (count(par.begin(), par.end(), '\t') > 1)
     422                if (par.find('\t', par_indent+1) != string::npos)
    423423                {
    424424                    boost::throw_exception(program_options::error(
    425425                        "Only one tab per paragraph is allowed in the options description"));
    namespace boost { namespace program_options {  
    469469                    // Take care to never increment the iterator past
    470470                    // the end, since MSVC 8.0 (brokenly), assumes that
    471471                    // doing that, even if no access happens, is a bug.
    472                     unsigned remaining = static_cast<unsigned>(std::distance(line_begin, par_end));
     472                    unsigned remaining = static_cast<unsigned>(par_end - line_begin);
    473473                    string::const_iterator line_end = line_begin +
    474474                        ((remaining < line_length) ? remaining : line_length);
    475475
    namespace boost { namespace program_options {  
    479479                        ((line_end < par_end) && (*line_end != ' ')))
    480480                    {
    481481                        // find last ' ' in the second half of the current paragraph line
    482                         string::const_iterator last_space =
    483                             find(reverse_iterator<string::const_iterator>(line_end),
    484                                  reverse_iterator<string::const_iterator>(line_begin),
    485                                  ' ')
    486                             .base();
     482                        string::size_type last_space_pos = par.find(' ', line_end - par.begin());
    487483
    488                         if (last_space != line_begin)
     484                        if (last_space_pos != string::npos &&
     485                            last_space_pos > (line_begin - par.begin()))
    489486                        {
    490                             // is last_space within the second half ot the
     487                            // is last space within the second half of the
    491488                            // current line
    492                             if (static_cast<unsigned>(std::distance(last_space, line_end)) <
     489                            if (static_cast<unsigned>(par.length() - last_space_pos) <
    493490                                (line_length / 2))
    494491                            {
    495                                 line_end = last_space;
     492                                line_end = par.begin() + last_space_pos;
    496493                            }
    497494                        }
    498495                    } // prevent chopped words
  • libs/program_options/src/value_semantic.cpp

    diff --git a/libs/program_options/src/value_semantic.cpp b/libs/program_options/src/value_semantic.cpp
    index 5314029..647550e 100644
    a b namespace boost { namespace program_options {  
    368368        string error_template  = original_error_template;
    369369        // remove duplicates using std::set
    370370        std::set<std::string>   alternatives_set (m_alternatives.begin(), m_alternatives.end());
    371         std::vector<std::string> alternatives_vec (alternatives_set.begin(), alternatives_set.end());
     371        std::vector<std::string> alternatives_vec;
     372        copy(alternatives_set.begin(), alternatives_set.end(), back_inserter(alternatives_vec));
    372373
    373374        error_template += " and matches ";
    374375        // Being very cautious: should be > 1 alternative!