Nicolas Cellier uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-nice.298.mcz==================== Summary ====================
Name: Collections-nice.298
Author: nice
Time: 8 February 2010, 12:27:22.955 pm
UUID: d1b2f5ef-522f-234d-b32a-0854961f312c
Ancestors: Collections-nice.297
indentationIfBlank: did not handle lines with or without line ending character the same
{
(String with: Character tab with: Character space) indentationIfBlank: [:x | nil].
(String with: Character tab with: Character space with: Character cr) indentationIfBlank: [:x | nil].
}
did return #(1 nil), now return #(nil nil)
=============== Diff against Collections-nice.297 ===============
Item was changed:
----- Method: String>>indentationIfBlank: (in category 'paragraph support') -----
indentationIfBlank: aBlock
"Answer the number of leading tabs in the receiver. If there are
no visible characters, pass the number of tabs to aBlock and return its value."
+ | leadingTabs nonTab nonTabIndex nonSepIndex lineEndIndex |
+ nonTab := (CharacterSet with: Character tab) complement.
+ nonTabIndex := self indexOfAnyOf: nonTab startingAt: 1.
+ nonTabIndex = 0 ifTrue: [
+ "Only made of tabs or empty"
+ ^aBlock value: self size].
+ leadingTabs := nonTabIndex - 1.
+ nonSepIndex := self indexOfAnyOf: CSNonSeparators startingAt: 1.
+ nonSepIndex = 0 ifTrue: [
+ "Only made of separators"
+ ^aBlock value: leadingTabs].
+ lineEndIndex := self indexOfAnyOf: CSLineEnders startingAt: 1.
+ (lineEndIndex between: 1 and: nonSepIndex) ifTrue: [
+ "Only made of separators up to a line end"
+ ^aBlock value: leadingTabs].
+ ^leadingTabs!
- | reader leadingTabs lastSeparator tab ch |
- tab := Character tab.
- reader := ReadStream on: self.
- leadingTabs := 0.
- [reader atEnd not and: [(ch := reader next) = tab]]
- whileTrue: [leadingTabs := leadingTabs + 1].
- lastSeparator := leadingTabs.
- [reader atEnd not and: [ch isSeparator and: [(CSLineEnders includes: ch) not]]]
- whileTrue: [lastSeparator := lastSeparator + 1. ch := reader next].
- (lastSeparator >= self size or: [CSLineEnders includes: ch])
- ifTrue: [^aBlock value: leadingTabs].
- ^ leadingTabs!