Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICU-22833 Port ICU 74.2 to Oracle Studio 12.6 #3062

Open
wants to merge 9 commits into
base: maint/maint-74
Choose a base branch
from
8 changes: 8 additions & 0 deletions icu4c/source/common/static_unicode_sets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,14 @@ Key unisets::chooseFrom(UnicodeString str, Key key1, Key key2) {
return get(key1)->contains(str) ? key1 : chooseFrom(str, key2);
}

CurrencySymbols unisets::kCurrencyEntries[5] = {
{DOLLAR_SIGN, u'$'},
{POUND_SIGN, u'£'},
{RUPEE_SIGN, u'₹'},
{YEN_SIGN, u'¥'},
{WON_SIGN, u'₩'},
};

//Key unisets::chooseCurrency(UnicodeString str) {
// if (get(DOLLAR_SIGN)->contains(str)) {
// return DOLLAR_SIGN;
Expand Down
10 changes: 2 additions & 8 deletions icu4c/source/common/static_unicode_sets.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,10 @@ U_COMMON_API Key chooseFrom(UnicodeString str, Key key1, Key key2);
// Unused in C++:
// Key chooseCurrency(UnicodeString str);
// Used instead:
static const struct {
extern struct CurrencySymbols {
Key key;
UChar32 exemplar;
} kCurrencyEntries[] = {
{DOLLAR_SIGN, u'$'},
{POUND_SIGN, u'£'},
{RUPEE_SIGN, u'₹'},
{YEN_SIGN, u'¥'},
{WON_SIGN, u'₩'},
};
} kCurrencyEntries[5];

} // namespace unisets
U_NAMESPACE_END
Expand Down
4 changes: 3 additions & 1 deletion icu4c/source/common/uniset_props.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,16 @@ void U_CALLCONV createUni32Set(UErrorCode &errorCode) {
}
ucln_common_registerCleanup(UCLN_COMMON_USET, uset_cleanup);
}

}

U_CFUNC UnicodeSet *
uniset_getUnicode32Instance(UErrorCode &errorCode) {
umtx_initOnce(uni32InitOnce, &createUni32Set, errorCode);
return uni32Singleton;
}

namespace {

// helper functions for matching of pattern syntax pieces ------------------ ***
// these functions are parallel to the PERL_OPEN etc. strings above

Expand Down
3 changes: 1 addition & 2 deletions icu4c/source/i18n/formatted_string_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ static_assert(

constexpr FormattedStringBuilder::Field::Field(uint8_t category, uint8_t field)
: bits((
U_ASSERT(category <= 0xf),
U_ASSERT(field <= 0xf),
U_ASSERT(category <= 0xf && field <= 0xf),
static_cast<uint8_t>((category << 4) | field)
)) {}

Expand Down
4 changes: 2 additions & 2 deletions icu4c/source/test/intltest/convtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ ConversionTest::TestUTF8ToUTF8Overflow() {
assertEquals("overflow", U_BUFFER_OVERFLOW_ERROR, errorCode.reset());
length = (int32_t)(target - result);
assertEquals("number of bytes written", 2, length);
assertEquals("next byte not clobbered", 5, result[2]);
assertEquals("next byte not clobbered", (char)5, result[2]);

// Convert the rest and flush.
ucnv_convertEx(cnv2.getAlias(), cnv1.getAlias(),
Expand Down Expand Up @@ -777,7 +777,7 @@ ConversionTest::TestUTF8ToUTF8Overflow() {
assertEquals("text2 overflow", U_BUFFER_OVERFLOW_ERROR, errorCode.reset());
length = (int32_t)(target - result);
assertEquals("text2 number of bytes written", 3, length);
assertEquals("text2 next byte not clobbered", 5, result[3]);
assertEquals("text2 next byte not clobbered", (char)5, result[3]);

// Convert the rest and flush.
ucnv_convertEx(cnv2.getAlias(), cnv1.getAlias(),
Expand Down
4 changes: 3 additions & 1 deletion icu4c/source/test/intltest/itutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,12 +808,14 @@ void LocalPointerTest::TestLocalXyzPointerNull() {

}

extern "C" typedef void(*fun_ptr)(UConstrainedFieldPosition*);

void LocalPointerTest::TestLocalXyzStdUniquePtr() {
IcuTestErrorCode status(*this, "TestLocalXyzStdUniquePtr");
#if !UCONFIG_NO_FORMATTING
auto* ptr = ucfpos_open(status);
// Implicit conversion operator
std::unique_ptr<UConstrainedFieldPosition, void(*)(UConstrainedFieldPosition*)> a =
std::unique_ptr<UConstrainedFieldPosition, fun_ptr> a =
LocalUConstrainedFieldPositionPointer(ptr);
// Explicit move constructor
LocalUConstrainedFieldPositionPointer a2(std::move(a));
Expand Down
6 changes: 1 addition & 5 deletions icu4c/source/test/intltest/numbertest_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3763,10 +3763,6 @@ void NumberFormatterApiTest::roundingOther() {
DBL_MIN,
u"2.225074E-308");

#ifndef DBL_TRUE_MIN
#define DBL_TRUE_MIN 4.9E-324
#endif

// Note: this behavior is intentionally different from Java; see
// https://github.com/google/double-conversion/issues/126
assertFormatSingle(
Expand All @@ -3775,7 +3771,7 @@ void NumberFormatterApiTest::roundingOther() {
u"E0",
NumberFormatter::with().notation(Notation::scientific()),
Locale::getEnglish(),
DBL_TRUE_MIN,
4.9E-324,
u"5E-324");
}

Expand Down
12 changes: 6 additions & 6 deletions icu4c/source/test/intltest/rbbitst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3379,20 +3379,20 @@ int32_t RBBILineMonkey::next(int32_t startPos) {
}

if (fAP->contains(prevChar) &&
(fAK->contains(thisChar) || thisChar == U'◌' || fAS->contains(thisChar))) {
(fAK->contains(thisChar) || thisChar == (UChar32)u'◌' || fAS->contains(thisChar))) {
setAppliedRule(pos, "LB 28a.1 AP x (AK | ◌ | AS)");
continue;
}

if ((fAK->contains(prevChar) || prevChar == U'◌' || fAS->contains(prevChar)) &&
if ((fAK->contains(prevChar) || prevChar == (UChar32)u'◌' || fAS->contains(prevChar)) &&
(fVF->contains(thisChar) || fVI->contains(thisChar))) {
setAppliedRule(pos, "LB 28a.2 (AK | ◌ | AS) x (VF | VI)");
continue;
}

if ((fAK->contains(prevCharX2) || prevCharX2 == U'◌' || fAS->contains(prevCharX2)) &&
if ((fAK->contains(prevCharX2) || prevCharX2 == (UChar32)u'◌' || fAS->contains(prevCharX2)) &&
fVI->contains(prevChar) &&
(fAK->contains(thisChar) || thisChar == U'◌')) {
(fAK->contains(thisChar) || thisChar == (UChar32)u'◌')) {
setAppliedRule(pos, "LB 28a.3 (AK | ◌ | AS) VI x (AK | ◌)");
continue;
}
Expand All @@ -3401,8 +3401,8 @@ int32_t RBBILineMonkey::next(int32_t startPos) {
// note: UnicodeString::char32At(length) returns ffff, not distinguishable
// from a legit ffff noncharacter. So test length separately.
UChar32 nextChar = fText->char32At(nextPos);
if ((fAK->contains(prevChar) || prevChar == U'◌' || fAS->contains(prevChar)) &&
(fAK->contains(thisChar) || thisChar == U'◌' || fAS->contains(thisChar)) &&
if ((fAK->contains(prevChar) || prevChar == (UChar32)u'◌' || fAS->contains(prevChar)) &&
(fAK->contains(thisChar) || thisChar == (UChar32)u'◌' || fAS->contains(thisChar)) &&
fVF->contains(nextChar)) {
setAppliedRule(pos, "LB 28a.4 (AK | ◌ | AS) x (AK | ◌ | AS) VF");
continue;
Expand Down
12 changes: 6 additions & 6 deletions icu4c/source/test/intltest/strtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,9 @@ StringTest::TestStringPieceU8() {

StringPiece abc3(u8"abcdef", 3);
assertEquals("abc3.length", 3, abc3.length());
assertEquals("abc3[0]", 0x61, abc3.data()[0]);
assertEquals("abc3[1]", 0x62, abc3.data()[1]);
assertEquals("abc3[2]", 0x63, abc3.data()[2]);
assertEquals("abc3[0]", (char)0x61, abc3.data()[0]);
assertEquals("abc3[1]", (char)0x62, abc3.data()[1]);
assertEquals("abc3[2]", (char)0x63, abc3.data()[2]);

StringPiece uvw("q");
uvw.set(u8"uvw");
Expand All @@ -550,9 +550,9 @@ StringTest::TestStringPieceU8() {
StringPiece xyz("r");
xyz.set(u8"xyzXYZ", 3);
assertEquals("xyz.length", 3, xyz.length());
assertEquals("xyz[0]", 0x78, xyz.data()[0]);
assertEquals("xyz[1]", 0x79, xyz.data()[1]);
assertEquals("xyz[2]", 0x7a, xyz.data()[2]);
assertEquals("xyz[0]", (char)0x78, xyz.data()[0]);
assertEquals("xyz[1]", (char)0x79, xyz.data()[1]);
assertEquals("xyz[2]", (char)0x7a, xyz.data()[2]);

StringPiece null(nullptr);
assertTrue("null is empty", null.empty());
Expand Down
2 changes: 1 addition & 1 deletion icu4c/source/test/intltest/uobjtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ void UObjectTest::testUMemory() {
UnicodeString *p;
enum { len=20 };

p=new(bytes) UnicodeString(len, (UChar32)U'€', len);
p=new(bytes) UnicodeString(len, (UChar32)u'€', len);
if((void *)p!=(void *)bytes) {
errln("placement new did not place the object at the expected address");
}
Expand Down
12 changes: 7 additions & 5 deletions icu4c/source/test/intltest/usettest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4177,6 +4177,8 @@ void UnicodeSetTest::TestSkipToStrings() {
assertFalse("no next", iter.next());
}

#include <assert.h>

void UnicodeSetTest::TestPatternCodePointComplement() {
IcuTestErrorCode errorCode(*this, "TestPatternCodePointComplement");
// ICU-21524 changes pattern ^ and equivalent functions to perform a "code point complement".
Expand All @@ -4195,14 +4197,14 @@ void UnicodeSetTest::TestPatternCodePointComplement() {
}
assertTrue("[:^Basic_Emoji:] --> lots of elements", notBasic.size() > 1000);
assertFalse("[:^Basic_Emoji:] --> no strings", notBasic.hasStrings());
assertFalse("[:^Basic_Emoji:] --> no bicycle", notBasic.contains(U'🚲'));
assertFalse("[:^Basic_Emoji:] --> no bicycle", notBasic.contains(U'\U0001F6B2'));
}

{
UnicodeSet notBasic(u"[:Basic_Emoji=No:]", errorCode);
assertTrue("[:Basic_Emoji=No:] --> lots of elements", notBasic.size() > 1000);
assertFalse("[:Basic_Emoji=No:] --> no strings", notBasic.hasStrings());
assertFalse("[:Basic_Emoji=No:] --> no bicycle", notBasic.contains(U'🚲'));
assertFalse("[:Basic_Emoji=No:] --> no bicycle", notBasic.contains(U'\U0001F6B2'));
}

{
Expand All @@ -4213,7 +4215,7 @@ void UnicodeSetTest::TestPatternCodePointComplement() {
assertFalse("[].applyIntPropertyValue(Basic_Emoji, 0) --> no strings",
notBasic.hasStrings());
assertFalse("[].applyIntPropertyValue(Basic_Emoji, 0) --> no bicycle",
notBasic.contains(U'🚲'));
notBasic.contains(U'\U0001F6B2'));
}

{
Expand All @@ -4224,7 +4226,7 @@ void UnicodeSetTest::TestPatternCodePointComplement() {
assertFalse("[].applyPropertyAlias(Basic_Emoji, No) --> no strings",
notBasic.hasStrings());
assertFalse("[].applyPropertyAlias(Basic_Emoji, No) --> no bicycle",
notBasic.contains(U'🚲'));
notBasic.contains(U'\U0001F6B2'));
}

// When there are strings, we must not use the complement for a more compact toPattern().
Expand Down Expand Up @@ -4253,6 +4255,6 @@ void UnicodeSetTest::TestPatternCodePointComplement() {
assertTrue("[:Basic_Emoji:].complement() --> has strings", notBasic.hasStrings());
assertTrue("[:Basic_Emoji:].complement().contains(chipmunk+emoji)",
notBasic.contains(u"🐿\uFE0F"));
assertFalse("[:Basic_Emoji:].complement() --> no bicycle", notBasic.contains(U'🚲'));
assertFalse("[:Basic_Emoji:].complement() --> no bicycle", notBasic.contains(U'\U0001F6B2'));
}
}
4 changes: 2 additions & 2 deletions icu4c/source/tools/genrb/reslist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1346,11 +1346,11 @@ compareKeyOldpos(const void * /*context*/, const void *l, const void *r) {
return compareInt32(((const KeyMapEntry *)l)->oldpos, ((const KeyMapEntry *)r)->oldpos);
}

void SResource::collectKeys(std::function<void(int32_t)> collector) const {
U_CFUNC void SResource::collectKeys(std::function<void(int32_t)> collector) const {
collector(fKey);
}

void ContainerResource::collectKeys(std::function<void(int32_t)> collector) const {
U_CFUNC void ContainerResource::collectKeys(std::function<void(int32_t)> collector) const {
collector(fKey);
for (SResource* curr = fFirst; curr != nullptr; curr = curr->fNext) {
curr->collectKeys(collector);
Expand Down
Loading