[BUG] String>>findFirstInString:inSet:startingAt: does not work if character of interest is last character in String, also WideString

John M McIntosh johnmci at smalltalkconsulting.com
Tue May 9 06:03:32 UTC 2006


IN the XMLWriter class try

String findFirstInString: ' "' inSet: XMLTranslationMap startingAt: 1.

This should return 2, because " is an entry in the XMLTranslationMap,  
however it return 0, because the code does not consider the last  
character in the string could be a character we are interested in.

I'll note ByteString has a primitive that implements this method and  
that primitive does the correct thing.

mmm perhaps a simpler  example.

this example

'hi-' asWideString  indexOfAnyOf: (CharacterSet newFrom: ' -0123456789 

that fails and returns zero.

the follow example works, because 'hi-' is a ByteString and the  
method call resolves to asking the  class of the object to invoke the  
findFirstInString:inSet:startingAt:  found in ByteString which is the  
primitive call.

'hi-'  indexOfAnyOf: (CharacterSet newFrom: ' -0123456789{}')

John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com

More information about the Squeak-dev mailing list