[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [patch] pr 12350, java.lang.StringBuffer.substring.
From: |
Bryce McKinlay |
Subject: |
Re: [patch] pr 12350, java.lang.StringBuffer.substring. |
Date: |
Mon, 22 Sep 2003 20:23:14 +1200 |
On Sunday, Sep 21, 2003, at 21:06 Pacific/Auckland, Ralph Loader wrote:
java.lang.StringBuffer.substring is manipulating the shared flag on the
StringBuffer object incorrectly, PR java/12350.
The following patch fixes the bug and adds a test case. It passes the
libjava/testsuite on i686-pc-linux-gnu.
Thanks Ralph.
I am checking in a slightly modified patch to both libgcj and classpath.
Regards
Bryce.
2003-09-21 Ralph Loader <address@hidden>
PR java/12350:
* java/lang/StringBuffer.java (substring): fix handling of shared flag.
Index: java/lang/StringBuffer.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/StringBuffer.java,v
retrieving revision 1.15
diff -u -r1.15 StringBuffer.java
--- java/lang/StringBuffer.java 24 Mar 2003 00:50:18 -0000 1.15
+++ java/lang/StringBuffer.java 22 Sep 2003 08:10:44 -0000
@@ -564,8 +564,9 @@
throw new StringIndexOutOfBoundsException();
if (len == 0)
return "";
- // Share the char[] unless 3/4 empty.
- shared = (len << 2) >= value.length;
+ // Share unless substring is smaller than 1/4 of the buffer.
+ if ((len << 2) >= value.length)
+ shared = true;
// Package constructor avoids an array copy.
return new String(value, beginIndex, len, shared);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [patch] pr 12350, java.lang.StringBuffer.substring.,
Bryce McKinlay <=