Andreas Raab uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ar.315.mcz ==================== Summary ==================== Name: Collections-ar.315 Author: ar Time: 24 February 2010, 6:14:58.766 pm UUID: 6415ae24-c876-a04a-9c18-43cbc796e8b7 Ancestors: Collections-edc.314 Fix an ancient bug in RunArray class>>scanFrom: which was never triggered in the past since RunArray contents would never be empty (initialized to a TextFontChange at least). Now they can be, which unveiled the bug, namely that when a RunArray of the form: RunArray runs: #(1 1 1) values: { {}. {TextEmphasis bold}. {} }. would be stored, the last value element would be lost when reading it back. With rather hairy consequences. Also, we can afford meaningful variable names in our code instead of 'aa', 'rr', and 'vv'. =============== Diff against Collections-edc.314 =============== Item was changed: ----- Method: RunArray class>>scanFrom: (in category 'instance creation') ----- scanFrom: strm "Read the style section of a fileOut or sources file. nextChunk has already been done. We need to return a RunArray of TextAttributes of various kinds. These are written by the implementors of writeScanOn:" + | runs values attrList char | - | rr vv aa this | (strm peekFor: $( ) ifFalse: [^ nil]. + runs := OrderedCollection new. - rr := OrderedCollection new. [strm skipSeparators. strm peekFor: $)] whileFalse: + [runs add: (Number readFrom: strm)]. + values := OrderedCollection new. "Value array" + attrList := OrderedCollection new. "Attributes list" + [(char := strm next) == nil] whileFalse: [ + char == $, ifTrue: [values add: attrList asArray. attrList := OrderedCollection new]. + char == $a ifTrue: [attrList add: - [rr add: (Number readFrom: strm)]. - vv := OrderedCollection new. "Value array" - aa := OrderedCollection new. "Attributes list" - [(this := strm next) == nil] whileFalse: [ - this == $, ifTrue: [vv add: aa asArray. aa := OrderedCollection new]. - this == $a ifTrue: [aa add: (TextAlignment new alignment: (Integer readFrom: strm ifFail: [0]))]. + char == $f ifTrue: [attrList add: - this == $f ifTrue: [aa add: (TextFontChange new fontNumber: (Integer readFrom: strm ifFail: [0]))]. + char == $F ifTrue: [attrList add: (TextFontReference toFont: - this == $F ifTrue: [aa add: (TextFontReference toFont: (StrikeFont familyName: (strm upTo: $#) size: (Integer readFrom: strm ifFail: [0])))]. + char == $b ifTrue: [attrList add: (TextEmphasis bold)]. + char == $i ifTrue: [attrList add: (TextEmphasis italic)]. + char == $u ifTrue: [attrList add: (TextEmphasis underlined)]. + char == $= ifTrue: [attrList add: (TextEmphasis struckOut)]. + char == $n ifTrue: [attrList add: (TextEmphasis normal)]. + char == $- ifTrue: [attrList add: (TextKern kern: -1)]. + char == $+ ifTrue: [attrList add: (TextKern kern: 1)]. + char == $c ifTrue: [attrList add: (TextColor scanFrom: strm)]. "color" + char == $L ifTrue: [attrList add: (TextLink scanFrom: strm)]. "L not look like 1" + char == $R ifTrue: [attrList add: (TextURL scanFrom: strm)]. - this == $b ifTrue: [aa add: (TextEmphasis bold)]. - this == $i ifTrue: [aa add: (TextEmphasis italic)]. - this == $u ifTrue: [aa add: (TextEmphasis underlined)]. - this == $= ifTrue: [aa add: (TextEmphasis struckOut)]. - this == $n ifTrue: [aa add: (TextEmphasis normal)]. - this == $- ifTrue: [aa add: (TextKern kern: -1)]. - this == $+ ifTrue: [aa add: (TextKern kern: 1)]. - this == $c ifTrue: [aa add: (TextColor scanFrom: strm)]. "color" - this == $L ifTrue: [aa add: (TextLink scanFrom: strm)]. "L not look like 1" - this == $R ifTrue: [aa add: (TextURL scanFrom: strm)]. "R capitalized so it can follow a number" + char == $q ifTrue: [attrList add: (TextSqkPageLink scanFrom: strm)]. + char == $p ifTrue: [attrList add: (TextSqkProjectLink scanFrom: strm)]. + char == $P ifTrue: [attrList add: (TextPrintIt scanFrom: strm)]. + char == $d ifTrue: [attrList add: (TextDoIt scanFrom: strm)]. - this == $q ifTrue: [aa add: (TextSqkPageLink scanFrom: strm)]. - this == $p ifTrue: [aa add: (TextSqkProjectLink scanFrom: strm)]. - this == $P ifTrue: [aa add: (TextPrintIt scanFrom: strm)]. - this == $d ifTrue: [aa add: (TextDoIt scanFrom: strm)]. "space, cr do nothing" ]. + values add: attrList asArray. + ^ self runs: runs asArray values: (values copyFrom: 1 to: runs size) - aa size > 0 ifTrue: [vv add: aa asArray]. - ^ self runs: rr asArray values: vv asArray " RunArray scanFrom: (ReadStream on: '(14 50 312)f1,f1b,f1LInteger +;i') "! |
Free forum by Nabble | Edit this page |