SYSTEM WARNING: Creating default object from empty value

Mantis - Squeak
Viewing Issue Advanced Details
3574 Collections major always 05-09-06 07:08 04-18-10 22:05
johnmci  
andreas  
normal  
closed 3.9  
fixed  
none    
none trunk  
0003574: String>>findFirstInString:inSet:startingAt: does not work if character of interest is last character in String, also WideString
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.

Perhaps code should look like

String>>findFirstInString: aString inSet: inclusionMap startingAt: start
    "Trivial, non-primitive version"
    | i stringSize ascii more |
    inclusionMap size ~= 256 ifTrue: [^ 0].
    stringSize _ aString size.
    more _ true.
    i _ start - 1.
    [more and: [i + 1 <= stringSize]] whileTrue: [
        i _ i + 1.
        ascii _ (aString at: i) asciiValue.
        more _ ascii < 256 ifTrue: [(inclusionMap at: ascii + 1) = 0] ifFalse: [true].
    ].
    (more not and: [i = stringSize]) ifTrue: [^i].
    i + 1 > stringSize ifTrue: [^ 0].
    ^ i

Also see WideString which is also I think is broken.
related to 0006366closed andreas [BUG] WideString findString:startingAt: and other matchTable problems 
related to 0005331closed andreas 'abc' beginsWith: 'ab' asWideString (returns wrong result) 
 Collection-String-IndexOf-Patch.1.cs [^] (612 bytes) 05-09-06 20:17
 Collection-String-IndexOf-Test.1.cs [^] (1,559 bytes) 05-09-06 20:27
 Collection-String-IndexOf-Patch.2.cs [^] (8,528 bytes) 05-10-06 00:27
 Collection-String-IndexOf-Test.2.cs [^] (1,987 bytes) 05-10-06 00:27
 Collection-String-IndexOf-Patch.3.cs [^] (8,536 bytes) 03-15-07 20:04
 Collection-String-IndexOf-Test.3.cs [^] (2,165 bytes) 03-15-07 20:05
 WideCharacterSet-M3574-Patch.1.cs [^] (469 bytes) 09-25-07 19:06
 WideCharacterSet-M3574-nice-hashPatch.1.cs [^] (832 bytes) 11-15-07 20:26
 WideCharacterSet-M3574-nice-newFrom.1.cs [^] (552 bytes) 11-15-07 21:34
 WideCharacterSet-M3574-nice-Test.1.cs [^] (3,501 bytes) 11-19-07 22:32
 WideCharacterSet-copy-Test-M3574-nice.1.cs [^] (646 bytes) 11-19-07 23:50
 WideCharacterSet-copy-Patch-M3574-nice.1.cs [^] (729 bytes) 11-19-07 23:50

Notes
(0004895)
nicolas cellier   
05-09-06 20:20   
[FIX] provided in attachment.

With this patch, we can now search for ordinary characters (asciiValue < 256) in WideString.
This patch still does not handle searching the index of wide characters...
(0004896)
nicolas cellier   
05-10-06 00:26   
[FIX] second fix and test in attachment

Now, there is a WideCharacterSet transparentely handling Wide Characters (thanks to CharacterSet>>become:).

We can search wide Characters in ByteString (use existing primitive with byte character subsets), and also in WideString.

(0005946)
MarcusDenker   
07-15-06 18:03   
test is added
(0008793)
black   
01-02-07 22:24   
This fix was posted 7 months ago. Unless there is reason to believe that it is defective, isn't it time to include it in the image?
(0008828)
Keith_Hodges   
01-05-07 09:25   
"fix begin"
Installer mantis bug: 3574 fix: 'Collection-String-IndexOf-Patch.2.cs'.
"fix test"
Installer mantis bug: 3574 fix: 'Collection-String-IndexOf-Test.2.cs'.
"fix end"
(0010444)
johnmci   
03-15-07 00:14   
findFirstInString: aString inCharacterSet: aCharacterSet startingAt: start
    "Trivial, non-primitive version"
    
    1
        to: aString size
        do: [:i | (aCharacterSet
                    includes: (aString at: i))
                ifTrue: [^ i]].
    ^ 0


This changed method does not consider 'start', thus apparently does the wrong thing.
(0010445)
nicolas cellier   
03-15-07 20:04   
Oops... well found!
Obviously a lack of testing !

"fix begin"
Installer mantis bug: 3574 fix: 'Collection-String-IndexOf-Patch.3.cs'.
"fix test"
Installer mantis bug: 3574 fix: 'Collection-String-IndexOf-Test.3.cs'.
"fix end"
(0010481)
edgardec   
03-30-07 13:46   
This now is 7071StringFindFirstInStringinSetstartingAt.cs and was in the 3.10 updates.
Thanks all
(0011206)
nicolas cellier   
09-25-07 19:05   
Gasp! in 3.10 image, i browsed the senders of self, and WideCharacterSet is, the classical bug of omitting the period at the end of previous sentence!

So I reopen the bug.
Please upload WideCharacterSet-M3574-Patch.1.cs
(0011438)
nicolas cellier   
11-15-07 20:29   
Following http://lists.squeakfoundation.org/pipermail/squeak-dev/2007-November/122292.html, [^]

hash is bugged. it sends an unimplemented message (due to some untested refactoring).

moreover, since WideCharacterSet can equal ordinary CharacterSet, hash has to care of it, what it did not.

WideCharacterSet-M3574-nice-hashPatch.1.cs is a patch correcting this behavior.
(0011440)
nicolas cellier   
11-15-07 21:35   
A convenient #newFrom: instance creation method was missing.

WideCharacterSet-M3574-nice-newFrom.1.cs adds it.
(0011446)
nicolas cellier   
11-19-07 22:33   
WideCharacterSet-M3574-nice-Test.1.cs now adds a few tests to WideCharacterSet itself...
(0011449)
nicolas cellier   
11-19-07 23:55   
copy is bugged also (see 0006777).
Please find test and patch again...
(0011570)
Keith_Hodges   
12-17-07 17:46   
"fix begin"
Installer mantis bug: 3574 fix:'Collection-String-IndexOf-Test.3.cs'.
Installer mantis bug: 3574 fix:'WideCharacterSet-M3574-Patch.1.cs'.
Installer mantis bug: 3574 fix:'WideCharacterSet-M3574-nice-hashPatch.1.cs'.
Installer mantis bug: 3574 fix:'WideCharacterSet-M3574-nice-newFrom.1.cs'.
Installer mantis bug: 3574 fix:'WideCharacterSet-copy-Patch-M3574-nice.1.cs'.
"fix test"
Installer mantis bug: 3574 fix:'Collection-String-IndexOf-Test.3.cs'.
Installer mantis bug: 3574 fix:'WideCharacterSet-M3574-nice-Test.1.cs'.
Installer mantis bug: 3574 fix:'WideCharacterSet-copy-Test-M3574-nice.1.cs'.
"fix end"

(0012328)
ducasse   
07-03-08 20:30   
in pharo 10049
(0013307)
nicolas cellier   
09-14-09 23:27   
main bug fixed in 3.10
colateral bugs introduced in 3.10 later fixed in
http://source.squeak.org/trunk/Collections-nice.132.mcz [^]
http://source.squeak.org/trunk/CollectionsTests-nice.95.mcz [^]