[BUG][FIX] Integer class(Object)>>error: ([er] v2 from Frank)

Doug Way dway at mailcan.com
Thu Apr 1 18:57:11 UTC 2004


Attaching Frank's fix as a real [FIX] message, so that it gets tracked.  
Boris says here that he agrees that Frank's fix is best.  (I haven't 
checked it myself.)

- Doug


Boris Gaertner wrote:

>"Frank Shearar" <frank.shearar at rnid.org.uk> wrote:
>
>When I posted an answer to Alexanders bug report, I got newest
>mails and saw that you posted exactly the fix that I posted, too.
>
>
><snip>
>  
>
>>Update 5844 (5844ANSICompatibility) introduces support for reading in float literals. These take the form <mantissa><exponentLetter><exponent>.
>>exponentLetter can be $e, $d or $q.
>>
>>Therefore, when you view Preference's class comment RunArray>>scanFrom: gets given '(220 29 81 35 812)f1,f1dPreferences
>>openFactoredPanel;;,f1,f1dPreferences giveHelpWithPreferences;;,f1'.
>>
>>The substring 'f1dPreferences' thus gets interpreted as a float literal and Number class tries to interpret the substring 'Preferences' as a sequence of digits.
>>    
>>
></snip>
>
><snip>
>  
>
>>I suppose the solution is to change RunArray>>scanFrom: to
>>Integer>>readFrom? Otherwise we'd have to not use $d in RunArray, which
>>means we'd have to change the .changes file, wouldn't we?
>>
>>I've attached a changeset which alters RunArray>>scanFrom: to use
>>Integer>>readFrom: instead of Number>>readFrom:. The three RunArray thingies that the changeset affects are TextDoIt ($d), TextAlignment ($a) and
>>TextFontReference ($F).
>>
>>The changeset does require someone more knowledgeable than I to review it - I know next to nothing about how RunArray works.
>>    
>>
></snip>
>
>I agree both with your fix and with your explanation to your fix.
>I revoke my fix and review yours.
>
>Greetings, Boris
>
>
>  
>

-------------- next part --------------
'From Squeak3.7beta of ''1 April 2004'' [latest update: #5868] on 1 April 2004 at 2:57:19 pm'!
"Change Set:		RunArrayScanFrom-fbs
Date:			1 April 2004
Author:			Frank Shearar

With update 5844, RunArray>>scanFrom: fails on '()f1dNumber new'. This happens because 1d1 is a literal float, so RunArray>>scanFrom: reads in a Number after the $f. This changeset instead reads in Integers. I've also added a small test case."!

TestCase subclass: #RunArrayTest
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Collections-Arrayed-Tests'!

!RunArray class methodsFor: 'instance creation' stamp: 'fbs 4/1/2004 14:38'!
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:"
	| rr vv aa this |
	(strm peekFor: $( ) ifFalse: [^ nil].
	rr _ OrderedCollection new.
	[strm skipSeparators.
	 strm peekFor: $)] whileFalse: 
		[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))].
		this == $f ifTrue: [aa add: 
			(TextFontChange new fontNumber: (Integer readFrom: strm))].
		this == $F ifTrue: [aa add: (TextFontReference new toFont: 
			(StrikeFont familyName: (strm upTo: $#) size: (Integer readFrom: 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"
		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"
		].
	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')
"! !


!RunArrayTest methodsFor: 'testing - instance creation' stamp: 'fbs 4/1/2004 14:56'!
testScanFromANSICompatibility
	RunArray scanFrom: (ReadStream on: '()f1dNumber new;;').
	RunArray scanFrom: (ReadStream on: '()a1death').
	RunArray scanFrom: (ReadStream on: '()F1death').! !



More information about the Squeak-dev mailing list