Issue #1971 - Part 2: Update ICU source to 63.2.

This commit is contained in:
Job Bautista 2022-07-24 21:03:27 +08:00 committed by roytam1
commit 1e69214382
3160 changed files with 275815 additions and 234203 deletions

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
@ -8,7 +8,7 @@
*
*******************************************************************************
* file name: uprops.cpp
* encoding: US-ASCII
* encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
@ -25,6 +25,7 @@
#include "unicode/utypes.h"
#include "unicode/uchar.h"
#include "unicode/ucptrie.h"
#include "unicode/unorm2.h"
#include "unicode/uscript.h"
#include "unicode/ustring.h"
@ -36,9 +37,11 @@
#include "ucase.h"
#include "ustr_imp.h"
U_NAMESPACE_USE
// ulayout_props_data.h is machine-generated by genprops
#define INCLUDED_FROM_UPROPS_CPP
#include "ulayout_props_data.h"
#define GET_BIDI_PROPS() ubidi_getSingleton()
U_NAMESPACE_USE
/* general properties API functions ----------------------------------------- */
@ -58,19 +61,19 @@ static UBool defaultContains(const BinaryProperty &prop, UChar32 c, UProperty /*
}
static UBool caseBinaryPropertyContains(const BinaryProperty &/*prop*/, UChar32 c, UProperty which) {
return ucase_hasBinaryProperty(c, which);
return static_cast<UBool>(ucase_hasBinaryProperty(c, which));
}
static UBool isBidiControl(const BinaryProperty &/*prop*/, UChar32 c, UProperty /*which*/) {
return ubidi_isBidiControl(GET_BIDI_PROPS(), c);
return ubidi_isBidiControl(c);
}
static UBool isMirrored(const BinaryProperty &/*prop*/, UChar32 c, UProperty /*which*/) {
return ubidi_isMirrored(GET_BIDI_PROPS(), c);
return ubidi_isMirrored(c);
}
static UBool isJoinControl(const BinaryProperty &/*prop*/, UChar32 c, UProperty /*which*/) {
return ubidi_isJoinControl(GET_BIDI_PROPS(), c);
return ubidi_isJoinControl(c);
}
#if UCONFIG_NO_NORMALIZATION
@ -128,9 +131,8 @@ static UBool changesWhenCasefolded(const BinaryProperty &/*prop*/, UChar32 c, UP
}
if(c>=0) {
/* single code point */
const UCaseProps *csp=ucase_getSingleton();
const UChar *resultString;
return (UBool)(ucase_toFullFolding(csp, c, &resultString, U_FOLD_CASE_DEFAULT)>=0);
return (UBool)(ucase_toFullFolding(c, &resultString, U_FOLD_CASE_DEFAULT)>=0);
} else {
/* guess some large but stack-friendly capacity */
UChar dest[2*UCASE_MAX_STRING_LENGTH];
@ -207,6 +209,11 @@ static UBool isPOSIX_xdigit(const BinaryProperty &/*prop*/, UChar32 c, UProperty
return u_isxdigit(c);
}
static UBool isRegionalIndicator(const BinaryProperty &/*prop*/, UChar32 c, UProperty /*which*/) {
// Property starts are a subset of lb=RI etc.
return 0x1F1E6<=c && c<=0x1F1FF;
}
static const BinaryProperty binProps[UCHAR_BINARY_LIMIT]={
/*
* column and mask values for binary properties from u_getUnicodeProperties().
@ -277,6 +284,10 @@ static const BinaryProperty binProps[UCHAR_BINARY_LIMIT]={
{ 2, U_MASK(UPROPS_2_EMOJI_PRESENTATION), defaultContains },
{ 2, U_MASK(UPROPS_2_EMOJI_MODIFIER), defaultContains },
{ 2, U_MASK(UPROPS_2_EMOJI_MODIFIER_BASE), defaultContains },
{ 2, U_MASK(UPROPS_2_EMOJI_COMPONENT), defaultContains },
{ 2, 0, isRegionalIndicator },
{ 1, U_MASK(UPROPS_PREPENDED_CONCATENATION_MARK), defaultContains },
{ 2, U_MASK(UPROPS_2_EXTENDED_PICTOGRAPHIC), defaultContains },
};
U_CAPI UBool U_EXPORT2
@ -322,11 +333,11 @@ static int32_t getBiDiClass(const IntProperty &/*prop*/, UChar32 c, UProperty /*
}
static int32_t getBiDiPairedBracketType(const IntProperty &/*prop*/, UChar32 c, UProperty /*which*/) {
return (int32_t)ubidi_getPairedBracketType(GET_BIDI_PROPS(), c);
return (int32_t)ubidi_getPairedBracketType(c);
}
static int32_t biDiGetMaxValue(const IntProperty &/*prop*/, UProperty which) {
return ubidi_getMaxValue(GET_BIDI_PROPS(), which);
return ubidi_getMaxValue(which);
}
#if UCONFIG_NO_NORMALIZATION
@ -344,11 +355,11 @@ static int32_t getGeneralCategory(const IntProperty &/*prop*/, UChar32 c, UPrope
}
static int32_t getJoiningGroup(const IntProperty &/*prop*/, UChar32 c, UProperty /*which*/) {
return ubidi_getJoiningGroup(GET_BIDI_PROPS(), c);
return ubidi_getJoiningGroup(c);
}
static int32_t getJoiningType(const IntProperty &/*prop*/, UChar32 c, UProperty /*which*/) {
return ubidi_getJoiningType(GET_BIDI_PROPS(), c);
return ubidi_getJoiningType(c);
}
static int32_t getNumericType(const IntProperty &/*prop*/, UChar32 c, UProperty /*which*/) {
@ -422,6 +433,18 @@ static int32_t getTrailCombiningClass(const IntProperty &/*prop*/, UChar32 c, UP
}
#endif
static int32_t getInPC(const IntProperty &, UChar32 c, UProperty) {
return ucptrie_get(&inpc_trie, c);
}
static int32_t getInSC(const IntProperty &, UChar32 c, UProperty) {
return ucptrie_get(&insc_trie, c);
}
static int32_t getVo(const IntProperty &, UChar32 c, UProperty) {
return ucptrie_get(&vo_trie, c);
}
static const IntProperty intProps[UCHAR_INT_LIMIT-UCHAR_INT_START]={
/*
* column, mask and shift values for int-value properties from u_getUnicodeProperties().
@ -457,6 +480,9 @@ static const IntProperty intProps[UCHAR_INT_LIMIT-UCHAR_INT_START]={
{ 2, UPROPS_SB_MASK, UPROPS_SB_SHIFT, defaultGetValue, defaultGetMaxValue },
{ 2, UPROPS_WB_MASK, UPROPS_WB_SHIFT, defaultGetValue, defaultGetMaxValue },
{ UPROPS_SRC_BIDI, 0, 0, getBiDiPairedBracketType, biDiGetMaxValue },
{ UPROPS_SRC_INPC, 0, maxInPCValue, getInPC, getMaxValueFromShift },
{ UPROPS_SRC_INSC, 0, maxInSCValue, getInSC, getMaxValueFromShift },
{ UPROPS_SRC_VO, 0, maxVoValue, getVo, getMaxValueFromShift },
};
U_CAPI int32_t U_EXPORT2
@ -558,6 +584,34 @@ uprops_getSource(UProperty which) {
}
}
U_CFUNC void U_EXPORT2
uprops_addPropertyStarts(UPropertySource src, const USetAdder *sa, UErrorCode *pErrorCode) {
if (U_FAILURE(*pErrorCode)) { return; }
const UCPTrie *trie;
switch (src) {
case UPROPS_SRC_INPC:
trie = &inpc_trie;
break;
case UPROPS_SRC_INSC:
trie = &insc_trie;
break;
case UPROPS_SRC_VO:
trie = &vo_trie;
break;
default:
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
// Add the start code point of each same-value range of the trie.
UChar32 start = 0, end;
while ((end = ucptrie_getRange(trie, start, UCPMAP_RANGE_NORMAL, 0,
nullptr, nullptr, nullptr)) >= 0) {
sa->add(sa->set, start);
start = end + 1;
}
}
#if !UCONFIG_NO_NORMALIZATION
U_CAPI int32_t U_EXPORT2
@ -576,14 +630,13 @@ u_getFC_NFKC_Closure(UChar32 c, UChar *dest, int32_t destCapacity, UErrorCode *p
// case folding and NFKC.)
// For the derivation, see Unicode's DerivedNormalizationProps.txt.
const Normalizer2 *nfkc=Normalizer2::getNFKCInstance(*pErrorCode);
const UCaseProps *csp=ucase_getSingleton();
if(U_FAILURE(*pErrorCode)) {
return 0;
}
// first: b = NFKC(Fold(a))
UnicodeString folded1String;
const UChar *folded1;
int32_t folded1Length=ucase_toFullFolding(csp, c, &folded1, U_FOLD_CASE_DEFAULT);
int32_t folded1Length=ucase_toFullFolding(c, &folded1, U_FOLD_CASE_DEFAULT);
if(folded1Length<0) {
const Normalizer2Impl *nfkcImpl=Normalizer2Factory::getImpl(nfkc);
if(nfkcImpl->getCompQuickCheck(nfkcImpl->getNorm16(c))!=UNORM_NO) {