[jruby-joni] 175/194: enable char class duplication warnings
Hideki Yamane
henrich at moszumanska.debian.org
Thu Feb 1 12:04:38 UTC 2018
This is an automated email from the git hooks/post-receive script.
henrich pushed a commit to branch debian/sid
in repository jruby-joni.
commit 0a0135251c44dbd6dc20317dc1cab91b444273df
Author: Marcin Mielzynski <lopx at gazeta.pl>
Date: Wed Jan 17 19:27:20 2018 +0100
enable char class duplication warnings
---
src/org/joni/ApplyCaseFold.java | 4 ++--
src/org/joni/CodeRangeBuffer.java | 15 +++++++--------
src/org/joni/ast/CClassNode.java | 23 ++++++++++++++++-------
3 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/src/org/joni/ApplyCaseFold.java b/src/org/joni/ApplyCaseFold.java
index c08a1e5..32a1fd1 100644
--- a/src/org/joni/ApplyCaseFold.java
+++ b/src/org/joni/ApplyCaseFold.java
@@ -53,7 +53,7 @@ final class ApplyCaseFold implements ApplyAllCaseFoldFunction {
if ((inCC && !cc.isNot()) || (!inCC && cc.isNot())) {
if (addFlag) {
if (enc.minLength() > 1 || to[0] >= BitSet.SINGLE_BYTE_SIZE) {
- cc.addCodeRange(env, to[0], to[0]);
+ cc.addCodeRange(env, to[0], to[0], false);
} else {
/* /(?i:[^A-C])/.match("a") ==> fail. */
bs.set(to[0]);
@@ -65,7 +65,7 @@ final class ApplyCaseFold implements ApplyAllCaseFoldFunction {
if (addFlag) {
if (enc.minLength() > 1 || to[0] >= BitSet.SINGLE_BYTE_SIZE) {
if (cc.isNot()) cc.clearNotFlag(env);
- cc.addCodeRange(env, to[0], to[0]);
+ cc.addCodeRange(env, to[0], to[0], false);
} else {
if (cc.isNot()) {
bs.clear(to[0]);
diff --git a/src/org/joni/CodeRangeBuffer.java b/src/org/joni/CodeRangeBuffer.java
index 1f87749..9a88aa3 100644
--- a/src/org/joni/CodeRangeBuffer.java
+++ b/src/org/joni/CodeRangeBuffer.java
@@ -19,13 +19,12 @@
*/
package org.joni;
-import org.jcodings.Encoding;
import org.joni.exception.ErrorMessages;
import org.joni.exception.ValueException;
public final class CodeRangeBuffer {
private static final int INIT_MULTI_BYTE_RANGE_SIZE = 5;
- public static final int ALL_MULTI_BYTE_RANGE = 0x7fffffff;
+ public static final int LAST_CODE_POINT = 0x7fffffff;
private int[]p;
private int used;
@@ -121,11 +120,11 @@ public final class CodeRangeBuffer {
}
}
- int high = low;
+ int high = to == LAST_CODE_POINT ? n : low;
bound = n;
while (high < bound) {
int x = (high + bound) >>> 1;
- if (to >= p[x * 2 + 1] - 1) { // to + 1
+ if (to + 1 >= p[x * 2 + 1]) {
high = x + 1;
} else {
bound = x;
@@ -138,7 +137,7 @@ public final class CodeRangeBuffer {
if (incN != 1) {
if (checkDup) {
- // if (from <= p[low * 2 + 2] && (p[low * 2 + 1] <= from || p[low * 2 + 2] <= to)) env.ccDuplicateWarn();
+ if (from <= p[low * 2 + 2] && (p[low * 2 + 1] <= from || p[low * 2 + 2] <= to)) env.ccDuplicateWarn();
}
if (from > p[low * 2 + 1]) from = p[low * 2 + 1];
@@ -187,7 +186,7 @@ public final class CodeRangeBuffer {
// SET_ALL_MULTI_BYTE_RANGE
protected static CodeRangeBuffer setAllMultiByteRange(ScanEnvironment env, CodeRangeBuffer pbuf) {
- return addCodeRangeToBuff(pbuf, env, env.enc.mbcodeStartPosition(), ALL_MULTI_BYTE_RANGE);
+ return addCodeRangeToBuff(pbuf, env, env.enc.mbcodeStartPosition(), LAST_CODE_POINT);
}
// ADD_ALL_MULTI_BYTE_RANGE
@@ -217,11 +216,11 @@ public final class CodeRangeBuffer {
if (pre <= from - 1) {
pbuf = addCodeRangeToBuff(pbuf, env, pre, from - 1);
}
- if (to == ALL_MULTI_BYTE_RANGE) break;
+ if (to == LAST_CODE_POINT) break;
pre = to + 1;
}
- if (to < ALL_MULTI_BYTE_RANGE) pbuf = addCodeRangeToBuff(pbuf, env, to + 1, ALL_MULTI_BYTE_RANGE);
+ if (to < LAST_CODE_POINT) pbuf = addCodeRangeToBuff(pbuf, env, to + 1, LAST_CODE_POINT);
return pbuf;
}
diff --git a/src/org/joni/ast/CClassNode.java b/src/org/joni/ast/CClassNode.java
index 1a2ea51..7061f0a 100644
--- a/src/org/joni/ast/CClassNode.java
+++ b/src/org/joni/ast/CClassNode.java
@@ -74,11 +74,20 @@ public final class CClassNode extends Node {
}
void addCodeRangeToBuf(ScanEnvironment env, int from, int to) {
- mbuf = CodeRangeBuffer.addCodeRangeToBuff(mbuf, env, from, to);
+ addCodeRangeToBuf(env, from, to, true);
}
+ void addCodeRangeToBuf(ScanEnvironment env, int from, int to, boolean checkDup) {
+ mbuf = CodeRangeBuffer.addCodeRangeToBuff(mbuf, env, from, to, checkDup);
+ }
+
+ // add_code_range, be aware of it returning null!
public void addCodeRange(ScanEnvironment env, int from, int to) {
- mbuf = CodeRangeBuffer.addCodeRange(mbuf, env, from, to);
+ addCodeRange(env, from, to, true);
+ }
+
+ public void addCodeRange(ScanEnvironment env, int from, int to, boolean checkDup) {
+ mbuf = CodeRangeBuffer.addCodeRange(mbuf, env, from, to, checkDup);
}
void addAllMultiByteRange(ScanEnvironment env) {
@@ -296,7 +305,7 @@ public final class CClassNode extends Node {
CClassNode ccWork = new CClassNode();
ccWork.addCTypeByRange(ctype, not, env, sbOut.value, ranges);
if (not) {
- ccWork.addCodeRangeToBuf(env, 0x80, CodeRangeBuffer.ALL_MULTI_BYTE_RANGE); // add_code_range_to_buf0
+ ccWork.addCodeRangeToBuf(env, 0x80, CodeRangeBuffer.LAST_CODE_POINT, false);
} else {
CClassNode ccAscii = new CClassNode();
if (enc.minLength() > 1) {
@@ -405,7 +414,7 @@ public final class CClassNode extends Node {
if (ascCC != null) ascCC.bs.set(arg.from);
} else if (arg.type == CCVALTYPE.CODE_POINT) {
addCodeRange(env, arg.from, arg.from);
- if (ascCC != null) ascCC.addCodeRange(env, arg.from, arg.from); // add_code_range0
+ if (ascCC != null) ascCC.addCodeRange(env, arg.from, arg.from, false);
}
}
arg.state = CCSTATE.VALUE;
@@ -420,7 +429,7 @@ public final class CClassNode extends Node {
if (ascCc != null) ascCc.bs.set(arg.from);
} else if (arg.type == CCVALTYPE.CODE_POINT) {
addCodeRange(env, arg.from, arg.from);
- if (ascCc != null) ascCc.addCodeRange(env, arg.from, arg.from); // add_code_range0
+ if (ascCc != null) ascCc.addCodeRange(env, arg.from, arg.from, false);
}
break;
@@ -442,7 +451,7 @@ public final class CClassNode extends Node {
if (ascCc != null) ascCc.bs.setRange(arg.from, arg.to);
} else {
addCodeRange(env, arg.from, arg.to);
- if (ascCc != null) ascCc.addCodeRange(env, arg.from, arg.to); // add_code_range0
+ if (ascCc != null) ascCc.addCodeRange(env, arg.from, arg.to, false);
}
} else {
if (arg.from > arg.to) {
@@ -458,7 +467,7 @@ public final class CClassNode extends Node {
addCodeRange(env, arg.from, arg.to);
if (ascCc != null) {
ascCc.bs.setRange(arg.from, arg.to < 0xff ? arg.to : 0xff);
- ascCc.addCodeRange(env, arg.from, arg.to); // add_code_range0
+ ascCc.addCodeRange(env, arg.from, arg.to, false);
}
}
// ccs_range_end:
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jruby-joni.git
More information about the pkg-java-commits
mailing list