Hi,
I made the following patch to fix a small problem pointed out by Patrick
Doyle in http://mail.gnu.org/pipermail/classpath/2001-August/001112.html
It only affects empty strings. It is based on the patch provided in
http://savannah.gnu.org/patch/?func=detailpatch&patch_id=23&group_id=85
2002-02-15 Mark Wielaard <[EMAIL PROTECTED]>
Thanks to Patrick Doyle
* java/lang/String.java (indexOf(String,int)): account for empty
string.
(lastIndexOf(String): account for empty string, and small
optimization.
(lastIndexOf(String,int): small optimization.
I also made Mauve tests that will hopefully go into Mauve.
Cheers,
Mark
? Makefile.diff
? String.diff
? announce.txt
? build
? classpath-0.03.tar.gz
? classpath.txt
? diff.patch
? eric-diff.patch
? japhar.announce
? java_files
? jikesvm.announce
? orp.announce
? updates
? gnu/java/rmi/Makefile
? gnu/java/rmi/dgc/Makefile
? gnu/java/rmi/registry/Makefile
? gnu/java/rmi/rmic/Makefile
? gnu/java/rmi/server/Makefile
? include/stamp-h1
? java/rmi/Makefile
? java/rmi/activation/Makefile
? java/rmi/dgc/Makefile
? java/rmi/registry/Makefile
? java/rmi/server/Makefile
? lib/classes.1
? lib/verify-jikes.libgcj
? lib/verifyclass
Index: java/lang/String.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/String.java,v
retrieving revision 1.36
diff -u -r1.36 String.java
--- java/lang/String.java 22 Jan 2002 22:27:00 -0000 1.36
+++ java/lang/String.java 15 Feb 2002 11:55:44 -0000
@@ -799,7 +799,7 @@
*/
public int indexOf(String str, int fromIndex) throws NullPointerException {
if (fromIndex < 0) fromIndex = 0;
- for (int i = fromIndex; i < count; i++)
+ for (int i = fromIndex; i <= count; i++)
if (regionMatches(i, str, 0, str.count))
return i;
return -1;
@@ -846,7 +846,7 @@
* @exception NullPointerException if `str' is null
*/
public int lastIndexOf(String str) throws NullPointerException {
- return lastIndexOf(str, count-1);
+ return lastIndexOf(str, count-str.count);
}
/**
@@ -864,8 +864,8 @@
*/
public int lastIndexOf(String str, int fromIndex)
throws NullPointerException {
- if (fromIndex > count)
- fromIndex = count;
+ if (fromIndex >= count)
+ fromIndex = count - str.count;
for (int i = fromIndex; i >= 0; i--)
if (regionMatches(i, str, 0, str.count))
return i;