Skip to content

Commit 4d088b6

Browse files
committedDec 19, 2017
refactor flags
1 parent e62366c commit 4d088b6

File tree

7 files changed

+16
-15
lines changed

7 files changed

+16
-15
lines changed
 

‎src/org/jcodings/Config.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020
package org.jcodings;
2121

2222
public interface Config {
23-
final int ENC_CASE_FOLD_TURKISH_AZERI = (1<<20);
24-
final int INTERNAL_ENC_CASE_FOLD_MULTI_CHAR = (1<<30);
25-
final int ENC_CASE_FOLD_MIN = INTERNAL_ENC_CASE_FOLD_MULTI_CHAR;
26-
final int ENC_CASE_FOLD_DEFAULT = ENC_CASE_FOLD_MIN;
27-
2823
/* work size */
2924
final int ENC_CODE_TO_MBC_MAXLEN = 7;
3025
final int ENC_MBC_CASE_FOLD_MAXLEN = 18;
@@ -38,6 +33,9 @@ public interface Config {
3833

3934
final boolean USE_UNICODE_PROPERTIES = true;
4035

36+
final int CodePointMaskWidth = 3;
37+
final int CodePointMask = (1 << CodePointMaskWidth) - 1;
38+
4139
final int CASE_UPCASE = (1<<13); /* has/needs uppercase mapping */
4240
final int CASE_DOWNCASE = (1<<14); /* has/needs lowercase mapping */
4341
final int CASE_TITLECASE = (1<<15); /* has/needs (special) titlecase mapping */
@@ -53,5 +51,8 @@ public interface Config {
5351
final int CASE_ASCII_ONLY = (1<<22); /* only modify ASCII range */
5452
final int CASE_IS_TITLECASE = (1<<23); /* character itself is already titlecase */
5553

56-
final int INTERNAL_CASE_FOLD_MULTI_CHAR = (1<<30); /* better not change original value! */
54+
final int INTERNAL_ENC_CASE_FOLD_MULTI_CHAR = (1<<30); /* better not change original value! */
55+
final int ENC_CASE_FOLD_MIN = INTERNAL_ENC_CASE_FOLD_MULTI_CHAR;
56+
final int ENC_CASE_FOLD_DEFAULT = ENC_CASE_FOLD_MIN;
57+
5758
}

‎src/org/jcodings/specific/BaseUTF8Encoding.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public int mbcCaseFold(int flag, byte[]bytes, IntHolder pp, int end, byte[]fold)
164164
if (isMbcAscii(bytes[p])) {
165165

166166
if (Config.USE_UNICODE_CASE_FOLD_TURKISH_AZERI) {
167-
if ((flag & Config.ENC_CASE_FOLD_TURKISH_AZERI) != 0) {
167+
if ((flag & Config.CASE_FOLD_TURKISH_AZERI) != 0) {
168168
if (bytes[p] == (byte)0x49) {
169169
fold[foldP++] = (byte)0xc4l;
170170
fold[foldP] = (byte)0xb1;

‎src/org/jcodings/specific/UTF16BEEncoding.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public int mbcCaseFold(int flag, byte[]bytes, IntHolder pp, int end, byte[]fold)
106106
p++;
107107

108108
if (Config.USE_UNICODE_CASE_FOLD_TURKISH_AZERI) {
109-
if ((flag & Config.ENC_CASE_FOLD_TURKISH_AZERI) != 0) {
109+
if ((flag & Config.CASE_FOLD_TURKISH_AZERI) != 0) {
110110
if (bytes[p] == (byte)0x49) {
111111
fold[foldP++] = (byte)0x01;
112112
fold[foldP] = (byte)0x31;

‎src/org/jcodings/specific/UTF16LEEncoding.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public int mbcCaseFold(int flag, byte[]bytes, IntHolder pp, int end, byte[]fold)
110110
if (isAscii(bytes[p] & 0xff) && bytes[p + 1] == 0) {
111111

112112
if (Config.USE_UNICODE_CASE_FOLD_TURKISH_AZERI) {
113-
if ((flag & Config.ENC_CASE_FOLD_TURKISH_AZERI) != 0) {
113+
if ((flag & Config.CASE_FOLD_TURKISH_AZERI) != 0) {
114114
if (bytes[p] == (byte)0x49) {
115115
fold[foldP++] = (byte)0x01;
116116
fold[foldP] = (byte)0x31;

‎src/org/jcodings/specific/UTF32BEEncoding.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public int mbcCaseFold(int flag, byte[]bytes, IntHolder pp, int end, byte[]fold)
7171
fold[foldP++] = 0;
7272

7373
if (Config.USE_UNICODE_CASE_FOLD_TURKISH_AZERI) {
74-
if ((flag & Config.ENC_CASE_FOLD_TURKISH_AZERI) != 0) {
74+
if ((flag & Config.CASE_FOLD_TURKISH_AZERI) != 0) {
7575
if (bytes[p + 3] == (byte)0x49) {
7676
fold[foldP++] = (byte)0x01;
7777
fold[foldP] = (byte)0x31;

‎src/org/jcodings/specific/UTF32LEEncoding.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public int mbcCaseFold(int flag, byte[]bytes, IntHolder pp, int end, byte[]fold)
6868
int foldP = 0;
6969
if (isAscii(bytes[p] & 0xff) && bytes[p + 1] == 0 && bytes[p + 2] == 0 && bytes[p + 3] == 0) {
7070

71-
if (Config.USE_UNICODE_CASE_FOLD_TURKISH_AZERI && (flag & Config.ENC_CASE_FOLD_TURKISH_AZERI) != 0) {
71+
if (Config.USE_UNICODE_CASE_FOLD_TURKISH_AZERI && (flag & Config.CASE_FOLD_TURKISH_AZERI) != 0) {
7272
if (bytes[p] == (byte)0x49) {
7373
fold[foldP++] = (byte)0x31;
7474
fold[foldP] = (byte)0x01;

‎src/org/jcodings/unicode/UnicodeEncoding.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public int mbcCaseFold(int flag, byte[]bytes, IntHolder pp, int end, byte[]fold)
112112
pp.value += len;
113113

114114
if (Config.USE_UNICODE_CASE_FOLD_TURKISH_AZERI) {
115-
if ((flag & Config.ENC_CASE_FOLD_TURKISH_AZERI) != 0) {
115+
if ((flag & Config.CASE_FOLD_TURKISH_AZERI) != 0) {
116116
if (code == 0x0049) {
117117
return codeToMbc(0x0131, fold, foldP);
118118
} else if (code == 0x0130) {
@@ -170,7 +170,7 @@ public void applyAllCaseFold(int flag, ApplyAllCaseFoldFunction fun, Object arg)
170170
}
171171
}
172172

173-
if (Config.USE_UNICODE_CASE_FOLD_TURKISH_AZERI && (flag & Config.ENC_CASE_FOLD_TURKISH_AZERI) != 0) {
173+
if (Config.USE_UNICODE_CASE_FOLD_TURKISH_AZERI && (flag & Config.CASE_FOLD_TURKISH_AZERI) != 0) {
174174
code[0] = 0x0131;
175175
fun.apply(0x0049, code, 1, arg);
176176
code[0] = 0x0049;
@@ -217,7 +217,7 @@ public void applyAllCaseFold(int flag, ApplyAllCaseFoldFunction fun, Object arg)
217217
}
218218
}
219219

220-
if (!Config.USE_UNICODE_CASE_FOLD_TURKISH_AZERI || (flag & Config.ENC_CASE_FOLD_TURKISH_AZERI) == 0) {
220+
if (!Config.USE_UNICODE_CASE_FOLD_TURKISH_AZERI || (flag & Config.CASE_FOLD_TURKISH_AZERI) == 0) {
221221
for (int i=0; i<CaseFold12.CaseUnfold_12_Locale.length; i+=2) {
222222
int[]from = CaseFold12.CaseUnfold_12_Locale[i];
223223
int[]to = CaseFold12.CaseUnfold_12_Locale[i + 1];
@@ -258,7 +258,7 @@ public void applyAllCaseFold(int flag, ApplyAllCaseFoldFunction fun, Object arg)
258258
int len = length(bytes, p, end);
259259

260260
if (Config.USE_UNICODE_CASE_FOLD_TURKISH_AZERI) {
261-
if ((flag & Config.ENC_CASE_FOLD_TURKISH_AZERI) != 0) {
261+
if ((flag & Config.CASE_FOLD_TURKISH_AZERI) != 0) {
262262
if (code == 0x0049) {
263263
return new CaseFoldCodeItem[]{new CaseFoldCodeItem(len, 1, new int[]{0x0131})};
264264
} else if(code == 0x0130) {

0 commit comments

Comments
 (0)
Please sign in to comment.