From 2d8cf20d0d5ca6b1fbdefc22229d4b7cf1497ede Mon Sep 17 00:00:00 2001 From: mark Date: Tue, 17 Jan 2006 18:09:40 +0000 Subject: Imported GNU Classpath 0.20 * Makefile.am (AM_CPPFLAGS): Add classpath/include. * java/nio/charset/spi/CharsetProvider.java: New override file. * java/security/Security.java: Likewise. * sources.am: Regenerated. * Makefile.in: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@109831 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/classpath/java/lang/String.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'libjava/classpath/java/lang/String.java') diff --git a/libjava/classpath/java/lang/String.java b/libjava/classpath/java/lang/String.java index 369d8085a02..231afc77b92 100644 --- a/libjava/classpath/java/lang/String.java +++ b/libjava/classpath/java/lang/String.java @@ -273,7 +273,8 @@ public final class String implements Serializable, Comparable, CharSequence throw new StringIndexOutOfBoundsException("offset: " + offset); if (count < 0) throw new StringIndexOutOfBoundsException("count: " + count); - if (offset + count < 0 || offset + count > ascii.length) + // equivalent to: offset + count < 0 || offset + count > ascii.length + if (ascii.length - offset < count) throw new StringIndexOutOfBoundsException("offset + count: " + (offset + count)); value = new char[count]; @@ -338,7 +339,8 @@ public final class String implements Serializable, Comparable, CharSequence throw new StringIndexOutOfBoundsException("offset: " + offset); if (count < 0) throw new StringIndexOutOfBoundsException("count: " + count); - if (offset + count < 0 || offset + count > data.length) + // equivalent to: offset + count < 0 || offset + count > data.length + if (data.length - offset < count) throw new StringIndexOutOfBoundsException("offset + count: " + (offset + count)); try @@ -418,7 +420,8 @@ public final class String implements Serializable, Comparable, CharSequence throw new StringIndexOutOfBoundsException("offset: " + offset); if (count < 0) throw new StringIndexOutOfBoundsException("count: " + count); - if (offset + count < 0 || offset + count > data.length) + // equivalent to: offset + count < 0 || offset + count > data.length + if (data.length - offset < count) throw new StringIndexOutOfBoundsException("offset + count: " + (offset + count)); int o, c; @@ -533,7 +536,8 @@ public final class String implements Serializable, Comparable, CharSequence throw new StringIndexOutOfBoundsException("offset: " + offset); if (count < 0) throw new StringIndexOutOfBoundsException("count: " + count); - if (offset + count < 0 || offset + count > data.length) + // equivalent to: offset + count < 0 || offset + count > data.length + if (data.length - offset < count) throw new StringIndexOutOfBoundsException("offset + count: " + (offset + count)); if (dont_copy) @@ -1761,7 +1765,7 @@ public final class String implements Serializable, Comparable, CharSequence /** * Return the number of code points between two indices in the - * StringBuffer. An unpaired surrogate counts as a + * String. An unpaired surrogate counts as a * code point for this purpose. Characters outside the indicated * range are not examined, even if the range ends in the middle of a * surrogate pair. @@ -1879,6 +1883,8 @@ public final class String implements Serializable, Comparable, CharSequence * described in s. * @param s the CharSequence * @return true iff this String contains s + * + * @since 1.5 */ public boolean contains (CharSequence s) { -- cgit v1.2.3