diff -w -b -r1.6 options_description.cpp 287c287,305 < if (!opt.description().empty()) { --- > if (!opt.description().empty()) > { > const unsigned line_length = 79; // excl. \n !! (== shell with >= 80) > > const std::string str = opt.description(); > > std::string::const_iterator i = str.begin(); > const std::string::const_iterator e = str.end(); > > bool first_line = true; > > while (i < e) > { > if (first_line) > { > for(int pad = first_column_width - ss.str().size(); pad > 0; --pad) > { > os.put(' '); > } 289c307,314 < for(int pad = first_column_width - ss.str().size(); pad > 0; --pad) { --- > first_line = false; > } > else > { > os << "\n"; > > for(unsigned pad = first_column_width; pad > 0; --pad) > { 292c317,369 < os << " : " << opt.description(); --- > } > > // the current line [i, i + slice] > std::string::difference_type slice = > min(line_length - first_column_width, > e - i); > > bool skip_one = false; > > // remove leading single spaces > if ((*i == ' ') && (((i + 1) < e) && (*(i + 1) != ' '))) > { > i += 1; > > if ((i + slice + 1) > e) > { > slice -= 1; > } > } > > // find and handle embedded new lines > std::string::const_iterator nl = find(i, i + slice, '\n'); > > if ((nl != i + slice) && (slice > 1)) > { > slice = nl - i; > skip_one = true; > } > > // try to prevent chopped words > if ((slice > 3) && > ((*(i + (slice - 1)) != ' ') && > ((i + slice < e) && ((*(i + slice) != ' ') && > (*(i + slice) != '\n'))))) > { > std::string::const_iterator last_space = i + slice - 2; > > // if word slice is more that (slice / 2) chopp it anyway > while ((last_space > (i + slice / 2)) && (*last_space != ' ')) > { > --last_space; > } > > if (last_space > (i + slice / 2)) > { > slice = last_space - i; > } > } > > os << std::string(i, i + slice); > > i += slice + (skip_one ? 1 : 0); > }