added startway check
This commit is contained in:
parent
6b4d989868
commit
d2d639666e
8 changed files with 64 additions and 5 deletions
|
|
@ -80,6 +80,8 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
|||
|
||||
private BExpressionContext foreignContext;
|
||||
|
||||
public int[] noStartWays = new int[0];
|
||||
|
||||
protected void setInverseVars() {
|
||||
currentVarOffset = nBuildInVars;
|
||||
}
|
||||
|
|
@ -187,7 +189,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
|||
/**
|
||||
* decode a byte-array into a lookup data array
|
||||
*/
|
||||
private void decode(int[] ld, boolean inverseDirection, byte[] ab) {
|
||||
public void decode(int[] ld, boolean inverseDirection, byte[] ab) {
|
||||
BitCoderContext ctx = ctxDecode;
|
||||
ctx.reset(ab);
|
||||
|
||||
|
|
@ -954,6 +956,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
|||
|
||||
private String _parseToken() throws Exception {
|
||||
StringBuilder sb = new StringBuilder(32);
|
||||
StringBuilder sbcom = new StringBuilder(32);
|
||||
boolean inComment = false;
|
||||
for (; ; ) {
|
||||
int ic = _readerDone ? -1 : _br.read();
|
||||
|
|
@ -966,7 +969,33 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
|||
if (c == '\n') linenr++;
|
||||
|
||||
if (inComment) {
|
||||
sbcom.append(c);
|
||||
if (c == '\r' || c == '\n') inComment = false;
|
||||
if (!inComment) {
|
||||
Integer num = variableNumbers.get("check_start_way");
|
||||
if (num != null && noStartWays.length == 0 && sbcom.toString().contains("noStartWay")) {
|
||||
String var = sbcom.toString().trim();
|
||||
String[] savar = var.split("\\|");
|
||||
if (savar.length == 4) {
|
||||
var = savar[3].substring(savar[3].indexOf("=")+1).trim();
|
||||
String[] sa = var.split(";");
|
||||
for (String s: sa) {
|
||||
String[] sa2 = s.split(",");
|
||||
String name = sa2[0];
|
||||
String value = sa2[1];
|
||||
int nidx = getLookupNameIdx(name);
|
||||
if (nidx == -1) break;
|
||||
int vidx = getLookupValueIdx(nidx, value);
|
||||
int[] tmp = new int[noStartWays.length + 2];
|
||||
if (noStartWays.length > 0) System.arraycopy(noStartWays, 0, tmp, 0, noStartWays.length);
|
||||
noStartWays = tmp;
|
||||
noStartWays[noStartWays.length-2] = nidx;
|
||||
noStartWays[noStartWays.length-1] = vidx;
|
||||
}
|
||||
}
|
||||
}
|
||||
sbcom.setLength(0);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (Character.isWhitespace(c)) {
|
||||
|
|
@ -983,4 +1012,21 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
|||
return value;
|
||||
}
|
||||
|
||||
int[] ld2 = new int[512];
|
||||
public boolean checkStartWay(byte[] ab) {
|
||||
if (ab == null) return true;
|
||||
Arrays.fill(ld2, 0);
|
||||
decode(ld2, false, ab);
|
||||
for (int i = 0; i < noStartWays.length; i += 2) {
|
||||
int key = noStartWays[i];
|
||||
int value = noStartWays[i+1];
|
||||
if (ld2[key] == value) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void freeNoWays() {
|
||||
noStartWays = new int[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,4 +129,6 @@ public final class BExpressionContextWay extends BExpressionContext implements T
|
|||
public void setDecodeForbidden(boolean decodeForbidden) {
|
||||
this.decodeForbidden = decodeForbidden;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue