Boost logo

Boost :

From: Trent Nelson (tnelson_at_[hidden])
Date: 2006-04-17 22:20:14


Hi,

With regards to the following lines in the latest version (1.16) of
program_options's options_description.cpp:

395: line_end = line_begin + line_length;
396: if (line_end > par_end)
397: {
398: line_end = par_end;
399: }

Line 395 causes VC8 to throw a runtime assertion error when processing
the last line of a multiline option description. This is because
'line_begin + line_length' will exceed the actual length of the string,
and it seems VC8 is pretty intent on not letting that happen, despite
the fact we correct it in following line.

Following patch did the trick for me:

--- options_description-1.16.cpp 2006-04-18 02:39:51.401147200
+0100
+++ options_description.cpp 2006-04-18 03:04:05.722358400 +0100
@@ -390,13 +390,13 @@
                         }
                     }
 
- string::const_iterator line_end;
+ string::const_iterator line_end = line_begin;
+ unsigned remaining = unsigned(distance(line_begin,
par_end));
 
- line_end = line_begin + line_length;
- if (line_end > par_end)
- {
- line_end = par_end;
- }
+ // line_end will be determined by either the end of
the
+ // current paragraph (remaining), or the current
line
+ // length, which ever is less.
+ line_end += ((remaining < line_length) ? remaining
: line_length);
             
                     // prevent chopped words
                     // Is line_end between two non-space characters?




Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk