Skip to content

Commit

Permalink
Merge branch 'roozbehFile' into 170-C9
Browse files Browse the repository at this point in the history
  • Loading branch information
eggrobin committed Oct 2, 2023
2 parents c881001 + e0e2fc2 commit a54fd20
Show file tree
Hide file tree
Showing 2 changed files with 424 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ static class Format {
Map<String, List<String>> fileToPropertySet = new TreeMap<String, List<String>>();
Map<String, String> fileToComments = new TreeMap<String, String>();
Map<String, String> fileToDirectory = new TreeMap<String, String>();
Map<String, List<String>> propertyToOrderedValues = new TreeMap<String, List<String>>();
Map<String, Map<String, String>> propertyToValueToComments =
new TreeMap<String, Map<String, String>>();
Map<String, String> hackMap = new HashMap<String, String>();
Expand Down Expand Up @@ -110,6 +111,12 @@ public static class PrintStyle {
// Unicode 15.1 and later LineBreak.txt and EastAsianWidth.txt, which are all generated
// in that format by some other tool.
boolean kenFile = false;
// Whether the file should be produced in the style of IndicPositionalCategory.txt and
// IndicSyllabicCategory.txt, which are both generated in that format by some other
// tool.
boolean roozbehFile = false;
// Whether to separate values of enumerated properties using a line of equal signs.
boolean separateValues = true;
boolean hackValues = false;
boolean mergeRanges = true;
String nameStyle = "none";
Expand Down Expand Up @@ -138,6 +145,10 @@ String parse(String options) {
interleaveValues = true;
} else if (piece.equals("kenFile")) {
kenFile = true;
} else if (piece.equals("roozbehFile")) {
roozbehFile = true;
} else if (piece.startsWith("separateValues=")) {
separateValues = afterEqualsBoolean(piece);
} else if (piece.equals("hackValues")) {
hackValues = true;
} else if (piece.equals("sortNumeric")) {
Expand Down Expand Up @@ -301,6 +312,10 @@ private void build() {
}
line = line.trim();
if (line.length() == 0) {
if (comments.length() != 0) {
// Preserve blank lines between comments.
comments += "\n";
}
continue;
}
if (DEBUG) {
Expand All @@ -321,6 +336,7 @@ private void build() {
comments += line;
} else {
// end of comments, roll up
comments = comments.trim();
if (comments.length() != 0) {
if (property != null) {
addValueComments(property, value, comments);
Expand Down Expand Up @@ -350,6 +366,12 @@ private void build() {
value = "";
} else if (line.startsWith("Value:")) {
value = lineValue;
var values = propertyToOrderedValues.get(property);
if (values == null) {
values = new ArrayList<String>();
propertyToOrderedValues.put(property, values);
}
values.add(value);
} else if (line.startsWith("HackName:")) {
final String regularItem = Utility.getUnskeleton(lineValue, true);
hackMap.put(regularItem, lineValue);
Expand Down Expand Up @@ -1152,6 +1174,9 @@ public static void generatePropertyFile(String filename) throws IOException {
filename, Format.theFormat.getPrintStyle(name));
if (!ps.kenFile) {
pwProp.println();
if (!ps.separateValues) {
pwProp.println();
}
pwProp.println(SEPARATOR);
}
final String propComment = Format.theFormat.getValueComments(name, "");
Expand All @@ -1161,7 +1186,11 @@ public static void generatePropertyFile(String filename) throws IOException {
pwProp.println(propComment);
} else if (!prop.isType(UnicodeProperty.BINARY_MASK)) {
pwProp.println();
pwProp.println("# Property:\t" + name);
if (ps.roozbehFile) {
pwProp.println("# Property: " + name);
} else {
pwProp.println("# Property:\t" + name);
}
}
}

Expand All @@ -1182,9 +1211,12 @@ public static void generatePropertyFile(String filename) throws IOException {
v = v + " (" + v2 + ")";
}
}
pwProp.println();
pwProp.println(ps.roozbehFile ? "#" : "");
pwProp.println("# All code points not explicitly listed for " + prop.getName());
pwProp.println("# have the value " + v + ".");
pwProp.println(
"# have the value "
+ v
+ (ps.roozbehFile && v.equals("NA") ? " (not applicable)." : "."));
}

if (!ps.interleaveValues && prop.isType(UnicodeProperty.BINARY_MASK)) {
Expand Down Expand Up @@ -1254,6 +1286,9 @@ private static void writeEnumeratedValues(
temp2.addAll(aliases);
aliases = temp2;
}
if (ps.roozbehFile) {
aliases = Format.theFormat.propertyToOrderedValues.get(prop.getName());
}
if (ps.sortNumeric) {
if (DEBUG) {
System.out.println("Reordering");
Expand Down Expand Up @@ -1284,7 +1319,7 @@ private static void writeEnumeratedValues(

final String missing = ps.skipUnassigned != null ? ps.skipUnassigned : ps.skipValue;
if (missing != null && !missing.equals(UCD_Names.NO)) {
pw.println();
pw.println(ps.roozbehFile ? "#" : "");
final String propName = bf.getPropName();
// if (propName == null) propName = "";
// else if (propName.length() != 0) propName = propName + "; ";
Expand All @@ -1302,6 +1337,10 @@ private static void writeEnumeratedValues(
writeEnumeratedMissingValues(pw, overallDefault, defaultLbValues);
}
}
if (!ps.separateValues) {
pw.println();
pw.println(SEPARATOR.replace('=', '-'));
}
for (final Iterator<String> it = aliases.iterator(); it.hasNext(); ) {
final String value = it.next();
if (DEBUG) {
Expand Down Expand Up @@ -1416,9 +1455,13 @@ private static void writeEnumeratedValues(

if (!prop.isType(UnicodeProperty.BINARY_MASK)) {
pw.println();
pw.println(SEPARATOR);
if (ps.separateValues) {
pw.println(SEPARATOR);
}
if (nonLongValue) {
pw.println();
if (ps.separateValues) {
pw.println();
}
pw.println("# " + prop.getName() + "=" + value);
}
}
Expand All @@ -1442,6 +1485,11 @@ private static void writeEnumeratedValues(
pw.println();
// if (s.size() != 0)
bf.setMergeRanges(ps.mergeRanges);
bf.setShowTotal(!ps.roozbehFile);
if (ps.roozbehFile) {
bf.setRangeBreakSource(
ToolUnicodePropertySource.make(Default.ucdVersion()).getProperty("Block"));
}
bf.showSetNames(pw, s);
if (DEBUG) {
System.out.println(bf.showSetNames(s));
Expand Down
Loading

0 comments on commit a54fd20

Please sign in to comment.