|
26 | 26 | import org.unicode.props.IndexUnicodeProperties.DefaultValueType; |
27 | 27 | import org.unicode.props.PropertyUtilities.Merge; |
28 | 28 | import org.unicode.props.UcdLineParser.IntRange; |
| 29 | +import org.unicode.props.UcdLineParser.UcdLine.Contents; |
29 | 30 | import org.unicode.text.utility.Settings; |
30 | 31 | import org.unicode.text.utility.Utility; |
31 | 32 |
|
@@ -771,19 +772,53 @@ private static void parsePropertyValueFile( |
771 | 772 | // file: " + propInfo); |
772 | 773 | // } |
773 | 774 | String value; |
774 | | - if (line.getParts().length == 2) { |
775 | | - assert propInfo.property.getType() == PropertyType.Binary; |
| 775 | + // The file emoji-sequences.txt has a comment-like field after the binary property. |
| 776 | + if (line.getParts().length == 2 |
| 777 | + || filename.equals("emoji/*/emoji-sequences") |
| 778 | + || filename.equals("emoji/*/emoji-zwj-sequences")) { |
| 779 | + if (propInfo.property.getType() != PropertyType.Binary) { |
| 780 | + throw new IllegalArgumentException( |
| 781 | + "Expected a value for " |
| 782 | + + propInfo.property.getType() |
| 783 | + + " property " |
| 784 | + + propName); |
| 785 | + } |
776 | 786 | value = "Yes"; |
777 | 787 | } else { |
778 | | - value = |
779 | | - propInfo.property.getType() == PropertyType.Binary |
780 | | - ? "Yes" |
781 | | - : line.getParts()[2]; |
| 788 | + value = line.getParts()[2]; |
| 789 | + if (propInfo.property.getType() == PropertyType.Binary) { |
| 790 | + if (line.getType() == Contents.DATA |
| 791 | + && UcdPropertyValues.Binary.forName(value) |
| 792 | + != UcdPropertyValues.Binary.Yes) { |
| 793 | + // Most binary properties have no value field, but at least kEH_NoRotate has |
| 794 | + // Y. |
| 795 | + throw new IllegalArgumentException( |
| 796 | + "Unexpected value " |
| 797 | + + value |
| 798 | + + " for binary property " |
| 799 | + + propName |
| 800 | + + " in " |
| 801 | + + filename); |
| 802 | + } else if (line.getType() == Contents.MISSING |
| 803 | + && UcdPropertyValues.Binary.forName(value) |
| 804 | + != UcdPropertyValues.Binary.No) { |
| 805 | + throw new IllegalArgumentException( |
| 806 | + "Unexpected default " |
| 807 | + + value |
| 808 | + + " for binary property " |
| 809 | + + propName |
| 810 | + + " in " |
| 811 | + + filename); |
| 812 | + } |
| 813 | + } |
782 | 814 | // The value should not be an empty string. |
783 | 815 | // Exception: NFKC_Casefold does remove some characters by mapping them to nothing. |
784 | | - assert !value.isEmpty() |
785 | | - || propInfo.property == UcdProperty.NFKC_Casefold |
786 | | - || propInfo.property == UcdProperty.NFKC_Simple_Casefold; |
| 816 | + if (value.isEmpty() |
| 817 | + && !(propInfo.property == UcdProperty.NFKC_Casefold |
| 818 | + || propInfo.property == UcdProperty.NFKC_Simple_Casefold)) { |
| 819 | + throw new IllegalArgumentException( |
| 820 | + "Unexpected empty value for property " + propName); |
| 821 | + } |
787 | 822 | if (propInfo.property == UcdProperty.kMandarin) { |
788 | 823 | if (indexUnicodeProperties.oldVersion) { |
789 | 824 | value = |
|
0 commit comments