Chris Muller uploaded a new version of Collections to project The Trunk: http://source.squeak.org/trunk/Collections-cmm.1019.mcz
==================== Summary ====================
Name: Collections-cmm.1019 Author: cmm Time: 13 July 2022, 3:32:00.282033 pm UUID: 0a992532-c6b1-4b44-9da5-e9f3cf55dc50 Ancestors: Collections-cmm.1018
- Disallow Unicode tokens with #format:.
=============== Diff against Collections-cmm.1018 ===============
Item was changed: ----- Method: String>>format: (in category 'formatting') ----- format: aCollection "Substitute tokens in the receiver with element values of aCollection. The tokens are indicated in curly-braces and may be either numeric, e.g., {1}, {2}, etc. and map to a SequenceableCollection, OR, alphanumeric, e.g., {name}, {date}, etc., in which case aCollection should be a Dictionary. The values can be static or, with the specification of a Block element, dynamic. Simplest examples: 'foo {date} bar' format: ({'date'->Date today} as: Dictionary).
Dynamic calculation is allowed via Blocks. 'foo {NOW} bar' format: ({'NOW'-> [DateAndTime now]} as: Dictionary).
Backward-compatible with numeric-only #format: 'foo {1} bar' format: {Date today}.
Now with block support: 'foo {1} bar' format: {[Date today]}. Complete example with escaped characters: '{ } \ foo {1} bar {2}' format: {12. 'string'}. '{ } \ foo {FOO} bar {BAR}' format: ({'FOO'->12. 'BAR'->'string'} as: Dictionary)." ^ self class new: self size * 11 // 10 "ready for +10% growth" streamContents: [ : output | | lastIndex nextIndex key | lastIndex := 1. key := 0. [ "stream to output until first { or " (nextIndex := self indexOfAnyOf: FormatCharacterSet startingAt: lastIndex) = 0 ] whileFalse: [ nextIndex = lastIndex ifFalse: [ output next: nextIndex - lastIndex putAll: self startingAt: lastIndex ]. "special char hit, escape char?" (self at: nextIndex) == $\ ifTrue: [ "transfer the escaped character. " output nextPut: (self at: (nextIndex := nextIndex + 1)) ] ifFalse: [ | nextKeyChar | "${ char, parse the key" [ nextKeyChar := self at: (nextIndex := nextIndex + 1). + nextKeyChar isAscii and: [ nextKeyChar isAlphaNumeric ] ] whileTrue: + [ (key isInteger and: [ nextKeyChar between: $0 and: $9 ]) - nextKeyChar isAlphaNumeric ] whileTrue: - [ (key isInteger and: [ nextKeyChar isDigit ]) ifTrue: [ key := key * 10 + nextKeyChar digitValue ] ifFalse: [ key isInteger ifTrue: [ key := WriteStream with: (key isZero ifTrue: [ String empty ] ifFalse: [ key asString ]) ]. key nextPut: nextKeyChar ] ]. + nextKeyChar == $} ifFalse: [ self error: '$} expected' translated ]. - nextKeyChar = $} ifFalse: [ self error: '$} expected' ]. key isInteger ifTrue: [ output nextPutAll: (aCollection at: key) value asString. key := 0 ] ifFalse: [ output nextPutAll: (aCollection at: key contents) value asString. key reset ] ]. lastIndex := nextIndex + 1 ]. lastIndex <= self size ifTrue: [ output next: self size - lastIndex + 1 putAll: self startingAt: lastIndex ] ]!
packages@lists.squeakfoundation.org