I am checking this in.

ChangeLog
2006-01-31  Ito Kazumitsu  <[EMAIL PROTECTED]>

        Fixes bug #22873
        * gnu/regexp/REMatch(toString(int)): Throw IndexOutOfBoundsException
        for an invalid index and return null for a skipped group.
Index: classpath/gnu/regexp/REMatch.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/regexp/REMatch.java,v
retrieving revision 1.4
diff -u -r1.4 REMatch.java
--- classpath/gnu/regexp/REMatch.java   30 Jan 2006 12:35:54 -0000      1.4
+++ classpath/gnu/regexp/REMatch.java   31 Jan 2006 14:43:41 -0000
@@ -179,7 +179,9 @@
      * @param sub Index of the subexpression.
      */
     public String toString(int sub) {
-       if ((sub >= start.length) || (start[sub] == -1)) return "";
+       if ((sub >= start.length) || sub < 0)
+           throw new IndexOutOfBoundsException("No group " + sub);
+       if (start[sub] == -1) return null;
        return (matchedText.substring(start[sub],end[sub]));
     }
     

Reply via email to