Skip to content

Commit

Permalink
sync up with onigmo 288d4ba731911a410ba73935aef88f550fafd9f0
Browse files Browse the repository at this point in the history
  • Loading branch information
lopex committed Dec 13, 2015
1 parent 9f945d8 commit eda1681
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/org/joni/Analyser.java
Expand Up @@ -1489,6 +1489,13 @@ private Node expandCaseFoldMakeRemString(byte[]bytes, int p, int end) {
return node;
}

private boolean isCaseFoldVariableLength(int itemNum, CaseFoldCodeItem[] items, int slen) {
for(int i = 0; i < itemNum; i++) {
if (items[i].byteLen != slen || items[i].codeLen != 1) return true;
}
return false;
}

private boolean expandCaseFoldStringAlt(int itemNum, CaseFoldCodeItem[]items,
byte[]bytes, int p, int slen, int end, ObjPtr<Node> node) {
boolean varlen = false;
Expand Down Expand Up @@ -1562,7 +1569,7 @@ private Node expandCaseFoldString(Node node) {
CaseFoldCodeItem[]items = enc.caseFoldCodesByString(regex.caseFoldFlag, bytes, p, end);
int len = enc.length(bytes, p, end);

if (items.length == 0) {
if (items.length == 0 || !isCaseFoldVariableLength(items.length, items, len)) {
if (stringNode == null) {
if (root == null && prevNode.p != null) {
topRoot = root = ConsAltNode.listAdd(null, prevNode.p);
Expand All @@ -1578,6 +1585,10 @@ private Node expandCaseFoldString(Node node) {
} else {
altNum *= (items.length + 1);
if (altNum > THRESHOLD_CASE_FOLD_ALT_FOR_EXPANSION) break;
if (stringNode != null) {
updateStringNodeCaseFold(stringNode);
stringNode.setAmbig();
}

if (root == null && prevNode.p != null) {
topRoot = root = ConsAltNode.listAdd(null, prevNode.p);
Expand All @@ -1599,6 +1610,11 @@ private Node expandCaseFoldString(Node node) {
p += len;
}

if (stringNode != null) {
updateStringNodeCaseFold(stringNode);
stringNode.setAmbig();
}

if (p < end) {
Node srem = expandCaseFoldMakeRemString(bytes, p, end);

Expand Down

0 comments on commit eda1681

Please sign in to comment.