Commit de2baf30 by Mark Wielaard Committed by Mark Wielaard

StringBuffer.java (getChars): Remove wrong dstOffset check against count.

        * java/lang/StringBuffer.java (getChars): Remove wrong dstOffset check
        against count.

From-SVN: r60616
parent 70e12fb9
2002-12-30 Mark Wielaard <mark@klomp.org>
* java/lang/StringBuffer.java (getChars): Remove wrong dstOffset check
against count.
2002-12-27 Mark Mitchell <mark@codesourcery.com> 2002-12-27 Mark Mitchell <mark@codesourcery.com>
* boehm.cc: Remove stray semicolon. * boehm.cc: Remove stray semicolon.
......
...@@ -308,26 +308,27 @@ public final class StringBuffer implements Serializable, CharSequence ...@@ -308,26 +308,27 @@ public final class StringBuffer implements Serializable, CharSequence
} }
} }
/** Get the specified array of characters. /**
* The characters will be copied into the array you pass in. * Get the specified array of characters. <code>srcOffset - srcEnd</code>
* @param srcOffset the index to start copying from in the * characters will be copied into the array you pass in.
* <code>StringBuffer</code>. *
* @param srcEnd the number of characters to copy. * @param srcOffset the index to start copying from (inclusive)
* @param dst the array to copy into. * @param srcEnd the index to stop copying from (exclusive)
* @param dstOffset the index to start copying into <code>dst</code>. * @param dst the array to copy into
* @exception NullPointerException if dst is null. * @param dstOffset the index to start copying into
* @exception IndexOutOfBoundsException if any source or target * @throws NullPointerException if dst is null
* indices are out of range. * @throws IndexOutOfBoundsException if any source or target indices are
* @see java.lang.System#arraycopy(java.lang.Object,int,java.lang.Object,int,int) * out of range (while unspecified, source problems cause a
*/ * StringIndexOutOfBoundsException, and dest problems cause an
public synchronized void getChars (int srcOffset, int srcEnd, * ArrayIndexOutOfBoundsException)
char[] dst, int dstOffset) * @see System#arraycopy(Object, int, Object, int, int)
{ */
if (srcOffset < 0 || srcOffset > srcEnd) public synchronized void getChars(int srcOffset, int srcEnd,
throw new StringIndexOutOfBoundsException (srcOffset); char[] dst, int dstOffset)
{
int todo = srcEnd - srcOffset; int todo = srcEnd - srcOffset;
if (srcEnd > count || dstOffset + todo > count) if (srcOffset < 0 || srcEnd > count || todo < 0)
throw new StringIndexOutOfBoundsException (srcEnd); throw new StringIndexOutOfBoundsException();
System.arraycopy(value, srcOffset, dst, dstOffset, todo); System.arraycopy(value, srcOffset, dst, dstOffset, todo);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment