diff -w -b -r1.6 options_description.cpp 14a15 > #include 287c288,390 < if (!opt.description().empty()) { --- > if (!opt.description().empty()) > { > const unsigned line_length = 79; // excl. \n !! (== shell with >= 80) > > typedef boost::tokenizer > tokenizer; > > tokenizer paragraphs(opt.description(), > char_separator("\n", "", boost::keep_empty_tokens)); > > tokenizer::const_iterator pi = paragraphs.begin(); > const tokenizer::const_iterator pe = paragraphs.end(); > > bool first_descrption_line = true; > > while (pi != pe) // paragraphs > { > string str = *pi; > > unsigned new_indent = 0; > > // only one indent per paragraph makes sens, we use the last one > string::size_type tab = str.find_last_of('\t'); > > if (tab != string::npos) > { > // leading '\t' do not count for indent length! > new_indent = tab - (count(str.begin(), str.end(), '\t') - 1); > } > > // remove all '\t' > while (tab != string::npos) > { > str.erase(tab, 1); > > tab = str.find('\t'); > } > > unsigned indent = first_column_width; > > // first line of a option description (not paragraph!) has a different indent! > if (first_descrption_line) > { > first_descrption_line = false; > > for(int pad = first_column_width - ss.str().size(); pad > 0; --pad) > { > os.put(' '); > } > } > else > { > os << '\n'; > > for(int pad = indent; pad > 0; --pad) > { > os.put(' '); > } > } > > unsigned slice = line_length - indent; > > if (str.size() < slice) > { > os << str; > } > else > { > string::const_iterator i = str.begin(); > const string::const_iterator e = str.end(); > > bool first_line = true; // of current paragraph! > > while (i < e) // paragraph lines (slice) > { > if (!first_line) > { > // trimm leading single spaces > if ((*i == ' ') && > ((i + 1 < e) && (*(i + 1) != ' '))) > { > i += 1; > > // trimm slice if out of bounds > if (i + slice > e) > { > slice -= 1; > } > } > } > > // prevent chopped words > // if (lastchar != ' ') && > // (exists(lastchar + 1) && (lastchar + 1 != ' ') > if ((*(i + (slice - 1)) != ' ') && > (((i + slice) < e) && (*(i + slice) != ' '))) > { > // find last ' ' in current paragraph slice > string::size_type ls = str.find_last_of(' ', (i - str.begin()) + slice); > > if (ls != string::npos) > { > // convert ls to iterator > string::const_iterator last_space = str.begin() + ls; 289c392,417 < for(int pad = first_column_width - ss.str().size(); pad > 0; --pad) { --- > // is last_space within the second half ot the current slice > if (last_space > i + (slice / 2)) > { > slice = last_space - i; > } > } > } // privent chopped words > > os << string(i, i + slice); > > i += slice; > > if (first_line) > { > indent = first_column_width + new_indent; > first_line = false; > } > > if (i < e) > { > slice = min(line_length - indent, e - i); > > os << '\n'; > > for(int pad = indent; pad > 0; --pad) > { 292c420,425 < os << " : " << opt.description(); --- > } > } // paragraph lines (slice) > } > > ++pi; > }