diff -ur boost_1_39_0/libs/program_options/src/options_description.cpp boost_1_39_0-sunstudio11-libcstd/libs/program_options/src/options_description.cpp --- boost_1_39_0/libs/program_options/src/options_description.cpp Sun Nov 25 19:38:02 2007 +++ boost_1_39_0-sunstudio11-libcstd/libs/program_options/src/options_description.cpp Tue Jun 16 10:30:09 2009 @@ -337,8 +337,17 @@ } else { + unsigned tabs = 0; + string::const_iterator parEnd = par.end(); + for ( string::const_iterator tp = par.begin(); + tp != parEnd && tabs <= 1; + ++tp ) + { + if ( *tp == '\t' ) + ++tabs; + } // only one tab per paragraph allowed - if (count(par.begin(), par.end(), '\t') > 1) + if (tabs > 1) { boost::throw_exception(program_options::error( "Only one tab per paragraph is allowed")); @@ -388,7 +397,10 @@ // Take care to never increment the iterator past // the end, since MSVC 8.0 (brokenly), assumes that // doing that, even if no access happens, is a bug. - unsigned remaining = distance(line_begin, par_end); + unsigned remaining = 0; + for ( string::const_iterator ipos = line_begin; + ipos != par_end; ++ipos, ++remaining ); + string::const_iterator line_end = line_begin + ((remaining < line_length) ? remaining : line_length); @@ -399,17 +411,21 @@ { // find last ' ' in the second half of the current paragraph line string::const_iterator last_space = - find(reverse_iterator(line_end), - reverse_iterator(line_begin), + find(string::const_reverse_iterator(line_end), + string::const_reverse_iterator(line_begin), ' ') .base(); if (last_space != line_begin) { + unsigned dist = 0; + for ( string::const_iterator ipos = last_space; + ipos != line_end; + ++ipos, ++dist ); + // is last_space within the second half ot the // current line - if ((unsigned)distance(last_space, line_end) < - (line_length - indent) / 2) + if (dist < (line_length - indent) / 2) { line_end = last_space; }