Michael Matz wrote:
Hi Jano,
On Wed, 25 Mar 2009, Ján Kupec wrote:
Fixed enless loop in word-longer-than-screen case. --- src/utils/text.cc | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/src/utils/text.cc b/src/utils/text.cc + bool wanthyphen = false; + // A single word is longer than the wrap width. Split the word and + // append a hyphen at the end of the line. This won't normally happen, + // but it can eventually happen e.g. with paths or too low screen widths.
It's usually better to _not_ mangle the output string in case it's overlong. It only creates problems with copy&paste, and still isn't more readable, especially for the words that usually are overlong, namely URLs and the like (lets ignore finnish or gaelic location names). Just leave out the hyphen if you don't find any good place to split. Also (and that's important) don't add an eol explicitely if you overflow the screenwidth, let it overflow by the normal terminal wrap-around. The visual effect is the same
I agree, but this function also supports indentation. But i could still make an exception in case indent == 0. Thanx for the suggestion.
but again for copy&paste it makes a difference (when you explicitely output an eol the terminal has no way of knowing that the thing starting at the next line actually is a continuation).
true
+ //! \todo make word-splitting more intelligent, e.g. if the word already + //! contains a hyphen, split there; do not split because + //! of a non-alphabet character; do not leave orphans, etc... + if (linep == prevwp) + { + prevwp = s - 2; + wanthyphen = true; + } + // update the size of the string to read s_bytes -= (prevwp - linep); // print the line, leave linep point to the start of the last word. for (; linep < prevwp; ++linep) out << *linep; + if (wanthyphen) + out << "-"; out << endl;
-- cheers, jano Ján Kupec YaST team ---------------------------------------------------------(PGP)--- Key ID: 637EE901 Fingerprint: 93B9 C79B 2D20 51C3 800B E09B 8048 46A6 637E E901 ---------------------------------------------------------(IRC)--- Server: irc.freenode.net Nick: jniq Channels: #zypp #yast #suse #susecz ---------------------------------------------------------(EOF)---