src/jdk/nashorn/internal/runtime/regexp/joni/Regex.java

changeset 1082
e1e27c4262be
parent 962
ac62e33a99b0
child 1205
4112748288bb
     1.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Regex.java	Mon Nov 03 07:29:46 2014 +0100
     1.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Regex.java	Mon Nov 03 11:47:41 2014 +0100
     1.3 @@ -24,6 +24,7 @@
     1.4  import jdk.nashorn.internal.runtime.regexp.joni.exception.ErrorMessages;
     1.5  import jdk.nashorn.internal.runtime.regexp.joni.exception.ValueException;
     1.6  
     1.7 +@SuppressWarnings("javadoc")
     1.8  public final class Regex implements RegexState {
     1.9  
    1.10      int[] code;             /* compiled pattern */
    1.11 @@ -107,7 +108,8 @@
    1.12      }
    1.13  
    1.14      // onig_alloc_init
    1.15 -    public Regex(final char[] chars, final int p, final int end, int option, final int caseFoldFlag, final Syntax syntax, final WarnCallback warnings) {
    1.16 +    public Regex(final char[] chars, final int p, final int end, final int optionp, final int caseFoldFlag, final Syntax syntax, final WarnCallback warnings) {
    1.17 +        int option = optionp;
    1.18  
    1.19          if ((option & (Option.DONT_CAPTURE_GROUP | Option.CAPTURE_GROUP)) ==
    1.20              (Option.DONT_CAPTURE_GROUP | Option.CAPTURE_GROUP)) {
    1.21 @@ -169,19 +171,33 @@
    1.22  
    1.23          if (len < Config.CHAR_TABLE_SIZE) {
    1.24              // map/skip
    1.25 -            if (map == null) map = new byte[Config.CHAR_TABLE_SIZE];
    1.26 +            if (map == null) {
    1.27 +                map = new byte[Config.CHAR_TABLE_SIZE];
    1.28 +            }
    1.29  
    1.30 -            for (int i=0; i<Config.CHAR_TABLE_SIZE; i++) map[i] = (byte)len;
    1.31 -            for (int i=0; i<len-1; i++) map[chars[p + i] & 0xff] = (byte)(len - 1 -i); // oxff ??
    1.32 +            for (int i=0; i<Config.CHAR_TABLE_SIZE; i++) {
    1.33 +                map[i] = (byte)len;
    1.34 +            }
    1.35 +            for (int i=0; i<len-1; i++)
    1.36 +             {
    1.37 +                map[chars[p + i] & 0xff] = (byte)(len - 1 -i); // oxff ??
    1.38 +            }
    1.39          } else {
    1.40 -            if (intMap == null) intMap = new int[Config.CHAR_TABLE_SIZE];
    1.41 +            if (intMap == null) {
    1.42 +                intMap = new int[Config.CHAR_TABLE_SIZE];
    1.43 +            }
    1.44  
    1.45 -            for (int i=0; i<len-1; i++) intMap[chars[p + i] & 0xff] = len - 1 - i; // oxff ??
    1.46 +            for (int i=0; i<len-1; i++)
    1.47 +             {
    1.48 +                intMap[chars[p + i] & 0xff] = len - 1 - i; // oxff ??
    1.49 +            }
    1.50          }
    1.51      }
    1.52  
    1.53      void setExactInfo(final OptExactInfo e) {
    1.54 -        if (e.length == 0) return;
    1.55 +        if (e.length == 0) {
    1.56 +            return;
    1.57 +        }
    1.58  
    1.59          // shall we copy that ?
    1.60          exact = e.chars;
    1.61 @@ -257,7 +273,11 @@
    1.62              s.append("exact: [").append(exact, exactP, exactEnd - exactP).append("]: length: ").append(exactEnd - exactP).append("\n");
    1.63          } else if (searchAlgorithm == SearchAlgorithm.MAP) {
    1.64              int n=0;
    1.65 -            for (int i=0; i<Config.CHAR_TABLE_SIZE; i++) if (map[i] != 0) n++;
    1.66 +            for (int i=0; i<Config.CHAR_TABLE_SIZE; i++) {
    1.67 +                if (map[i] != 0) {
    1.68 +                    n++;
    1.69 +                }
    1.70 +            }
    1.71  
    1.72              s.append("map: n = ").append(n).append("\n");
    1.73              if (n > 0) {

mercurial