Fix for String>withBlanksTrimmed in 1.3

Georg Gollmann gollmann at edvz.tuwien.ac.at
Fri Jan 30 09:11:56 UTC 1998


String>withBlanksTrimmed breaks on empty strings in Squeak 1.3, here is a fix:

!String methodsFor: 'converting' stamp: 'go 1/29/98 13:25'!
withBlanksTrimmed
	"Return a copy of the receiver from which leading and trailing blanks
	 have been trimmed.
	 Simplified by Gerardo Richarte 11/3/97.
	 Fixed for empty strings by go 1/29/98 13:24"

	self size = 0 ifTrue: [ ^self ].
	^ self
		copyFrom: (self findFirst: [:eachChar | eachChar
isSeparator not])
		to: (self findLast: [:eachChar | eachChar isSeparator not])

	" ' abc  d   ' withBlanksTrimmed"! !

Georg

----
Dipl.Ing. Georg Gollmann                   TU-Wien, EDV-Zentrum

phon:(+43-1) 58801 - 5848
fax: (+43-1) 587 42 11
mail:gollmann at edvz.tuwien.ac.at
http://macos.tuwien.ac.at/Gollmann.html





More information about the Squeak-dev mailing list