Skip to content

Commit ce2ff44

Browse files
committed
allkeys.txt ignorables are not variable
1 parent 9a88f80 commit ce2ff44

File tree

2 files changed

+10
-22
lines changed

2 files changed

+10
-22
lines changed

unicodetools/src/main/java/org/unicode/text/UCA/UCA.java

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -809,26 +809,21 @@ public static String toString(String sortKey, int level) {
809809
return result.toString();
810810
}
811811

812-
static final int variableBottom = UCA.getPrimary(CE_FFFE) + 1;
813-
814-
/*
815-
* Produces a human-readable string for a sort key.
816-
* removed after unicodetools svn r641
812+
/**
813+
* Start of variable primaries. Primary weight one higher than that for the special U+FFFE.
814+
* https://www.unicode.org/reports/tr35/tr35-collation.html#tailored_noncharacter_weights
817815
*/
818-
// static public String toStringUCA(String sortKey, String original, int variableTop,
819-
// StringBuilder extraComment)
816+
private static final int variableBottom = UCA.getPrimary(CE_FFFE) + 1;
820817

821-
public static boolean isVariablePrimary(
822-
char primary, int variableTop, boolean lastWasVariable) {
823-
return primary == 0 ? lastWasVariable : primary <= variableTop && variableBottom <= primary;
818+
private boolean isVariablePrimary(char primary) {
819+
return variableBottom <= primary && primary <= ucaData.variableHigh;
824820
}
825821

826-
public static String toStringUCA(CEList ceList, int variableTop, StringBuilder extraComment) {
822+
public String toStringUCA(CEList ceList, StringBuilder extraComment) {
827823
if (ceList == null || ceList.isEmpty()) {
828824
return "[.0000.0000.0000]";
829825
}
830826
extraComment.setLength(0);
831-
boolean lastWasVariable = false;
832827
final StringBuffer result = new StringBuffer();
833828

834829
for (int i = 0; i < ceList.length(); ++i) {
@@ -837,12 +832,8 @@ public static String toStringUCA(CEList ceList, int variableTop, StringBuilder e
837832
final char s = UCA.getSecondary(ce);
838833
final char t = UCA.getTertiary(ce);
839834

840-
final boolean isVariable = isVariablePrimary(p, variableTop, lastWasVariable);
841-
842-
lastWasVariable = isVariable;
843-
844835
result.append("[")
845-
.append(isVariable ? "*" : ".")
836+
.append(isVariablePrimary(p) ? "*" : ".")
846837
.append(Utility.hex(p))
847838
.append(".")
848839
.append(Utility.hex(s))
@@ -904,7 +895,7 @@ public static boolean isImplicitLeadCE(int ce) {
904895
* from the UCA data, they are narrowed in. The first three values are used in building; the
905896
* last two in testing.
906897
*/
907-
private int variableLowCE; // used for testing against
898+
private static final int variableLowCE = makeKey(1, 0, 0); // used for testing against
908899

909900
private int variableHighCE; // used for testing against
910901

@@ -1452,8 +1443,6 @@ private void cleanup() {
14521443
}
14531444
*/
14541445

1455-
// fixlater;
1456-
variableLowCE = makeKey(1, 0, 0);
14571446
variableHighCE =
14581447
makeKey(
14591448
ucaData.variableHigh,

unicodetools/src/main/java/org/unicode/text/UCA/WriteAllkeys.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ static void writeAllkeys(String filename, CollatorType collatorType) throws IOEx
6363
addString(collator, "\uFFFE", sorted);
6464
addString(collator, "\uFFFF", sorted);
6565

66-
final int variableTop = CEList.getPrimary(collator.getVariableHighCE());
6766
final StringBuilder extraComment = new StringBuilder();
6867
for (final Entry<String, String> entry : sorted.entrySet()) {
6968
// String key = entry.getKey();
@@ -80,7 +79,7 @@ static void writeAllkeys(String filename, CollatorType collatorType) throws IOEx
8079
log.println(
8180
hex
8281
+ " ; "
83-
+ UCA.toStringUCA(ceList, variableTop, extraComment)
82+
+ collator.toStringUCA(ceList, extraComment)
8483
+ " # "
8584
+ Default.ucd().getName(value)
8685
+ extraComment);

0 commit comments

Comments
 (0)