This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: StringBuffer patch


Hi,

On Sun, 2002-12-22 at 22:04, Mark Wielaard wrote:

> 2002-12-21  Mark Wielaard  <mark@klomp.org>
> 
>     * java/lang/StringBuffer.java (getChars): Remove wrong of dstOffset
>     against count.

Now with patch attached.

Sorry,

Mark
Index: java/lang/StringBuffer.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/StringBuffer.java,v
retrieving revision 1.13
diff -u -r1.13 StringBuffer.java
--- java/lang/StringBuffer.java	22 Jan 2002 22:40:16 -0000	1.13
+++ java/lang/StringBuffer.java	22 Dec 2002 20:43:19 -0000
@@ -308,26 +308,27 @@
       }
   }
 
-  /** Get the specified array of characters.
-   *  The characters will be copied into the array you pass in.
-   *  @param srcOffset the index to start copying from in the
-   *         <code>StringBuffer</code>.
-   *  @param srcEnd the number of characters to copy.
-   *  @param dst the array to copy into.
-   *  @param dstOffset the index to start copying into <code>dst</code>.
-   *  @exception NullPointerException if dst is null.
-   *  @exception IndexOutOfBoundsException if any source or target
-   *             indices are out of range.
-   *  @see java.lang.System#arraycopy(java.lang.Object,int,java.lang.Object,int,int)
+  /**
+   * Get the specified array of characters. <code>srcOffset - srcEnd</code>
+   * characters will be copied into the array you pass in.
+   *
+   * @param srcOffset the index to start copying from (inclusive)
+   * @param srcEnd the index to stop copying from (exclusive)
+   * @param dst the array to copy into
+   * @param dstOffset the index to start copying into
+   * @throws NullPointerException if dst is null
+   * @throws IndexOutOfBoundsException if any source or target indices are
+   *         out of range (while unspecified, source problems cause a
+   *         StringIndexOutOfBoundsException, and dest problems cause an
+   *         ArrayIndexOutOfBoundsException)
+   * @see System#arraycopy(Object, int, Object, int, int)
    */
-  public synchronized void getChars (int srcOffset, int srcEnd,
-				     char[] dst, int dstOffset)
+  public synchronized void getChars(int srcOffset, int srcEnd,
+                                    char[] dst, int dstOffset)
   {
-    if (srcOffset < 0 || srcOffset > srcEnd)
-      throw new StringIndexOutOfBoundsException (srcOffset);
     int todo = srcEnd - srcOffset;
-    if (srcEnd > count || dstOffset + todo > count)
-      throw new StringIndexOutOfBoundsException (srcEnd);
+    if (srcOffset < 0 || srcEnd > count || todo < 0)
+      throw new StringIndexOutOfBoundsException();
     System.arraycopy(value, srcOffset, dst, dstOffset, todo);
   }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]