src/share/classes/java/util/regex/Pattern.java

Print this page

        

@@ -2495,33 +2495,27 @@
                 case ']':
                     firstInClass = false;
                     if (prev != null) {
                         if (consume)
                             next();
+                       if (include)
                         return prev;
+                       else
+                           return prev.complement();
                     }
                     break;
                 default:
                     firstInClass = false;
                     break;
             }
             node = range(bits);
-            if (include) {
                 if (prev == null) {
                     prev = node;
                 } else {
                     if (prev != node)
                         prev = union(prev, node);
                 }
-            } else {
-                if (prev == null) {
-                    prev = node.complement();
-                } else {
-                    if (prev != node)
-                        prev = setDifference(prev, node);
-                }
-            }
             ch = peek();
         }
     }
 
     private CharProperty bitsOrSingle(BitClass bits, int ch) {

@@ -5160,20 +5154,10 @@
                 boolean isSatisfiedBy(int ch) {
                     return lhs.isSatisfiedBy(ch) && rhs.isSatisfiedBy(ch);}};
     }
 
     /**
-     * Returns the set difference of two CharProperty nodes.
-     */
-    private static CharProperty setDifference(final CharProperty lhs,
-                                              final CharProperty rhs) {
-        return new CharProperty() {
-                boolean isSatisfiedBy(int ch) {
-                    return ! rhs.isSatisfiedBy(ch) && lhs.isSatisfiedBy(ch);}};
-    }
-
-    /**
      * Handles word boundaries. Includes a field to allow this one class to
      * deal with the different types of word boundaries we can match. The word
      * characters include underscores, letters, and digits. Non spacing marks
      * can are also part of a word if they have a base character, otherwise
      * they are ignored for purposes of finding word boundaries.