Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions third_party/joni/src/org/joni/ApplyCaseFold.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public void apply(int from, int[]to, int length, Object o) {
Encoding enc = env.enc;
CClassNode cc = arg.cc;
CClassNode ascCc = arg.ascCc;
CClassNode foldCc = arg.foldCc;
BitSet bs = cc.bs;
boolean addFlag;

Expand All @@ -44,13 +45,12 @@ public void apply(int from, int[]to, int length, Object o) {
return;
}

if (ascCc == null) {
if (!isEligible(foldCc, enc, from) || ascCc == null) {
addFlag = false;
} else if (Encoding.isAscii(from) == Encoding.isAscii(to[0])) {
addFlag = true;
} else {
addFlag = ascCc.isCodeInCC(enc, from);
if (ascCc.isNot()) addFlag = !addFlag;
addFlag = isEligible(ascCc, enc, from);
}

if (length == 1) {
Expand Down Expand Up @@ -84,7 +84,8 @@ public void apply(int from, int[]to, int length, Object o) {
} // CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS

} else {
if (cc.isCodeInCC(enc, from) && (!Config.CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS || !cc.isNot())) {
if (addFlag && cc.isCodeInCC(enc, from)
&& (!Config.CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS || !cc.isNot())) {
StringNode node = null;
for (int i=0; i<length; i++) {
if (i == 0) {
Expand All @@ -110,5 +111,11 @@ public void apply(int from, int[]to, int length, Object o) {

}

static boolean isEligible(CClassNode ascCc, Encoding enc, int code) {
if (ascCc == null) return false;
boolean eligible = ascCc.isCodeInCC(enc, code);
return ascCc.isNot() ? !eligible : eligible;
}

static final ApplyCaseFold INSTANCE = new ApplyCaseFold();
}
6 changes: 4 additions & 2 deletions third_party/joni/src/org/joni/ApplyCaseFoldArg.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@

final class ApplyCaseFoldArg {
final ScanEnvironment env;
final CClassNode cc, ascCc;
final CClassNode cc, ascCc, foldCc;
ListNode altRoot;
ListNode tail;

ApplyCaseFoldArg(ScanEnvironment env, CClassNode cc, CClassNode ascCc) {
ApplyCaseFoldArg(ScanEnvironment env, CClassNode cc, CClassNode ascCc,
CClassNode foldCc) {
this.env = env;
this.cc = cc;
this.ascCc = ascCc;
this.foldCc = foldCc;
}
}
Loading