--- /home/cpdev/src/classpath/gnu/regexp/RETokenOneOf.java	2006-01-23 17:32:53.000000000 +0000
+++ gnu/regexp/RETokenOneOf.java	2005-09-14 21:51:27.000000000 +0000
@@ -71,62 +71,52 @@
   }
 
     boolean match(CharIndexed input, REMatch mymatch) {
-      return negative ? matchN(input, mymatch) : matchP(input, mymatch);
-    }
-
-    private boolean matchN(CharIndexed input, REMatch mymatch) {
-    if (input.charAt(mymatch.index) == CharIndexed.OUT_OF_BOUNDS) 
+    if (negative && (input.charAt(mymatch.index) == CharIndexed.OUT_OF_BOUNDS)) 
       return false;
 
     REMatch newMatch = null;
     REMatch last = null;
     REToken tk;
+    boolean isMatch;
     for (int i=0; i < options.size(); i++) {
 	tk = (REToken) options.elementAt(i);
 	REMatch tryMatch = (REMatch) mymatch.clone();
 	if (tk.match(input, tryMatch)) { // match was successful
-	    return false;
-	} // is a match
-    } // try next option
-
-    ++mymatch.index;
-    return next(input, mymatch);
-  }
+	    if (negative) return false;
 
-    private boolean matchP(CharIndexed input, REMatch mymatch) {
-    REMatch newMatch = null;
-    REMatch last = null;
-    REToken tk;
-    for (int i=0; i < options.size(); i++) {
-	// In ordaer that the backtracking can work,
-	// each option must be chained to the next token.
-	// But the chain method has some side effect, so
-	// we use clones.
-	tk = (REToken)((REToken) options.elementAt(i)).clone();
-	tk.chain(this.next);
-	tk.setUncle(this.uncle);
-	tk.subIndex = this.subIndex;
-	REMatch tryMatch = (REMatch) mymatch.clone();
-	if (tk.match(input, tryMatch)) { // match was successful
-	    if (last == null) {
-		newMatch = tryMatch;
-		last = tryMatch;
-	    } else {
-		last.next = tryMatch;
-		last = tryMatch;
-	    }
+	    if (next(input, tryMatch)) {
+		// Add tryMatch to list of possibilities.
+		if (last == null) {
+		    newMatch = tryMatch;
+		    last = tryMatch;
+		} else {
+		    last.next = tryMatch;
+		    last = tryMatch;
+		}
+	    } // next succeeds
 	} // is a match
     } // try next option
 
     if (newMatch != null) {
-	// set contents of mymatch equal to newMatch
+	if (negative) {
+	    return false;
+	} else {
+	    // set contents of mymatch equal to newMatch
 
-	// try each one that matched
-	mymatch.assignFrom(newMatch);
-	return true;
+	    // try each one that matched
+	    mymatch.assignFrom(newMatch);
+	    return true;
+	}
     } else {
-	return false;
+	if (negative) {
+	    ++mymatch.index;
+	    return next(input, mymatch);
+	} else {
+	    return false;
+	}
     }
+
+    // index+1 works for [^abc] lists, not for generic lookahead (--> index)
   }
 
   void dump(StringBuffer os) {
