Bert Freudenberg uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-bf.502.mcz ==================== Summary ==================== Name: Collections-bf.502 Author: bf Time: 2 March 2013, 1:45:38.248 pm UUID: 87a84004-6bba-4930-acf3-a86574e1f415 Ancestors: Collections-fbs.501 Sundry changes: * deal with "[:" and "{}" in String>>findSelector * process numeric entities in String>>asUnHtml * remove PositionableStream>>last (unused, buggy) =============== Diff against Collections-fbs.501 =============== Item was removed: - ----- Method: PositionableStream>>last (in category 'accessing') ----- - last - "Return the final element in the receiver" - - ^ collection at: position! Item was changed: ----- Method: String>>asUnHtml (in category 'converting') ----- asUnHtml "Strip out all Html stuff (commands in angle brackets <>) and convert the characters &<> back to their real value. Leave actual cr and tab as they were in text." | in out char rest | in := ReadStream on: self. out := WriteStream on: (String new: self size). [in atEnd] whileFalse: [in peek = $< ifTrue: [in unCommand] "Absorb <...><...>" ifFalse: [(char := in next) = $& ifTrue: [rest := in upTo: $;. out nextPut: (HtmlEntities at: rest + ifAbsent: [ + (rest beginsWith: '#') + ifTrue: [Character value: rest allButFirst asInteger] + ifFalse: [Character space]])] - ifAbsent: [Character space])] ifFalse: [out nextPut: char]]. ]. ^ out contents! Item was changed: ----- Method: String>>findSelector (in category 'converting') ----- findSelector "Dan's code for hunting down selectors with keyword parts; while this doesn't give a true parse, in most cases it does what we want, in where it doesn't, we're none the worse for it." | sel possibleParens | sel := self withBlanksTrimmed. (sel includes: $:) ifTrue: [sel := sel copyReplaceAll: ':' with: ': '. "for the style (aa max:bb) with no space" + sel := sel copyReplaceAll: '[:' with: '[ :'. "for the style ([:a) with no space" possibleParens := sel findTokens: Character separators. sel := self class streamContents: [:s | | level | + level := 0. - level := 0. possibleParens do: + [:token | - [:token | | n | (level = 0 and: [token endsWith: ':']) ifTrue: [s nextPutAll: token] + ifFalse: [level := level + + (token occurrencesOf: $() - (token occurrencesOf: $)) + + (token occurrencesOf: $[) - (token occurrencesOf: $]) + + (token occurrencesOf: ${) - (token occurrencesOf: $})]]]]. - ifFalse: [(n := token occurrencesOf: $( ) > 0 ifTrue: [level := level + n]. - (n := token occurrencesOf: $[ ) > 0 ifTrue: [level := level + n]. - (n := token occurrencesOf: $] ) > 0 ifTrue: [level := level - n]. - (n := token occurrencesOf: $) ) > 0 ifTrue: [level := level - n]]]]]. - sel isEmpty ifTrue: [^ nil]. sel isOctetString ifTrue: [sel := sel asOctetString]. Symbol hasInterned: sel ifTrue: [:aSymbol | ^ aSymbol]. ^ nil! |
The last build on CI server showed that #last is still being used from
many places. While it might be ambiguous in PositionableStream, we need an alternative in ReadStream. Levente On Sat, 2 Mar 2013, [hidden email] wrote: > Bert Freudenberg uploaded a new version of Collections to project The Trunk: > http://source.squeak.org/trunk/Collections-bf.502.mcz > > ==================== Summary ==================== > > Name: Collections-bf.502 > Author: bf > Time: 2 March 2013, 1:45:38.248 pm > UUID: 87a84004-6bba-4930-acf3-a86574e1f415 > Ancestors: Collections-fbs.501 > > Sundry changes: > * deal with "[:" and "{}" in String>>findSelector > * process numeric entities in String>>asUnHtml > * remove PositionableStream>>last (unused, buggy) > > =============== Diff against Collections-fbs.501 =============== > > Item was removed: > - ----- Method: PositionableStream>>last (in category 'accessing') ----- > - last > - "Return the final element in the receiver" > - > - ^ collection at: position! > > Item was changed: > ----- Method: String>>asUnHtml (in category 'converting') ----- > asUnHtml > "Strip out all Html stuff (commands in angle brackets <>) and convert > the characters &<> back to their real value. Leave actual cr and tab as > they were in text." > | in out char rest | > in := ReadStream on: self. > out := WriteStream on: (String new: self size). > [in atEnd] whileFalse: > [in peek = $< > ifTrue: [in unCommand] "Absorb <...><...>" > ifFalse: [(char := in next) = $& > ifTrue: [rest := in upTo: $;. > out nextPut: (HtmlEntities > at: rest > + ifAbsent: [ > + (rest beginsWith: '#') > + ifTrue: [Character value: rest allButFirst asInteger] > + ifFalse: [Character space]])] > - ifAbsent: [Character space])] > ifFalse: [out nextPut: char]]. > ]. > ^ out contents! > > Item was changed: > ----- Method: String>>findSelector (in category 'converting') ----- > findSelector > "Dan's code for hunting down selectors with keyword parts; while this doesn't give a true parse, in most cases it does what we want, in where it doesn't, we're none the worse for it." > | sel possibleParens | > sel := self withBlanksTrimmed. > (sel includes: $:) ifTrue: > [sel := sel copyReplaceAll: ':' with: ': '. "for the style (aa max:bb) with no space" > + sel := sel copyReplaceAll: '[:' with: '[ :'. "for the style ([:a) with no space" > possibleParens := sel findTokens: Character separators. > sel := self class streamContents: > [:s | | level | > + level := 0. > - level := 0. > possibleParens do: > + [:token | > - [:token | | n | > (level = 0 and: [token endsWith: ':']) > ifTrue: [s nextPutAll: token] > + ifFalse: [level := level > + + (token occurrencesOf: $() - (token occurrencesOf: $)) > + + (token occurrencesOf: $[) - (token occurrencesOf: $]) > + + (token occurrencesOf: ${) - (token occurrencesOf: $})]]]]. > - ifFalse: [(n := token occurrencesOf: $( ) > 0 ifTrue: [level := level + n]. > - (n := token occurrencesOf: $[ ) > 0 ifTrue: [level := level + n]. > - (n := token occurrencesOf: $] ) > 0 ifTrue: [level := level - n]. > - (n := token occurrencesOf: $) ) > 0 ifTrue: [level := level - n]]]]]. > - > sel isEmpty ifTrue: [^ nil]. > sel isOctetString ifTrue: [sel := sel asOctetString]. > Symbol hasInterned: sel ifTrue: > [:aSymbol | ^ aSymbol]. > ^ nil! > > > |
Maybe it's just the comment that's wrong? That it's not the "final element" but the one that was just read using #next? Then it would make sense, although I'd prefer a different selector.
| s | s := 'hello' readStream. s next == s last ==> true I've put it back with a better comment for now. (*) But maybe we should rather fix DateAndTime class>>readFrom:, which appears to be the only place this is used? Actually, it seems Time class>>readFrom: is at fault for reading beyond the end of the time. Also, its indentation is totally misleading. Yep, that looks better, committed as Kernel-bf.744. Test's are green, too. Now we just might want to deprecate #last? - Bert - (*) also came across the totally weird #peekBack. That surely must be a prime candidate for deprecation, no? On 2013-03-03, at 03:16, Levente Uzonyi <[hidden email]> wrote: > The last build on CI server showed that #last is still being used from many places. While it might be ambiguous in PositionableStream, we need an alternative in ReadStream. > > > Levente > > On Sat, 2 Mar 2013, [hidden email] wrote: > >> Name: Collections-bf.502 >> >> Item was removed: >> - ----- Method: PositionableStream>>last (in category 'accessing') ----- >> - last >> - "Return the final element in the receiver" >> - >> - ^ collection at: position! |
Free forum by Nabble | Edit this page |