Merge
authorlana
Tue, 25 Mar 2014 14:51:51 -0700
changeset 23776 e517d680b5cf
parent 23403 85dbdc227c5e (current diff)
parent 23775 da8965562cd2 (diff)
child 23777 ce87cedb71cf
Merge
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/RangeToken.java	Wed Jul 05 19:34:04 2017 +0200
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/RangeToken.java	Tue Mar 25 14:51:51 2014 -0700
@@ -3,11 +3,12 @@
  * DO NOT REMOVE OR ALTER!
  */
 /*
- * Copyright 1999-2002,2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
@@ -351,7 +352,7 @@
                                                 // src2:      o----o
                                                 // src2:          o----o
                                                 // src2:  o------------o
-                if (src2begin <= src2begin && src1end <= src2end) {
+                if (src2begin <= src1begin && src1end <= src2end) {
                                                 // src1:    o--------o
                                                 // src2:  o------------o
                                                 // res:     o--------o
@@ -384,6 +385,7 @@
                     result[wp++] = src2begin;
                     result[wp++] = src2end;
                     this.ranges[src1] = src2end+1;
+                    src2 += 2;
                 }
             } else if (src2end < src1begin) {
                                                 // Not overlapped
@@ -399,10 +401,6 @@
                                            +"]");
             }
         }
-        while (src1 < this.ranges.length) {
-            result[wp++] = this.ranges[src1++];
-            result[wp++] = this.ranges[src1++];
-        }
         this.ranges = new int[wp];
         System.arraycopy(result, 0, this.ranges, 0, wp);
                                                 // this.ranges is sorted and compacted.
@@ -464,8 +462,8 @@
                 if (ch > 0xffff)
                     lowers.addRange(ch, ch);
                 else {
-                    char uch = Character.toUpperCase((char)ch);
-                    lowers.addRange(uch, uch);
+                    char lch = Character.toLowerCase((char)ch);
+                    lowers.addRange(lch, lch);
                 }
             }
         }
@@ -479,8 +477,10 @@
 
     void dumpRanges() {
         System.err.print("RANGE: ");
-        if (this.ranges == null)
+        if (this.ranges == null) {
             System.err.println(" NULL");
+            return;
+        }
         for (int i = 0;  i < this.ranges.length;  i += 2) {
             System.err.print("["+this.ranges[i]+","+this.ranges[i+1]+"] ");
         }
@@ -552,10 +552,10 @@
             else if (this == Token.token_spaces)
                 ret = "\\s";
             else {
-                StringBuffer sb = new StringBuffer();
-                sb.append("[");
+                StringBuilder sb = new StringBuilder();
+                sb.append('[');
                 for (int i = 0;  i < this.ranges.length;  i += 2) {
-                    if ((options & RegularExpression.SPECIAL_COMMA) != 0 && i > 0)  sb.append(",");
+                    if ((options & RegularExpression.SPECIAL_COMMA) != 0 && i > 0)  sb.append(',');
                     if (this.ranges[i] == this.ranges[i+1]) {
                         sb.append(escapeCharInCharClass(this.ranges[i]));
                     } else {
@@ -564,7 +564,7 @@
                         sb.append(escapeCharInCharClass(this.ranges[i+1]));
                     }
                 }
-                sb.append("]");
+                sb.append(']');
                 ret = sb.toString();
             }
         } else {
@@ -578,7 +578,7 @@
                 StringBuffer sb = new StringBuffer();
                 sb.append("[^");
                 for (int i = 0;  i < this.ranges.length;  i += 2) {
-                    if ((options & RegularExpression.SPECIAL_COMMA) != 0 && i > 0)  sb.append(",");
+                    if ((options & RegularExpression.SPECIAL_COMMA) != 0 && i > 0)  sb.append(',');
                     if (this.ranges[i] == this.ranges[i+1]) {
                         sb.append(escapeCharInCharClass(this.ranges[i]));
                     } else {
@@ -587,7 +587,7 @@
                         sb.append(escapeCharInCharClass(this.ranges[i+1]));
                     }
                 }
-                sb.append("]");
+                sb.append(']');
                 ret = sb.toString();
             }
         }