+2004-08-29 Mark Wielaard <mark@klomp.org>
+
+ * java/util/Arrays.java
+ (sort(byte[], int, int)): Check fromIndex < 0.
+ (sort(char[], int, int)): Likewise.
+ (sort(short[], int, int)): Likewise.
+ (sort(int[], int, int)): Likewise.
+ (sort(long[], int, int)): Likewise.
+ (sort(float[], int, int)): Likewise.
+ (sort(double[], int, int)): Likewise.
+ (sort(Object[], int, int, Comparator)): Likewise.
+ (qsort(byte[], int, int)): Honor lower bound from in insertion sort.
+ (qsort(char[], int, int)): Likewise.
+ (qsort(short[], int, int)): Likewise.
+ (qsort(int[], int, int)): Likewise.
+ (qsort(long[], int, int)): Likewise.
+ (qsort(float[], int, int)): Likewise.
+ (qsort(double[], int, int)): Likewise.
+
2004-08-29 Andrew John Hughes <gnu_andrew@member.fsf.org>
* java/util/AbstractCollection.java, java/util/AbstractList.java,
/* Arrays.java -- Utility class with methods to operate on arrays
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
+ Free Software Foundation, Inc.
This file is part of GNU Classpath.
{
if (fromIndex > toIndex)
throw new IllegalArgumentException();
+ if (fromIndex < 0)
+ throw new ArrayIndexOutOfBoundsException();
qsort(a, fromIndex, toIndex - fromIndex);
}
if (count <= 7)
{
for (int i = from + 1; i < from + count; i++)
- for (int j = i; j > 0 && array[j - 1] > array[j]; j--)
+ for (int j = i; j > from && array[j - 1] > array[j]; j--)
swap(j, j - 1, array);
return;
}
{
if (fromIndex > toIndex)
throw new IllegalArgumentException();
+ if (fromIndex < 0)
+ throw new ArrayIndexOutOfBoundsException();
qsort(a, fromIndex, toIndex - fromIndex);
}
if (count <= 7)
{
for (int i = from + 1; i < from + count; i++)
- for (int j = i; j > 0 && array[j - 1] > array[j]; j--)
+ for (int j = i; j > from && array[j - 1] > array[j]; j--)
swap(j, j - 1, array);
return;
}
{
if (fromIndex > toIndex)
throw new IllegalArgumentException();
+ if (fromIndex < 0)
+ throw new ArrayIndexOutOfBoundsException();
qsort(a, fromIndex, toIndex - fromIndex);
}
if (count <= 7)
{
for (int i = from + 1; i < from + count; i++)
- for (int j = i; j > 0 && array[j - 1] > array[j]; j--)
- swap(j, j - 1, array);
+ for (int j = i; j > from && array[j - 1] > array[j]; j--)
+ swap(j, j - 1, array);
return;
}
{
if (fromIndex > toIndex)
throw new IllegalArgumentException();
+ if (fromIndex < 0)
+ throw new ArrayIndexOutOfBoundsException();
qsort(a, fromIndex, toIndex - fromIndex);
}
if (count <= 7)
{
for (int i = from + 1; i < from + count; i++)
- for (int j = i; j > 0 && array[j - 1] > array[j]; j--)
+ for (int j = i; j > from && array[j - 1] > array[j]; j--)
swap(j, j - 1, array);
return;
}
{
if (fromIndex > toIndex)
throw new IllegalArgumentException();
+ if (fromIndex < 0)
+ throw new ArrayIndexOutOfBoundsException();
qsort(a, fromIndex, toIndex - fromIndex);
}
if (count <= 7)
{
for (int i = from + 1; i < from + count; i++)
- for (int j = i; j > 0 && array[j - 1] > array[j]; j--)
+ for (int j = i; j > from && array[j - 1] > array[j]; j--)
swap(j, j - 1, array);
return;
}
{
if (fromIndex > toIndex)
throw new IllegalArgumentException();
+ if (fromIndex < 0)
+ throw new ArrayIndexOutOfBoundsException();
qsort(a, fromIndex, toIndex - fromIndex);
}
{
for (int i = from + 1; i < from + count; i++)
for (int j = i;
- j > 0 && Float.compare(array[j - 1], array[j]) > 0;
+ j > from && Float.compare(array[j - 1], array[j]) > 0;
j--)
{
swap(j, j - 1, array);
{
if (fromIndex > toIndex)
throw new IllegalArgumentException();
+ if (fromIndex < 0)
+ throw new ArrayIndexOutOfBoundsException();
qsort(a, fromIndex, toIndex - fromIndex);
}
{
for (int i = from + 1; i < from + count; i++)
for (int j = i;
- j > 0 && Double.compare(array[j - 1], array[j]) > 0;
+ j > from && Double.compare(array[j - 1], array[j]) > 0;
j--)
{
swap(j, j - 1, array);
if (fromIndex > toIndex)
throw new IllegalArgumentException("fromIndex " + fromIndex
+ " > toIndex " + toIndex);
+ if (fromIndex < 0)
+ throw new ArrayIndexOutOfBoundsException();
// In general, the code attempts to be simple rather than fast, the
// idea being that a good optimising JIT will be able to optimise it