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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

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

johnmci
Mantis
http://bugs.impara.de/view.php?id=3574

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 <[hidden email]> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
========================================================================
===


Reply | Threaded
Open this post in threaded view
|

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

Nicolas Cellier-3
Le Mardi 09 Mai 2006 08:03, John M McIntosh a écrit :

> Mantis
> http://bugs.impara.de/view.php?id=3574
>
>...
>
> this example
>
> 'hi-' asWideString  indexOfAnyOf: (CharacterSet newFrom: ' -0123456789
> {}')
>
> that fails and returns zero.
>

It is easy to make this example work (off by one error see patch on mantis),
but this method is really for ByteString !

I mean you cannot put a wide character in the CharacterSet..., then you cannot
search for wide characters...

Nicolas


Reply | Threaded
Open this post in threaded view
|

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

Nicolas Cellier-3
Le Mardi 09 Mai 2006 20:32, nicolas cellier a écrit :
> I mean you cannot put a wide character in the CharacterSet..., then you
> cannot search for wide characters...
>
> Nicolas

With second patch at http://bugs.impara.de/view.php?id=3574 we now can.

Nicolas


Reply | Threaded
Open this post in threaded view
|

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

stéphane ducasse-2
In reply to this post by johnmci
I hope I will find tests on mantis :)

Stef

On 9 mai 06, at 08:03, John M McIntosh wrote:

> Mantis
> http://bugs.impara.de/view.php?id=3574
>
> 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 <[hidden email]> 1-800-477-2659
> Corporate Smalltalk Consulting Ltd.  http://
> www.smalltalkconsulting.com
> ======================================================================
> =====
>
>