Skip to content

Commit

Permalink
Merge remote-tracking branch 'la-vache/main' into 176-C29
Browse files Browse the repository at this point in the history
  • Loading branch information
eggrobin committed Dec 20, 2023
2 parents cc62623 + 7780fa2 commit eb5c8c1
Show file tree
Hide file tree
Showing 97 changed files with 499,596 additions and 408,546 deletions.
32 changes: 27 additions & 5 deletions UnicodeJsps/src/main/java/org/unicode/jsp/ScriptTester.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.ibm.icu.lang.UScript;
import com.ibm.icu.text.Normalizer;
import com.ibm.icu.text.UnicodeSet;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Collection;
import java.util.Comparator;
Expand All @@ -20,6 +21,7 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import org.unicode.props.UnicodeProperty;

/**
* Class for testing whether strings have allowed combinations of multiple scripts.
Expand Down Expand Up @@ -319,6 +321,7 @@ public static class ScriptExtensions {
public static final Comparator<BitSet> COMPARATOR =
new Comparator<BitSet>() {

@Override
public int compare(BitSet o1, BitSet o2) {
int diff = o1.cardinality() - o2.cardinality();
if (diff != 0) return diff;
Expand All @@ -344,6 +347,7 @@ private static class MyHandler extends FileUtilities.SemiFileReader {

UnicodeMap<BitSet> map = new UnicodeMap<BitSet>();

@Override
public boolean handleLine(int start, int end, String[] items) {
BitSet bitSet = new BitSet(LIMIT);
for (String script : SPACES.split(items[1])) {
Expand Down Expand Up @@ -429,21 +433,39 @@ public static UnicodeMap<String> getScriptSpecialsNames() {
return result;
}

public static String[][] getScriptSpecialsAlternates() {
public static String[][] getScriptSpecialsAlternates(UnicodeProperty scriptProp) {
Collection<BitSet> availableValues = getScriptSpecials().getAvailableValues();
String[][] result = new String[availableValues.size()][];
List<String[]> result = new ArrayList<>();
Set<String> names = new TreeSet<String>(); // to alphabetize

int i = 0;
for (BitSet value : availableValues) {
String baseName =
ScriptExtensions.getNames(value, UProperty.NameChoice.LONG, ",", names);
String altName =
ScriptExtensions.getNames(value, UProperty.NameChoice.SHORT, ",", names);
String[] row = {baseName, altName};
result[i++] = row;
result.add(row);
}
return result;

// Get the single values, and build alternate values for the property, for isValidValue
// of a single script (eg Arab)
List<String> values = scriptProp.getAvailableValues();
for (String value : values) {
List<String> row = new ArrayList<>();
row.add(value);
for (String alias : scriptProp.getValueAliases(value)) {
if (!alias.equals(value)) {
row.add(alias);
}
}
// duplicate it whenever singular, because the tooling expects at least 2 values (ugg)
if (row.size() == 1) {
row.add(value);
}
result.add(row.toArray(new String[row.size()]));
}

return result.toArray(new String[result.size()][]);
}

private ScriptTester(UnicodeMap<BitSet> character_scripts) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public MySymbolTable() {
// return null;
// }

@Override
public boolean applyPropertyAlias(
String propertyName, String propertyValue, UnicodeSet result) {
boolean status = false;
Expand Down Expand Up @@ -201,9 +202,11 @@ public boolean applyPropertyAlias(
}
;
if (!status) {
try {
status = applyPropertyAlias0(prop, "No", result, !invert);
} catch (Exception e) {
if (prop.isType(UnicodeProperty.BINARY_OR_ENUMERATED_OR_CATALOG_MASK)) {
try {
status = applyPropertyAlias0(prop, "No", result, !invert);
} catch (Exception e) {
}
}
;
if (!status) {
Expand Down Expand Up @@ -336,6 +339,7 @@ public ComparisonMatcher(String pattern, Relation comparator) {
this.pattern = pattern;
}

@Override
public boolean test(String value) {
int comp = comparator.compare(pattern, value.toString());
switch (relation) {
Expand All @@ -352,6 +356,7 @@ public boolean test(String value) {
}
}

@Override
public PatternMatcher set(String pattern) {
this.pattern = pattern;
return this;
Expand Down
Loading

0 comments on commit eb5c8c1

Please sign in to comment.