Andreas Raab uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ar.278.mcz==================== Summary ====================
Name: Collections-ar.278
Author: ar
Time: 11 January 2010, 8:02:24.751 pm
UUID: d4f9bb76-0a96-214d-a374-19454fc1e221
Ancestors: Collections-ul.277
Fix for withNoLineLongerThan: bug.
=============== Diff against Collections-ul.277 ===============
Item was changed:
----- Method: String>>withNoLineLongerThan: (in category 'converting') -----
withNoLineLongerThan: aNumber
"Answer a string with the same content as receiver, but rewrapped so that no line has more characters than the given number"
aNumber isNumber not | (aNumber < 1) ifTrue: [self error: 'too narrow'].
^self class
new: self size * (aNumber + 1) // aNumber "provision for supplementary line breaks"
streamContents: [ :stream |
self lineIndicesDo: [ :start :endWithoutDelimiters :end | | lineStart |
+ lineStart := (self indexOfAnyOf: CSNonSeparators startingAt: start ifAbsent: [endWithoutDelimiters + 1]) min: endWithoutDelimiters.
- lineStart := self indexOfAnyOf: CSNonSeparators startingAt: start ifAbsent: [endWithoutDelimiters + 1].
[| lineEnd spacePosition |
lineEnd := 0.
spacePosition := lineStart.
[spacePosition := self indexOfAnyOf: CSSeparators startingAt: spacePosition + 1 ifAbsent: [lineStart + aNumber + 1].
spacePosition - lineStart <= (aNumber min: endWithoutDelimiters - lineStart)]
whileTrue: [lineEnd := spacePosition].
lineEnd = 0
ifTrue: ["no space - split arbitrarily"
lineEnd := lineStart + aNumber - 1 min: endWithoutDelimiters.
stream nextPutAll: (self copyFrom: lineStart to: lineEnd).
lineStart := lineEnd + 1]
ifFalse: ["split before space"
stream nextPutAll: (self copyFrom: lineStart to: lineEnd - 1).
"eliminate conscutive spaces at split"
lineStart := self indexOfAnyOf: CSNonSeparators startingAt: lineEnd + 1 ifAbsent: [endWithoutDelimiters + 1] ].
lineStart <= endWithoutDelimiters ]
whileTrue: [stream cr].
stream nextPutAll: (self copyFrom: endWithoutDelimiters + 1 to: end) ] ]!