|
From: Ype K. <yk...@xs...> - 2001-02-01 20:40:42
|
Dear developers,
Tried to report this via soureforge but the bugid bug
is still there.
In jython 2.0 a3 I have this:
'aaa'.count('a',0,2) == 2, ok, and
'ababab'.count('ab',0,5) == 3, should be 2 (CPython also gives 2).
'defdefdef.count('def',0,8) == 3, should also be 2.
Using blackdown java 1.3, powerpc, no jit.
You might want to add sth like this to test_string.py,
count() is untested there:
test('count', 'aaa', 3, 'a')
test('count', 'aaa', 2, 'a', 0, 2)
test('count', 'ababab', 3, 'ab', 0)
test('count', 'ababab', 2, 'ab', 0, 5)
test('count', 'ababab', 2, 'ab', 1)
test('count', 'ababab', 2, 'ab', 1, 6)
test('count', 'ababab', 0, 'abc')
test('count', 'ababab', 0, '')
Good luck, thanks for your time,
Ype
Patch against PyString.java (the first bit is only for speeding up a little,
I have to say though that it has not even been compiled):
1045,1048c1045,1048
< if (end < 0) {
< end += n;
< } else if (end > n)
< end = n;
---
> if (end < 0)
> end = n+end;
> if (end > n)
> end = n;
1053c1053
< int lastcheck = end - slen;
---
> //end = end-slen;
1056c1056
< while (start <= lastcheck) {
---
> while (start < end) {
1058c1058
< if (index == -1)
---
> if (index >= end || index == -1)
|