12e5b6d6dSopenharmony_ci// © 2017 and later: Unicode, Inc. and others. 22e5b6d6dSopenharmony_ci// License & terms of use: http://www.unicode.org/copyright.html 32e5b6d6dSopenharmony_ci/* 42e5b6d6dSopenharmony_ci******************************************************************************* 52e5b6d6dSopenharmony_ci* 62e5b6d6dSopenharmony_ci* Copyright (C) 2003, International Business Machines 72e5b6d6dSopenharmony_ci* Corporation and others. All Rights Reserved. 82e5b6d6dSopenharmony_ci* 92e5b6d6dSopenharmony_ci******************************************************************************* 102e5b6d6dSopenharmony_ci* 112e5b6d6dSopenharmony_ci* File line.h 122e5b6d6dSopenharmony_ci* 132e5b6d6dSopenharmony_ci* Modification History: 142e5b6d6dSopenharmony_ci* 152e5b6d6dSopenharmony_ci* Date Name Description 162e5b6d6dSopenharmony_ci* 07/07/2003 weiv Creation. 172e5b6d6dSopenharmony_ci******************************************************************************* 182e5b6d6dSopenharmony_ci*/ 192e5b6d6dSopenharmony_ci 202e5b6d6dSopenharmony_ci// 212e5b6d6dSopenharmony_ci// class Line 222e5b6d6dSopenharmony_ci// 232e5b6d6dSopenharmony_ci// Each line from the source file (containing a name, presumably) gets 242e5b6d6dSopenharmony_ci// one of these structs. 252e5b6d6dSopenharmony_ci// 262e5b6d6dSopenharmony_ci 272e5b6d6dSopenharmony_ci#include "strengthprobe.h" 282e5b6d6dSopenharmony_ci 292e5b6d6dSopenharmony_ciStrengthProbe::StrengthProbe(CompareFn comparer, GetSortKeyFn getter, UChar SE, 302e5b6d6dSopenharmony_ci UChar B0, UChar B1, UChar B2, UChar B3) : 312e5b6d6dSopenharmony_ciSE(SE), 322e5b6d6dSopenharmony_ciB0(B0), B1(B1), B2(B2), B3(B3), 332e5b6d6dSopenharmony_ciutilFirstP(&utilFirst), utilSecondP(&utilSecond), 342e5b6d6dSopenharmony_cifrenchSecondary(false), 352e5b6d6dSopenharmony_cicomparer(comparer), skgetter(getter) 362e5b6d6dSopenharmony_ci{ 372e5b6d6dSopenharmony_ci} 382e5b6d6dSopenharmony_ci 392e5b6d6dSopenharmony_ciint 402e5b6d6dSopenharmony_ciStrengthProbe::setProbeChars(UChar B0, UChar B1, UChar B2, UChar B3) 412e5b6d6dSopenharmony_ci{ 422e5b6d6dSopenharmony_ci this->B0 = B0; 432e5b6d6dSopenharmony_ci this->B1 = B1; 442e5b6d6dSopenharmony_ci this->B2 = B2; 452e5b6d6dSopenharmony_ci this-> 462e5b6d6dSopenharmony_ciB3 = B3; 472e5b6d6dSopenharmony_ci return checkSanity(); 482e5b6d6dSopenharmony_ci} 492e5b6d6dSopenharmony_ci 502e5b6d6dSopenharmony_ciint 512e5b6d6dSopenharmony_ciStrengthProbe::checkSanity() 522e5b6d6dSopenharmony_ci{ 532e5b6d6dSopenharmony_ci int sanityRes; 542e5b6d6dSopenharmony_ci utilFirst.setTo(B0); 552e5b6d6dSopenharmony_ci utilSecond.setTo(B3); 562e5b6d6dSopenharmony_ci if((sanityRes = comparer(&utilFirstP, &utilSecondP)) >= 0) { 572e5b6d6dSopenharmony_ci return sanityRes*10 + 3; 582e5b6d6dSopenharmony_ci } 592e5b6d6dSopenharmony_ci utilSecond.setTo(B2); 602e5b6d6dSopenharmony_ci if((sanityRes = comparer(&utilFirstP, &utilSecondP)) >= 0) { 612e5b6d6dSopenharmony_ci return sanityRes*10 + 2; 622e5b6d6dSopenharmony_ci } 632e5b6d6dSopenharmony_ci utilSecond.setTo(B1); 642e5b6d6dSopenharmony_ci if((sanityRes = comparer(&utilFirstP, &utilSecondP)) >= 0) { 652e5b6d6dSopenharmony_ci return sanityRes*10 + 1; 662e5b6d6dSopenharmony_ci } 672e5b6d6dSopenharmony_ci utilFirst.setTo(B3); 682e5b6d6dSopenharmony_ci utilSecond.setTo(B2); 692e5b6d6dSopenharmony_ci if((sanityRes = comparer(&utilFirstP, &utilSecondP)) >= 0) { 702e5b6d6dSopenharmony_ci return sanityRes*10 + 5; 712e5b6d6dSopenharmony_ci } 722e5b6d6dSopenharmony_ci utilSecond.setTo(B1); 732e5b6d6dSopenharmony_ci if((sanityRes = comparer(&utilFirstP, &utilSecondP)) >= 0) { 742e5b6d6dSopenharmony_ci return sanityRes*10 + 4; 752e5b6d6dSopenharmony_ci } 762e5b6d6dSopenharmony_ci utilFirst.setTo(B2); 772e5b6d6dSopenharmony_ci if((sanityRes = comparer(&utilFirstP, &utilSecondP)) >= 0) { 782e5b6d6dSopenharmony_ci return sanityRes*10 + 6; 792e5b6d6dSopenharmony_ci } 802e5b6d6dSopenharmony_ci utilFirst.setTo(B0); 812e5b6d6dSopenharmony_ci if(distanceFromEmptyString(utilFirst) > UCOL_PRIMARY) { 822e5b6d6dSopenharmony_ci return 1000; 832e5b6d6dSopenharmony_ci } 842e5b6d6dSopenharmony_ci utilFirst.setTo(B1); 852e5b6d6dSopenharmony_ci if(distanceFromEmptyString(utilFirst) > UCOL_PRIMARY) { 862e5b6d6dSopenharmony_ci return 1001; 872e5b6d6dSopenharmony_ci } 882e5b6d6dSopenharmony_ci utilFirst.setTo(B2); 892e5b6d6dSopenharmony_ci if(distanceFromEmptyString(utilFirst) > UCOL_PRIMARY) { 902e5b6d6dSopenharmony_ci return 1002; 912e5b6d6dSopenharmony_ci } 922e5b6d6dSopenharmony_ci utilFirst.setTo(B3); 932e5b6d6dSopenharmony_ci if(distanceFromEmptyString(utilFirst) > UCOL_PRIMARY) { 942e5b6d6dSopenharmony_ci return 1003; 952e5b6d6dSopenharmony_ci } 962e5b6d6dSopenharmony_ci return 0; 972e5b6d6dSopenharmony_ci} 982e5b6d6dSopenharmony_ci 992e5b6d6dSopenharmony_ciUBool 1002e5b6d6dSopenharmony_ciStrengthProbe::probePrefix(const Line &x, const Line &y, UChar first, UChar second) { 1012e5b6d6dSopenharmony_ci utilFirst.name[0] = first; 1022e5b6d6dSopenharmony_ci utilFirst.name[1] = SE; 1032e5b6d6dSopenharmony_ci u_strcpy(utilFirst.name+2, x.name); 1042e5b6d6dSopenharmony_ci utilFirst.name[x.len+2] = 0; 1052e5b6d6dSopenharmony_ci utilFirst.len = x.len+2; 1062e5b6d6dSopenharmony_ci 1072e5b6d6dSopenharmony_ci utilSecond.name[0] = second; 1082e5b6d6dSopenharmony_ci utilSecond.name[1] = SE; 1092e5b6d6dSopenharmony_ci u_strcpy(utilSecond.name+2, y.name); 1102e5b6d6dSopenharmony_ci utilSecond.name[y.len+2] = 0; 1112e5b6d6dSopenharmony_ci utilSecond.len = y.len+2; 1122e5b6d6dSopenharmony_ci 1132e5b6d6dSopenharmony_ci if(comparer(&utilFirstP, &utilSecondP) < 0) { 1142e5b6d6dSopenharmony_ci return true; 1152e5b6d6dSopenharmony_ci } else { 1162e5b6d6dSopenharmony_ci return false; 1172e5b6d6dSopenharmony_ci } 1182e5b6d6dSopenharmony_ci} 1192e5b6d6dSopenharmony_ci 1202e5b6d6dSopenharmony_ciUBool 1212e5b6d6dSopenharmony_ciStrengthProbe::probeSuffix(const Line &x, const Line &y, UChar first, UChar second) { 1222e5b6d6dSopenharmony_ci u_strcpy(utilFirst.name, x.name); 1232e5b6d6dSopenharmony_ci utilFirst.name[x.len] = SE; 1242e5b6d6dSopenharmony_ci utilFirst.name[x.len+1] = first; 1252e5b6d6dSopenharmony_ci utilFirst.name[x.len+2] = 0; 1262e5b6d6dSopenharmony_ci utilFirst.len = x.len + 2; 1272e5b6d6dSopenharmony_ci u_strcpy(utilSecond.name, y.name); 1282e5b6d6dSopenharmony_ci utilSecond.name[y.len] = SE; 1292e5b6d6dSopenharmony_ci utilSecond.name[y.len+1] = second; 1302e5b6d6dSopenharmony_ci utilSecond.name[y.len+2] = 0; 1312e5b6d6dSopenharmony_ci utilSecond.len = y.len + 2; 1322e5b6d6dSopenharmony_ci 1332e5b6d6dSopenharmony_ci if(comparer(&utilFirstP, &utilSecondP) < 0) { 1342e5b6d6dSopenharmony_ci return true; 1352e5b6d6dSopenharmony_ci } else { 1362e5b6d6dSopenharmony_ci return false; 1372e5b6d6dSopenharmony_ci } 1382e5b6d6dSopenharmony_ci} 1392e5b6d6dSopenharmony_ci 1402e5b6d6dSopenharmony_ciUBool 1412e5b6d6dSopenharmony_ciStrengthProbe::probePrefixNoSep(const Line &x, const Line &y, UChar first, UChar second) { 1422e5b6d6dSopenharmony_ci utilFirst.name[0] = first; 1432e5b6d6dSopenharmony_ci u_strcpy(utilFirst.name+1, x.name); 1442e5b6d6dSopenharmony_ci utilFirst.name[x.len+1] = 0; 1452e5b6d6dSopenharmony_ci utilFirst.len = x.len + 1; 1462e5b6d6dSopenharmony_ci 1472e5b6d6dSopenharmony_ci utilSecond.name[0] = second; 1482e5b6d6dSopenharmony_ci u_strcpy(utilSecond.name+1, y.name); 1492e5b6d6dSopenharmony_ci utilSecond.name[y.len+1] = 0; 1502e5b6d6dSopenharmony_ci utilSecond.len = y.len + 1; 1512e5b6d6dSopenharmony_ci 1522e5b6d6dSopenharmony_ci if(comparer(&utilFirstP, &utilSecondP) < 0) { 1532e5b6d6dSopenharmony_ci return true; 1542e5b6d6dSopenharmony_ci } else { 1552e5b6d6dSopenharmony_ci return false; 1562e5b6d6dSopenharmony_ci } 1572e5b6d6dSopenharmony_ci} 1582e5b6d6dSopenharmony_ci 1592e5b6d6dSopenharmony_ciUBool 1602e5b6d6dSopenharmony_ciStrengthProbe::probeSuffixNoSep(const Line &x, const Line &y, UChar first, UChar second) { 1612e5b6d6dSopenharmony_ci u_strcpy(utilFirst.name, x.name); 1622e5b6d6dSopenharmony_ci utilFirst.name[x.len] = first; 1632e5b6d6dSopenharmony_ci utilFirst.name[x.len+1] = 0; 1642e5b6d6dSopenharmony_ci utilFirst.len = x.len + 1; 1652e5b6d6dSopenharmony_ci u_strcpy(utilSecond.name, y.name); 1662e5b6d6dSopenharmony_ci utilSecond.name[y.len] = second; 1672e5b6d6dSopenharmony_ci utilSecond.name[y.len+1] = 0; 1682e5b6d6dSopenharmony_ci utilSecond.len = y.len + 1; 1692e5b6d6dSopenharmony_ci 1702e5b6d6dSopenharmony_ci if(comparer(&utilFirstP, &utilSecondP) < 0) { 1712e5b6d6dSopenharmony_ci return true; 1722e5b6d6dSopenharmony_ci } else { 1732e5b6d6dSopenharmony_ci return false; 1742e5b6d6dSopenharmony_ci } 1752e5b6d6dSopenharmony_ci} 1762e5b6d6dSopenharmony_ci 1772e5b6d6dSopenharmony_ciUColAttributeValue 1782e5b6d6dSopenharmony_ciStrengthProbe::getStrength(const Line &x, const Line &y) { 1792e5b6d6dSopenharmony_ci const Line *xp = &x; 1802e5b6d6dSopenharmony_ci const Line *yp = &y; 1812e5b6d6dSopenharmony_ci 1822e5b6d6dSopenharmony_ci Line empty; 1832e5b6d6dSopenharmony_ci Line *emptyP = ∅ 1842e5b6d6dSopenharmony_ci if(comparer(&emptyP, &xp) == 0) { 1852e5b6d6dSopenharmony_ci return distanceFromEmptyString(y); 1862e5b6d6dSopenharmony_ci } 1872e5b6d6dSopenharmony_ci 1882e5b6d6dSopenharmony_ci int32_t result = comparer(&xp, &yp); 1892e5b6d6dSopenharmony_ci 1902e5b6d6dSopenharmony_ci if(result == 0) { 1912e5b6d6dSopenharmony_ci return UCOL_IDENTICAL; 1922e5b6d6dSopenharmony_ci } else if(result > 0) { 1932e5b6d6dSopenharmony_ci return UCOL_OFF; // bad situation 1942e5b6d6dSopenharmony_ci } else { // we need to probe strength 1952e5b6d6dSopenharmony_ci if(probeSuffix(x, y, B1, B0)) { 1962e5b6d6dSopenharmony_ci //if(probePrefix(x, y, B2, B0)) { // swamps secondary difference 1972e5b6d6dSopenharmony_ci return UCOL_PRIMARY; 1982e5b6d6dSopenharmony_ci } else if(probePrefix(x, y, B3, B0)) { // swamps tertiary difference 1992e5b6d6dSopenharmony_ci return UCOL_SECONDARY; 2002e5b6d6dSopenharmony_ci } else if(probeSuffix(x, y, B3, B0)) { // swamped by tertiary difference 2012e5b6d6dSopenharmony_ci return UCOL_TERTIARY; 2022e5b6d6dSopenharmony_ci } else if(!probePrefix(x, y, B3, B0)) { 2032e5b6d6dSopenharmony_ci return UCOL_QUATERNARY; 2042e5b6d6dSopenharmony_ci } 2052e5b6d6dSopenharmony_ci /* 2062e5b6d6dSopenharmony_ci //if(probeSuffix(x, y, B1, B0)) { 2072e5b6d6dSopenharmony_ci if(probePrefix(x, y, B2, B0)) { // swamps secondary difference 2082e5b6d6dSopenharmony_ci return UCOL_PRIMARY; 2092e5b6d6dSopenharmony_ci } else if(probePrefix(x, y, B3, B0)) { // swamps tertiary difference 2102e5b6d6dSopenharmony_ci return UCOL_SECONDARY; 2112e5b6d6dSopenharmony_ci } else if(probeSuffix(x, y, B3, B0)) { // swamped by tertiary difference 2122e5b6d6dSopenharmony_ci return UCOL_TERTIARY; 2132e5b6d6dSopenharmony_ci } else if(!probePrefix(x, y, B3, B0)) { 2142e5b6d6dSopenharmony_ci return UCOL_QUATERNARY; 2152e5b6d6dSopenharmony_ci } 2162e5b6d6dSopenharmony_ci */ 2172e5b6d6dSopenharmony_ci } 2182e5b6d6dSopenharmony_ci return UCOL_OFF; // bad 2192e5b6d6dSopenharmony_ci} 2202e5b6d6dSopenharmony_ci 2212e5b6d6dSopenharmony_ciUColAttributeValue 2222e5b6d6dSopenharmony_ciStrengthProbe::getStrength(const UnicodeString &sx, const UnicodeString &sy) { 2232e5b6d6dSopenharmony_ci Line x(sx); 2242e5b6d6dSopenharmony_ci Line y(sy); 2252e5b6d6dSopenharmony_ci return getStrength(x, y); 2262e5b6d6dSopenharmony_ci} 2272e5b6d6dSopenharmony_ci 2282e5b6d6dSopenharmony_ciint32_t 2292e5b6d6dSopenharmony_ciStrengthProbe::compare(const UnicodeString &sx, const UnicodeString &sy) { 2302e5b6d6dSopenharmony_ci Line x(sx); 2312e5b6d6dSopenharmony_ci Line y(sy); 2322e5b6d6dSopenharmony_ci const Line *xp = &x; 2332e5b6d6dSopenharmony_ci const Line *yp = &y; 2342e5b6d6dSopenharmony_ci return comparer(&xp, &yp); 2352e5b6d6dSopenharmony_ci} 2362e5b6d6dSopenharmony_ci 2372e5b6d6dSopenharmony_ciint32_t 2382e5b6d6dSopenharmony_ciStrengthProbe::compare(const Line &x, const Line &y) { 2392e5b6d6dSopenharmony_ci const Line *xp = &x; 2402e5b6d6dSopenharmony_ci const Line *yp = &y; 2412e5b6d6dSopenharmony_ci return comparer(&xp, &yp); 2422e5b6d6dSopenharmony_ci} 2432e5b6d6dSopenharmony_ci 2442e5b6d6dSopenharmony_ciUColAttributeValue 2452e5b6d6dSopenharmony_ciStrengthProbe::distanceFromEmptyString(const Line &x) { 2462e5b6d6dSopenharmony_ci if(x.name[0] == 0x30D) { 2472e5b6d6dSopenharmony_ci int32_t putBreakPointHere = 0; 2482e5b6d6dSopenharmony_ci } 2492e5b6d6dSopenharmony_ci Line empty; 2502e5b6d6dSopenharmony_ci Line *emptyP = ∅ 2512e5b6d6dSopenharmony_ci uint8_t buff[256]; 2522e5b6d6dSopenharmony_ci getSortKey(empty.name, empty.len, buff, 256); 2532e5b6d6dSopenharmony_ci Line B0Line(B0); 2542e5b6d6dSopenharmony_ci Line *B0LineP = &B0Line; 2552e5b6d6dSopenharmony_ci const Line *xp = &x; 2562e5b6d6dSopenharmony_ci int32_t result = comparer(&emptyP, &xp); 2572e5b6d6dSopenharmony_ci if(result == 0) { 2582e5b6d6dSopenharmony_ci return UCOL_IDENTICAL; 2592e5b6d6dSopenharmony_ci } else if(result > 0) { 2602e5b6d6dSopenharmony_ci return UCOL_OFF; 2612e5b6d6dSopenharmony_ci } 2622e5b6d6dSopenharmony_ci result = comparer(&B0LineP, &xp); 2632e5b6d6dSopenharmony_ci if(result <= 0) { 2642e5b6d6dSopenharmony_ci return UCOL_PRIMARY; 2652e5b6d6dSopenharmony_ci } 2662e5b6d6dSopenharmony_ci Line sexb0(SE); 2672e5b6d6dSopenharmony_ci sexb0.append(x.name, x.len); 2682e5b6d6dSopenharmony_ci sexb0.append(B0); 2692e5b6d6dSopenharmony_ci 2702e5b6d6dSopenharmony_ci Line seb0(SE); 2712e5b6d6dSopenharmony_ci seb0.append(B0); 2722e5b6d6dSopenharmony_ci uint8_t seb0K[256]; 2732e5b6d6dSopenharmony_ci uint8_t sexb0K[256]; 2742e5b6d6dSopenharmony_ci uint8_t seb2K[256]; 2752e5b6d6dSopenharmony_ci uint8_t seb3K[256]; 2762e5b6d6dSopenharmony_ci memset(seb0K, 0, 256); 2772e5b6d6dSopenharmony_ci memset(sexb0K, 0, 256); 2782e5b6d6dSopenharmony_ci memset(seb2K, 0, 256); 2792e5b6d6dSopenharmony_ci memset(seb3K, 0, 256); 2802e5b6d6dSopenharmony_ci 2812e5b6d6dSopenharmony_ci getSortKey(seb0, seb0K, 256); 2822e5b6d6dSopenharmony_ci getSortKey(sexb0, sexb0K, 256); 2832e5b6d6dSopenharmony_ci 2842e5b6d6dSopenharmony_ci if(compare(seb0, sexb0) <= 0) { 2852e5b6d6dSopenharmony_ci Line seb2(SE); 2862e5b6d6dSopenharmony_ci seb2.append(B2); 2872e5b6d6dSopenharmony_ci getSortKey(seb2, seb2K, 256); 2882e5b6d6dSopenharmony_ci result = compare(seb2, sexb0); 2892e5b6d6dSopenharmony_ci if((result <= 0 && !frenchSecondary) || (result >= 0 && frenchSecondary)) { // swamps tertiary difference 2902e5b6d6dSopenharmony_ci return UCOL_SECONDARY; 2912e5b6d6dSopenharmony_ci } 2922e5b6d6dSopenharmony_ci Line seb3(SE); 2932e5b6d6dSopenharmony_ci seb3.append(B3); 2942e5b6d6dSopenharmony_ci getSortKey(seb3, seb3K, 256); 2952e5b6d6dSopenharmony_ci if(compare(seb3, sexb0) < 0) { 2962e5b6d6dSopenharmony_ci return UCOL_TERTIARY; 2972e5b6d6dSopenharmony_ci } 2982e5b6d6dSopenharmony_ci return UCOL_QUATERNARY; 2992e5b6d6dSopenharmony_ci } else { 3002e5b6d6dSopenharmony_ci // if this was UCA, we would have a primary difference. 3012e5b6d6dSopenharmony_ci // however, this might not be so, since not everybody 3022e5b6d6dSopenharmony_ci // makes well formed CEs. 3032e5b6d6dSopenharmony_ci // in cs_CZ on linux, space is tertiary ignorable, but 3042e5b6d6dSopenharmony_ci // its quaternary level strength is lower than quad 3052e5b6d6dSopenharmony_ci // strengths for non-ignorables. oh well, more testing 3062e5b6d6dSopenharmony_ci // required 3072e5b6d6dSopenharmony_ci // I think that we can only have quaternary difference 3082e5b6d6dSopenharmony_ci // here (in addition to primary difference). 3092e5b6d6dSopenharmony_ci //if(!probePrefix(x, empty, B3, B0)) { 3102e5b6d6dSopenharmony_ci //return UCOL_QUATERNARY; 3112e5b6d6dSopenharmony_ci //} else { 3122e5b6d6dSopenharmony_ci return UCOL_PRIMARY; 3132e5b6d6dSopenharmony_ci //} 3142e5b6d6dSopenharmony_ci } 3152e5b6d6dSopenharmony_ci} 3162e5b6d6dSopenharmony_ci 3172e5b6d6dSopenharmony_ciUColAttributeValue 3182e5b6d6dSopenharmony_ciStrengthProbe::distanceFromEmptyString(const UnicodeString &x) { 3192e5b6d6dSopenharmony_ci const Line xp(x); 3202e5b6d6dSopenharmony_ci return distanceFromEmptyString(xp); 3212e5b6d6dSopenharmony_ci} 3222e5b6d6dSopenharmony_ci 3232e5b6d6dSopenharmony_ci 3242e5b6d6dSopenharmony_ciUColAttributeValue 3252e5b6d6dSopenharmony_ciStrengthProbe::getPrefixedStrength(const Line &prefix, const Line &x, const Line &y) { 3262e5b6d6dSopenharmony_ci contractionUtilFirst.setToConcat(&prefix, &x); 3272e5b6d6dSopenharmony_ci contractionUtilSecond.setToConcat(&prefix, &y); 3282e5b6d6dSopenharmony_ci return getStrength(contractionUtilFirst, contractionUtilSecond); 3292e5b6d6dSopenharmony_ci} 3302e5b6d6dSopenharmony_ci 3312e5b6d6dSopenharmony_ci 3322e5b6d6dSopenharmony_ciStrengthProbe::StrengthProbe(const StrengthProbe &that) { 3332e5b6d6dSopenharmony_ci *this = that; 3342e5b6d6dSopenharmony_ci} 3352e5b6d6dSopenharmony_ci 3362e5b6d6dSopenharmony_ciStrengthProbe & 3372e5b6d6dSopenharmony_ciStrengthProbe::operator=(const StrengthProbe &that) { 3382e5b6d6dSopenharmony_ci if(this != &that) { 3392e5b6d6dSopenharmony_ci B0 = that.B0; 3402e5b6d6dSopenharmony_ci B1 = that.B1; 3412e5b6d6dSopenharmony_ci B2 = that.B2; 3422e5b6d6dSopenharmony_ci B3 = that.B3; 3432e5b6d6dSopenharmony_ci SE = that.SE; 3442e5b6d6dSopenharmony_ci frenchSecondary = that.frenchSecondary; 3452e5b6d6dSopenharmony_ci comparer = that.comparer; 3462e5b6d6dSopenharmony_ci skgetter = that.skgetter; 3472e5b6d6dSopenharmony_ci 3482e5b6d6dSopenharmony_ci utilFirstP = &utilFirst; 3492e5b6d6dSopenharmony_ci utilSecondP = &utilSecond; 3502e5b6d6dSopenharmony_ci } 3512e5b6d6dSopenharmony_ci 3522e5b6d6dSopenharmony_ci return *this; 3532e5b6d6dSopenharmony_ci} 3542e5b6d6dSopenharmony_ci 3552e5b6d6dSopenharmony_ciUBool 3562e5b6d6dSopenharmony_ciStrengthProbe::isFrenchSecondary(UErrorCode &status) { 3572e5b6d6dSopenharmony_ci utilFirst.setTo(B0); 3582e5b6d6dSopenharmony_ci utilFirst.append(SE); 3592e5b6d6dSopenharmony_ci utilFirst.append(B2); 3602e5b6d6dSopenharmony_ci utilSecond.setTo(B2); 3612e5b6d6dSopenharmony_ci utilSecond.append(SE); 3622e5b6d6dSopenharmony_ci utilSecond.append(B0); 3632e5b6d6dSopenharmony_ci 3642e5b6d6dSopenharmony_ci int32_t result = compare(utilFirst, utilSecond); 3652e5b6d6dSopenharmony_ci 3662e5b6d6dSopenharmony_ci if(result < 0) { 3672e5b6d6dSopenharmony_ci return false; 3682e5b6d6dSopenharmony_ci } else if(result > 0) { 3692e5b6d6dSopenharmony_ci frenchSecondary = true; 3702e5b6d6dSopenharmony_ci return true; 3712e5b6d6dSopenharmony_ci } else { 3722e5b6d6dSopenharmony_ci status = U_INTERNAL_PROGRAM_ERROR; 3732e5b6d6dSopenharmony_ci return false; 3742e5b6d6dSopenharmony_ci } 3752e5b6d6dSopenharmony_ci} 3762e5b6d6dSopenharmony_ci 3772e5b6d6dSopenharmony_ciUBool 3782e5b6d6dSopenharmony_ciStrengthProbe::isUpperFirst(UErrorCode &status) { 3792e5b6d6dSopenharmony_ci UChar i = 0; 3802e5b6d6dSopenharmony_ci int32_t result = 0; 3812e5b6d6dSopenharmony_ci int32_t upper = 0, lower = 0, equal = 0; 3822e5b6d6dSopenharmony_ci for(i = 0x41; i < 0x5B; i++) { 3832e5b6d6dSopenharmony_ci utilFirst.setTo(i); 3842e5b6d6dSopenharmony_ci utilSecond.setTo(i+0x20); 3852e5b6d6dSopenharmony_ci result = compare(utilFirst, utilSecond); 3862e5b6d6dSopenharmony_ci if(result < 0) { 3872e5b6d6dSopenharmony_ci upper++; 3882e5b6d6dSopenharmony_ci } else if(result > 0) { 3892e5b6d6dSopenharmony_ci lower++; 3902e5b6d6dSopenharmony_ci } else { 3912e5b6d6dSopenharmony_ci equal++; 3922e5b6d6dSopenharmony_ci } 3932e5b6d6dSopenharmony_ci } 3942e5b6d6dSopenharmony_ci 3952e5b6d6dSopenharmony_ci if(lower == 0 && equal == 0) { 3962e5b6d6dSopenharmony_ci return true; 3972e5b6d6dSopenharmony_ci } 3982e5b6d6dSopenharmony_ci if(upper == 0 && equal == 0) { 3992e5b6d6dSopenharmony_ci return false; 4002e5b6d6dSopenharmony_ci } 4012e5b6d6dSopenharmony_ci status = U_INTERNAL_PROGRAM_ERROR; 4022e5b6d6dSopenharmony_ci return false; 4032e5b6d6dSopenharmony_ci} 4042e5b6d6dSopenharmony_ci 405