From 19a6f99ca8fada3ccd32e164e0c00348c4ab38b6 Mon Sep 17 00:00:00 2001 From: Rmys Date: Sun, 23 Feb 2025 12:56:51 +0300 Subject: [PATCH] icu4c ver. bump --- programming/misc/icu4c/actions.py | 15 + ...USet-C-iterator-return-std-u16string.patch | 223 ++++ ...NAMESPACE_OR_INTERNAL-header-only-lo.patch | 336 +++++ ...st.h-IcuTestErrorCode-usable-without.patch | 1076 +++++++++++++++++ ...54-header-only-test-USet-C-iterators.patch | 546 +++++++++ ...lly-revert-PR-3295-U_ICU_NAMESPACE_O.patch | 153 +++ ...54-USetHeaderOnlyTest-use-unique_ptr.patch | 119 ++ ...te-copy-assign-from-IcuTestErrorCode.patch | 56 + ...ound-Replace-std-u16string-member-wi.patch | 111 ++ ...-to-using-std-u16string-instead-of-U.patch | 104 ++ .../misc/icu4c/files/gennorm2-man.patch | 128 ++ .../misc/icu4c/files/icuinfo-man.patch | 145 +++ programming/misc/icu4c/pspec.xml | 22 +- 13 files changed, 3032 insertions(+), 2 deletions(-) create mode 100644 programming/misc/icu4c/files/fedora/0001-ICU-22954-USet-C-iterator-return-std-u16string.patch create mode 100644 programming/misc/icu4c/files/fedora/0002-ICU-22954-U_ICU_NAMESPACE_OR_INTERNAL-header-only-lo.patch create mode 100644 programming/misc/icu4c/files/fedora/0003-ICU-22954-intltest.h-IcuTestErrorCode-usable-without.patch create mode 100644 programming/misc/icu4c/files/fedora/0004-ICU-22954-header-only-test-USet-C-iterators.patch create mode 100644 programming/misc/icu4c/files/fedora/0005-ICU-22954-Partially-revert-PR-3295-U_ICU_NAMESPACE_O.patch create mode 100644 programming/misc/icu4c/files/fedora/0006-ICU-22954-USetHeaderOnlyTest-use-unique_ptr.patch create mode 100644 programming/misc/icu4c/files/fedora/0007-ICU-22954-Delete-copy-assign-from-IcuTestErrorCode.patch create mode 100644 programming/misc/icu4c/files/fedora/0008-ICU-22954-Workaround-Replace-std-u16string-member-wi.patch create mode 100644 programming/misc/icu4c/files/fedora/0009-ICU-22954-Revert-to-using-std-u16string-instead-of-U.patch create mode 100644 programming/misc/icu4c/files/gennorm2-man.patch create mode 100644 programming/misc/icu4c/files/icuinfo-man.patch diff --git a/programming/misc/icu4c/actions.py b/programming/misc/icu4c/actions.py index 797e193b08..335d2df981 100644 --- a/programming/misc/icu4c/actions.py +++ b/programming/misc/icu4c/actions.py @@ -39,6 +39,21 @@ def install(): if get.buildTYPE() == "_emul32": pisitools.domove("/_emul32/bin/icu-config", "/usr/bin", "icu-config-32") pisitools.removeDir("/_emul32") + + # pisitools.dosym("/usr/lib/libicudata.so.76.1", "/usr/lib/libicudata.so.73") + # pisitools.dosym("/usr/lib/libicui18n.so.76.1", "/usr/lib/libicui18n.so.73") + # pisitools.dosym("/usr/lib/libicuio.so.76.1", "/usr/lib/libicuio.so.73") + # pisitools.dosym("/usr/lib/libicutest.so.76.1", "/usr/lib/libicutest.so.73") + # pisitools.dosym("/usr/lib/libicutu.so.76.1", "/usr/lib/libicutu.so.73") + # pisitools.dosym("/usr/lib/libicuuc.so.76.1", "/usr/lib/libicuuc.so.73") + + # pisitools.dosym("/usr/lib32/libicudata.so.76.1", "/usr/lib32/libicudata.so.73") + # pisitools.dosym("/usr/lib32/libicui18n.so.76.1", "/usr/lib32/libicui18n.so.73") + # pisitools.dosym("/usr/lib32/libicuio.so.76.1", "/usr/lib32/libicuio.so.73") + # pisitools.dosym("/usr/lib32/libicutest.so.76.1", "/usr/lib32/libicutest.so.73") + # pisitools.dosym("/usr/lib32/libicutu.so.76.1", "/usr/lib32/libicutu.so.73") + # pisitools.dosym("/usr/lib32/libicuuc.so.76.1", "/usr/lib32/libicuuc.so.73") + for f in shelltools.ls("%s/usr/lib32/pkgconfig" % get.installDIR()): pisitools.dosed("%s/usr/lib32/pkgconfig/%s" % (get.installDIR(), f), "_emul32", "usr") pisitools.dosed("%s/usr/lib32/icu/%s/Makefile.inc" % ( get.installDIR(), get.srcVERSION()), "_emul32", "usr") diff --git a/programming/misc/icu4c/files/fedora/0001-ICU-22954-USet-C-iterator-return-std-u16string.patch b/programming/misc/icu4c/files/fedora/0001-ICU-22954-USet-C-iterator-return-std-u16string.patch new file mode 100644 index 0000000000..8bce76a651 --- /dev/null +++ b/programming/misc/icu4c/files/fedora/0001-ICU-22954-USet-C-iterator-return-std-u16string.patch @@ -0,0 +1,223 @@ +From d03826cdeec4ad3fd0667f00a551e6a46272897b Mon Sep 17 00:00:00 2001 +From: Markus Scherer +Date: Mon, 9 Dec 2024 16:06:39 -0800 +Subject: [PATCH] ICU-22954 USet C++ iterator return std::u16string + +--- + icu4c/source/common/unicode/uniset.h | 11 ++++--- + icu4c/source/common/unicode/uset.h | 44 ++++++++++++++----------- + icu4c/source/test/intltest/usettest.cpp | 6 ++-- + 3 files changed, 36 insertions(+), 25 deletions(-) + +diff --git a/icu4c/source/common/unicode/uniset.h b/icu4c/source/common/unicode/uniset.h +index d070fd631a2..5b32f3ca5d4 100644 +--- icu4c/source/common/unicode/uniset.h ++++ icu4c/source/common/unicode/uniset.h +@@ -1173,10 +1173,12 @@ class U_COMMON_API UnicodeSet final : public UnicodeFilter { + inline U_HEADER_NESTED_NAMESPACE::USetStrings strings() const { + return U_HEADER_NESTED_NAMESPACE::USetStrings(toUSet()); + } ++#endif // U_HIDE_DRAFT_API + ++#ifndef U_HIDE_DRAFT_API + /** + * Returns a C++ iterator for iterating over all of the elements of this set. +- * Convenient all-in one iteration, but creates a UnicodeString for each ++ * Convenient all-in one iteration, but creates a std::u16string for each + * code point or string. + * (Similar to how Java UnicodeSet *is an* Iterable<String>.) + * +@@ -1185,13 +1187,14 @@ class U_COMMON_API UnicodeSet final : public UnicodeFilter { + * \code + * UnicodeSet set(u"[abcçカ🚴{}{abc}{de}]", errorCode); + * for (auto el : set) { ++ * UnicodeString us(el); + * std::string u8; +- * printf("set.string length %ld \"%s\"\n", (long)el.length(), el.toUTF8String(u8).c_str()); ++ * printf("set.string length %ld \"%s\"\n", (long)us.length(), us.toUTF8String(u8).c_str()); + * } + * \endcode + * + * @return an all-elements iterator. +- * @draft ICU 76 ++ * @draft ICU 77 + * @see end + * @see codePoints + * @see ranges +@@ -1203,7 +1206,7 @@ class U_COMMON_API UnicodeSet final : public UnicodeFilter { + + /** + * @return an exclusive-end sentinel for iterating over all of the elements of this set. +- * @draft ICU 76 ++ * @draft ICU 77 + * @see begin + * @see codePoints + * @see ranges +diff --git a/icu4c/source/common/unicode/uset.h b/icu4c/source/common/unicode/uset.h +index c8f9b5592df..914c4c4e5de 100644 +--- icu4c/source/common/unicode/uset.h ++++ icu4c/source/common/unicode/uset.h +@@ -33,10 +33,11 @@ + #include "unicode/uchar.h" + + #if U_SHOW_CPLUSPLUS_API ++#include + #include + #include "unicode/char16ptr.h" + #include "unicode/localpointer.h" +-#include "unicode/unistr.h" ++#include "unicode/utf16.h" + #endif // U_SHOW_CPLUSPLUS_API + + #ifndef USET_DEFINED +@@ -1737,17 +1738,19 @@ class USetStrings { + const USet *uset; + int32_t count; + }; ++#endif // U_HIDE_DRAFT_API + ++#ifndef U_HIDE_DRAFT_API + /** + * Iterator returned by USetElements. +- * @draft ICU 76 ++ * @draft ICU 77 + */ + class USetElementIterator { + public: +- /** @draft ICU 76 */ ++ /** @draft ICU 77 */ + USetElementIterator(const USetElementIterator &other) = default; + +- /** @draft ICU 76 */ ++ /** @draft ICU 77 */ + bool operator==(const USetElementIterator &other) const { + // No need to compare rangeCount & end given private constructor + // and assuming we don't compare iterators across the set being modified. +@@ -1756,26 +1759,28 @@ class USetElementIterator { + return uset == other.uset && c == other.c && index == other.index; + } + +- /** @draft ICU 76 */ ++ /** @draft ICU 77 */ + bool operator!=(const USetElementIterator &other) const { return !operator==(other); } + +- /** @draft ICU 76 */ +- UnicodeString operator*() const { ++ /** @draft ICU 77 */ ++ std::u16string operator*() const { + if (c >= 0) { +- return UnicodeString(c); ++ return c <= 0xffff ? ++ std::u16string({static_cast(c)}) : ++ std::u16string({U16_LEAD(c), U16_TRAIL(c)}); + } else if (index < totalCount) { + int32_t length; + const UChar *uchars = uset_getString(uset, index - rangeCount, &length); + // assert uchars != nullptr; +- return UnicodeString(uchars, length); ++ return {ConstChar16Ptr(uchars), static_cast(length)}; + } else { +- return UnicodeString(); ++ return {}; + } + } + + /** + * Pre-increment. +- * @draft ICU 76 ++ * @draft ICU 77 + */ + USetElementIterator &operator++() { + if (c < end) { +@@ -1800,7 +1805,7 @@ class USetElementIterator { + + /** + * Post-increment. +- * @draft ICU 76 ++ * @draft ICU 77 + */ + USetElementIterator operator++(int) { + USetElementIterator result(*this); +@@ -1840,7 +1845,7 @@ class USetElementIterator { + + /** + * A C++ "range" for iterating over all of the elements of a USet. +- * Convenient all-in one iteration, but creates a UnicodeString for each ++ * Convenient all-in one iteration, but creates a std::u16string for each + * code point or string. + * + * Code points are returned first, then empty and multi-character strings. +@@ -1849,15 +1854,16 @@ class USetElementIterator { + * using U_HEADER_NESTED_NAMESPACE::USetElements; + * LocalUSetPointer uset(uset_openPattern(u"[abcçカ🚴{}{abc}{de}]", -1, &errorCode)); + * for (auto el : USetElements(uset.getAlias())) { ++ * UnicodeString us(el); + * std::string u8; +- * printf("uset.string length %ld \"%s\"\n", (long)el.length(), el.toUTF8String(u8).c_str()); ++ * printf("uset.string length %ld \"%s\"\n", (long)us.length(), us.toUTF8String(u8).c_str()); + * } + * \endcode + * + * C++ UnicodeSet has member functions for iteration, including begin() and end(). + * + * @return an all-elements iterator. +- * @draft ICU 76 ++ * @draft ICU 77 + * @see USetCodePoints + * @see USetRanges + * @see USetStrings +@@ -1866,21 +1872,21 @@ class USetElements { + public: + /** + * Constructs a C++ "range" object over all of the elements of the USet. +- * @draft ICU 76 ++ * @draft ICU 77 + */ + USetElements(const USet *uset) + : uset(uset), rangeCount(uset_getRangeCount(uset)), + stringCount(uset_getStringCount(uset)) {} + +- /** @draft ICU 76 */ ++ /** @draft ICU 77 */ + USetElements(const USetElements &other) = default; + +- /** @draft ICU 76 */ ++ /** @draft ICU 77 */ + USetElementIterator begin() const { + return USetElementIterator(uset, 0, rangeCount, rangeCount + stringCount); + } + +- /** @draft ICU 76 */ ++ /** @draft ICU 77 */ + USetElementIterator end() const { + return USetElementIterator(uset, rangeCount + stringCount, rangeCount, rangeCount + stringCount); + } +diff --git a/icu4c/source/test/intltest/usettest.cpp b/icu4c/source/test/intltest/usettest.cpp +index a53e813ad2f..477639e8659 100644 +--- icu4c/source/test/intltest/usettest.cpp ++++ icu4c/source/test/intltest/usettest.cpp +@@ -4448,8 +4448,9 @@ void UnicodeSetTest::TestElementIterator() { + UnicodeSet set(u"[abcçカ🚴{}{abc}{de}]", errorCode); + UnicodeString result; + for (auto el : set) { ++ // UnicodeString us(el); + // std::string u8; +- // printf("set.string length %ld \"%s\"\n", (long)el.length(), el.toUTF8String(u8).c_str()); ++ // printf("set.string length %ld \"%s\"\n", (long)us.length(), us.toUTF8String(u8).c_str()); + result.append(u" \"").append(el).append(u'"'); + } + assertEquals(WHERE, uR"( "a" "b" "c" "ç" "カ" "🚴" "" "abc" "de")", result); +@@ -4463,8 +4464,9 @@ void UnicodeSetTest::TestUSetElementIterator() { + LocalUSetPointer uset(uset_openPattern(u"[abcçカ🚴{}{abc}{de}]", -1, errorCode)); + UnicodeString result; + for (auto el : USetElements(uset.getAlias())) { ++ // UnicodeString us(el); + // std::string u8; +- // printf("uset.string length %ld \"%s\"\n", (long)el.length(), el.toUTF8String(u8).c_str()); ++ // printf("uset.string length %ld \"%s\"\n", (long)us.length(), us.toUTF8String(u8).c_str()); + result.append(u" \"").append(el).append(u'"'); + } + assertEquals(WHERE, uR"( "a" "b" "c" "ç" "カ" "🚴" "" "abc" "de")", result); +-- +2.47.1 + diff --git a/programming/misc/icu4c/files/fedora/0002-ICU-22954-U_ICU_NAMESPACE_OR_INTERNAL-header-only-lo.patch b/programming/misc/icu4c/files/fedora/0002-ICU-22954-U_ICU_NAMESPACE_OR_INTERNAL-header-only-lo.patch new file mode 100644 index 0000000000..aba47e0a48 --- /dev/null +++ b/programming/misc/icu4c/files/fedora/0002-ICU-22954-U_ICU_NAMESPACE_OR_INTERNAL-header-only-lo.patch @@ -0,0 +1,336 @@ +From 8655718531e478428151162313f67432ed28cd9d Mon Sep 17 00:00:00 2001 +From: Markus Scherer +Date: Mon, 9 Dec 2024 18:42:23 -0800 +Subject: [PATCH] ICU-22954 U_ICU_NAMESPACE_OR_INTERNAL, header-only + localpointer header-only parts of char16ptr.h + +--- + icu4c/source/common/unicode/char16ptr.h | 51 ++++++++++++++++++++-- + icu4c/source/common/unicode/localpointer.h | 10 ++--- + icu4c/source/common/unicode/normlzr.h | 4 +- + icu4c/source/common/unicode/unistr.h | 8 ++-- + icu4c/source/common/unicode/uset.h | 14 +++--- + icu4c/source/common/unicode/uversion.h | 19 +++++++- + icu4c/source/i18n/unicode/ucol.h | 4 +- + 7 files changed, 84 insertions(+), 26 deletions(-) + +diff --git a/icu4c/source/common/unicode/char16ptr.h b/icu4c/source/common/unicode/char16ptr.h +index daf35cd43ba..a2722d9f463 100644 +--- icu4c/source/common/unicode/char16ptr.h ++++ icu4c/source/common/unicode/char16ptr.h +@@ -9,10 +9,13 @@ + + #include "unicode/utypes.h" + +-#if U_SHOW_CPLUSPLUS_API ++#if U_SHOW_CPLUSPLUS_API || U_SHOW_CPLUSPLUS_HEADER_API + + #include + #include ++#include ++ ++#endif + + /** + * \file +@@ -21,8 +24,6 @@ + * Also conversion functions from char16_t * to UChar * and OldUChar *. + */ + +-U_NAMESPACE_BEGIN +- + /** + * \def U_ALIASING_BARRIER + * Barrier for pointer anti-aliasing optimizations even across function boundaries. +@@ -36,6 +37,11 @@ U_NAMESPACE_BEGIN + # define U_ALIASING_BARRIER(ptr) + #endif + ++// ICU DLL-exported ++#if U_SHOW_CPLUSPLUS_API ++ ++U_NAMESPACE_BEGIN ++ + /** + * char16_t * wrapper with implicit conversion from distinct but bit-compatible pointer types. + * @stable ICU 59 +@@ -251,6 +257,34 @@ const char16_t *ConstChar16Ptr::get() const { return u_.cp; } + #endif + /// \endcond + ++U_NAMESPACE_END ++ ++#endif // U_SHOW_CPLUSPLUS_API ++ ++// Usable in header-only definitions ++#if U_SHOW_CPLUSPLUS_API || U_SHOW_CPLUSPLUS_HEADER_API ++ ++namespace U_ICU_NAMESPACE_OR_INTERNAL { ++ ++#ifndef U_FORCE_HIDE_INTERNAL_API ++/** @internal */ ++template>> ++inline const char16_t *uprv_char16PtrFromUChar(const T *p) { ++ if constexpr (std::is_same_v) { ++ return p; ++ } else { ++#if U_SHOW_CPLUSPLUS_API ++ return ConstChar16Ptr(p).get(); ++#else ++#ifdef U_ALIASING_BARRIER ++ U_ALIASING_BARRIER(p); ++#endif ++ return reinterpret_cast(p); ++#endif ++ } ++} ++#endif ++ + /** + * Converts from const char16_t * to const UChar *. + * Includes an aliasing barrier if available. +@@ -307,6 +341,15 @@ inline OldUChar *toOldUCharPtr(char16_t *p) { + return reinterpret_cast(p); + } + ++} // U_ICU_NAMESPACE_OR_INTERNAL ++ ++#endif // U_SHOW_CPLUSPLUS_API || U_SHOW_CPLUSPLUS_HEADER_API ++ ++// ICU DLL-exported ++#if U_SHOW_CPLUSPLUS_API ++ ++U_NAMESPACE_BEGIN ++ + #ifndef U_FORCE_HIDE_INTERNAL_API + /** + * Is T convertible to a std::u16string_view or some other 16-bit string view? +@@ -379,6 +422,6 @@ inline std::u16string_view toU16StringViewNullable(const T& text) { + + U_NAMESPACE_END + +-#endif /* U_SHOW_CPLUSPLUS_API */ ++#endif // U_SHOW_CPLUSPLUS_API + + #endif // __CHAR16PTR_H__ +diff --git a/icu4c/source/common/unicode/localpointer.h b/icu4c/source/common/unicode/localpointer.h +index 9c891bf3088..487ddb48b78 100644 +--- icu4c/source/common/unicode/localpointer.h ++++ icu4c/source/common/unicode/localpointer.h +@@ -21,7 +21,7 @@ + + /** + * \file +- * \brief C++ API: "Smart pointers" for use with and in ICU4C C++ code. ++ * \brief C++ header-only API: "Smart pointers" for use with and in ICU4C C++ code. + * + * These classes are inspired by + * - std::auto_ptr +@@ -40,11 +40,11 @@ + + #include "unicode/utypes.h" + +-#if U_SHOW_CPLUSPLUS_API ++#if U_SHOW_CPLUSPLUS_API || U_SHOW_CPLUSPLUS_HEADER_API + + #include + +-U_NAMESPACE_BEGIN ++namespace U_ICU_NAMESPACE_OR_INTERNAL { + + /** + * "Smart pointer" base class; do not use directly: use LocalPointer etc. +@@ -603,7 +603,7 @@ class LocalOpenPointer : public LocalPointerBase { + } // namespace internal + #endif + +-U_NAMESPACE_END ++} // U_ICU_NAMESPACE_OR_INTERNAL + +-#endif /* U_SHOW_CPLUSPLUS_API */ ++#endif // U_SHOW_CPLUSPLUS_API || U_SHOW_CPLUSPLUS_HEADER_API + #endif /* __LOCALPOINTER_H__ */ +diff --git a/icu4c/source/common/unicode/normlzr.h b/icu4c/source/common/unicode/normlzr.h +index 0309bce5382..40848bf00ca 100644 +--- icu4c/source/common/unicode/normlzr.h ++++ icu4c/source/common/unicode/normlzr.h +@@ -801,8 +801,8 @@ Normalizer::compare(const UnicodeString &s1, const UnicodeString &s2, + uint32_t options, + UErrorCode &errorCode) { + // all argument checking is done in unorm_compare +- return unorm_compare(toUCharPtr(s1.getBuffer()), s1.length(), +- toUCharPtr(s2.getBuffer()), s2.length(), ++ return unorm_compare(U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(s1.getBuffer()), s1.length(), ++ U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(s2.getBuffer()), s2.length(), + options, + &errorCode); + } +diff --git a/icu4c/source/common/unicode/unistr.h b/icu4c/source/common/unicode/unistr.h +index 39d789fd6ef..a1901c91504 100644 +--- icu4c/source/common/unicode/unistr.h ++++ icu4c/source/common/unicode/unistr.h +@@ -4676,7 +4676,7 @@ UnicodeString::startsWith(const UnicodeString& srcText, + inline UBool + UnicodeString::startsWith(ConstChar16Ptr srcChars, int32_t srcLength) const { + if(srcLength < 0) { +- srcLength = u_strlen(toUCharPtr(srcChars)); ++ srcLength = u_strlen(U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(srcChars)); + } + return doEqualsSubstring(0, srcLength, srcChars, 0, srcLength); + } +@@ -4684,7 +4684,7 @@ UnicodeString::startsWith(ConstChar16Ptr srcChars, int32_t srcLength) const { + inline UBool + UnicodeString::startsWith(const char16_t *srcChars, int32_t srcStart, int32_t srcLength) const { + if(srcLength < 0) { +- srcLength = u_strlen(toUCharPtr(srcChars)); ++ srcLength = u_strlen(U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(srcChars)); + } + return doEqualsSubstring(0, srcLength, srcChars, srcStart, srcLength); + } +@@ -4707,7 +4707,7 @@ inline UBool + UnicodeString::endsWith(ConstChar16Ptr srcChars, + int32_t srcLength) const { + if(srcLength < 0) { +- srcLength = u_strlen(toUCharPtr(srcChars)); ++ srcLength = u_strlen(U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(srcChars)); + } + return doEqualsSubstring(length() - srcLength, srcLength, srcChars, 0, srcLength); + } +@@ -4717,7 +4717,7 @@ UnicodeString::endsWith(const char16_t *srcChars, + int32_t srcStart, + int32_t srcLength) const { + if(srcLength < 0) { +- srcLength = u_strlen(toUCharPtr(srcChars + srcStart)); ++ srcLength = u_strlen(U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(srcChars + srcStart)); + } + return doEqualsSubstring(length() - srcLength, srcLength, + srcChars, srcStart, srcLength); +diff --git a/icu4c/source/common/unicode/uset.h b/icu4c/source/common/unicode/uset.h +index 914c4c4e5de..345d6244544 100644 +--- icu4c/source/common/unicode/uset.h ++++ icu4c/source/common/unicode/uset.h +@@ -32,13 +32,13 @@ + #include "unicode/utypes.h" + #include "unicode/uchar.h" + +-#if U_SHOW_CPLUSPLUS_API ++#if U_SHOW_CPLUSPLUS_API || U_SHOW_CPLUSPLUS_HEADER_API + #include + #include + #include "unicode/char16ptr.h" + #include "unicode/localpointer.h" + #include "unicode/utf16.h" +-#endif // U_SHOW_CPLUSPLUS_API ++#endif + + #ifndef USET_DEFINED + +@@ -346,9 +346,9 @@ uset_openPatternOptions(const UChar* pattern, int32_t patternLength, + U_CAPI void U_EXPORT2 + uset_close(USet* set); + +-#if U_SHOW_CPLUSPLUS_API ++#if U_SHOW_CPLUSPLUS_API || U_SHOW_CPLUSPLUS_HEADER_API + +-U_NAMESPACE_BEGIN ++namespace U_ICU_NAMESPACE_OR_INTERNAL { + + /** + * \class LocalUSetPointer +@@ -361,7 +361,7 @@ U_NAMESPACE_BEGIN + */ + U_DEFINE_LOCAL_OPEN_POINTER(LocalUSetPointer, USet, uset_close); + +-U_NAMESPACE_END ++} // U_ICU_NAMESPACE_OR_INTERNAL + + #endif + +@@ -1658,7 +1658,7 @@ class USetStringIterator { + int32_t length; + const UChar *uchars = uset_getString(uset, index, &length); + // assert uchars != nullptr; +- return {ConstChar16Ptr(uchars), static_cast(length)}; ++ return {uprv_char16PtrFromUChar(uchars), static_cast(length)}; + } + return {}; + } +@@ -1772,7 +1772,7 @@ class USetElementIterator { + int32_t length; + const UChar *uchars = uset_getString(uset, index - rangeCount, &length); + // assert uchars != nullptr; +- return {ConstChar16Ptr(uchars), static_cast(length)}; ++ return {uprv_char16PtrFromUChar(uchars), static_cast(length)}; + } else { + return {}; + } +diff --git a/icu4c/source/common/unicode/uversion.h b/icu4c/source/common/unicode/uversion.h +index 25d73a3aeb5..a29bf21efda 100644 +--- icu4c/source/common/unicode/uversion.h ++++ icu4c/source/common/unicode/uversion.h +@@ -125,7 +125,7 @@ typedef uint8_t UVersionInfo[U_MAX_VERSION_LENGTH]; + U_NAMESPACE_USE + # endif + +-#ifndef U_HIDE_DRAFT_API ++#ifndef U_FORCE_HIDE_DRAFT_API + /** + * \def U_HEADER_NESTED_NAMESPACE + * Nested namespace used inside U_ICU_NAMESPACE for header-only APIs. +@@ -150,22 +150,37 @@ typedef uint8_t UVersionInfo[U_MAX_VERSION_LENGTH]; + * @draft ICU 76 + */ + ++/** ++ * \def U_ICU_NAMESPACE_OR_INTERNAL ++ * Namespace used for header-only APIs that used to be regular C++ APIs. ++ * Different when used inside ICU to prevent public use of internal instantiations. ++ * Similar to U_HEADER_ONLY_NAMESPACE, but the public definition is the same as U_ICU_NAMESPACE. ++ * "U_ICU_NAMESPACE" or "U_ICU_NAMESPACE::internal". ++ * ++ * @draft ICU 77 ++ */ ++ + // The first test is the same as for defining U_EXPORT for Windows. + #if defined(_MSC_VER) || (UPRV_HAS_DECLSPEC_ATTRIBUTE(__dllexport__) && \ + UPRV_HAS_DECLSPEC_ATTRIBUTE(__dllimport__)) + # define U_HEADER_NESTED_NAMESPACE header ++# define U_ICU_NAMESPACE_OR_INTERNAL U_ICU_NAMESPACE + #elif defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || \ + defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION) || \ + defined(U_LAYOUTEX_IMPLEMENTATION) || defined(U_TOOLUTIL_IMPLEMENTATION) + # define U_HEADER_NESTED_NAMESPACE internal ++# define U_ICU_NAMESPACE_OR_INTERNAL U_ICU_NAMESPACE::internal ++ namespace U_ICU_NAMESPACE_OR_INTERNAL {} ++ using namespace U_ICU_NAMESPACE_OR_INTERNAL; + #else + # define U_HEADER_NESTED_NAMESPACE header ++# define U_ICU_NAMESPACE_OR_INTERNAL U_ICU_NAMESPACE + #endif + + #define U_HEADER_ONLY_NAMESPACE U_ICU_NAMESPACE::U_HEADER_NESTED_NAMESPACE + + namespace U_HEADER_ONLY_NAMESPACE {} +-#endif // U_HIDE_DRAFT_API ++#endif // U_FORCE_HIDE_DRAFT_API + + #endif /* __cplusplus */ + +diff --git a/icu4c/source/i18n/unicode/ucol.h b/icu4c/source/i18n/unicode/ucol.h +index ae4f29c3c6c..8b6dfeaa0a8 100644 +--- icu4c/source/i18n/unicode/ucol.h ++++ icu4c/source/i18n/unicode/ucol.h +@@ -1572,8 +1572,8 @@ class Predicate { + return compare( + ucol_strcoll( + collator, +- toUCharPtr(lhs.getBuffer()), lhs.length(), +- toUCharPtr(rhs.getBuffer()), rhs.length()), ++ U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(lhs.getBuffer()), lhs.length(), ++ U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(rhs.getBuffer()), rhs.length()), + result); + } + +-- +2.47.1 + diff --git a/programming/misc/icu4c/files/fedora/0003-ICU-22954-intltest.h-IcuTestErrorCode-usable-without.patch b/programming/misc/icu4c/files/fedora/0003-ICU-22954-intltest.h-IcuTestErrorCode-usable-without.patch new file mode 100644 index 0000000000..7b0db24a23 --- /dev/null +++ b/programming/misc/icu4c/files/fedora/0003-ICU-22954-intltest.h-IcuTestErrorCode-usable-without.patch @@ -0,0 +1,1076 @@ +From 320220ef694123393a5c5d6eb6a1c7536fc57aba Mon Sep 17 00:00:00 2001 +From: Markus Scherer +Date: Wed, 11 Dec 2024 15:34:40 -0800 +Subject: [PATCH] ICU-22954 intltest.h & IcuTestErrorCode usable without + U_SHOW_CPLUSPLUS_API + +--- + icu4c/source/test/intltest/intltest.cpp | 152 +++++++++++------- + icu4c/source/test/intltest/intltest.h | 127 +++++++++------ + icu4c/source/test/intltest/itutil.cpp | 8 +- + .../test/intltest/localematchertest.cpp | 4 +- + icu4c/source/test/intltest/numfmtst.cpp | 37 +++-- + icu4c/source/test/iotest/iotest.cpp | 21 +-- + icu4c/source/tools/ctestfw/tstdtmod.cpp | 25 ++- + icu4c/source/tools/ctestfw/unicode/testlog.h | 40 +++-- + 8 files changed, 264 insertions(+), 150 deletions(-) + +diff --git a/icu4c/source/test/intltest/intltest.cpp b/icu4c/source/test/intltest/intltest.cpp +index e46eaafca32..3806d0ff529 100644 +--- icu4c/source/test/intltest/intltest.cpp ++++ icu4c/source/test/intltest/intltest.cpp +@@ -20,6 +20,7 @@ + #include + #include + #include ++#include + + #include "unicode/ctest.h" // for str_timeDelta + #include "unicode/curramt.h" +@@ -501,13 +502,13 @@ IntlTest* IntlTest::gTest = nullptr; + + static int32_t execCount = 0; + +-void it_log( UnicodeString message ) ++void it_log(std::u16string_view message) + { + if (IntlTest::gTest) + IntlTest::gTest->log( message ); + } + +-void it_logln( UnicodeString message ) ++void it_logln(std::u16string_view message) + { + if (IntlTest::gTest) + IntlTest::gTest->logln( message ); +@@ -519,13 +520,13 @@ void it_logln() + IntlTest::gTest->logln(); + } + +-void it_info( UnicodeString message ) ++void it_info(std::u16string_view message) + { + if (IntlTest::gTest) + IntlTest::gTest->info( message ); + } + +-void it_infoln( UnicodeString message ) ++void it_infoln(std::u16string_view message) + { + if (IntlTest::gTest) + IntlTest::gTest->infoln( message ); +@@ -543,30 +544,47 @@ void it_err() + IntlTest::gTest->err(); + } + +-void it_err( UnicodeString message ) ++void it_err(std::u16string_view message) + { + if (IntlTest::gTest) + IntlTest::gTest->err( message ); + } + +-void it_errln( UnicodeString message ) ++void it_errln(std::u16string_view message) + { + if (IntlTest::gTest) + IntlTest::gTest->errln( message ); + } + +-void it_dataerr( UnicodeString message ) ++void it_dataerr(std::u16string_view message) + { + if (IntlTest::gTest) + IntlTest::gTest->dataerr( message ); + } + +-void it_dataerrln( UnicodeString message ) ++void it_dataerrln(std::u16string_view message) + { + if (IntlTest::gTest) + IntlTest::gTest->dataerrln( message ); + } + ++void it_logln(const char* message) { ++ it_logln(UnicodeString(message)); ++} ++ ++void it_err(const char* message) { ++ it_err(UnicodeString(message)); ++} ++ ++void it_errln(const char* message) { ++ it_errln(UnicodeString(message)); ++} ++ ++void it_dataerrln(const char* message) { ++ it_dataerrln(UnicodeString(message)); ++} ++ ++ + IntlTest::IntlTest() + { + caller = nullptr; +@@ -784,7 +802,7 @@ UBool IntlTest::runTestLoop( char* testname, char* par, char *baseName ) + execCount++; + char msg[256]; + snprintf(msg, sizeof(msg), "%s {", name); +- LL_message(msg, true); ++ LL_message(UnicodeString(msg), true); + UDate timeStart = uprv_getRawUTCtime(); + strcpy(saveBaseLoc,name); + strcat(saveBaseLoc,"/"); +@@ -828,11 +846,11 @@ UBool IntlTest::runTestLoop( char* testname, char* par, char *baseName ) + } + LL_indentlevel -= 3; + if (lastTestFailed) { +- LL_message( "", true); ++ LL_message({}, true); + } +- LL_message( msg, true); ++ LL_message(UnicodeString(msg), true); + if (lastTestFailed) { +- LL_message( "", true); ++ LL_message({}, true); + } + LL_indentlevel += 3; + } +@@ -849,7 +867,7 @@ UBool IntlTest::runTestLoop( char* testname, char* par, char *baseName ) + /** + * Adds given string to the log if we are in verbose mode. + */ +-void IntlTest::log( const UnicodeString &message ) ++void IntlTest::log(std::u16string_view message) + { + if( verbose ) { + LL_message( message, false ); +@@ -860,7 +878,7 @@ void IntlTest::log( const UnicodeString &message ) + * Adds given string to the log if we are in verbose mode. Adds a new line to + * the given message. + */ +-void IntlTest::logln( const UnicodeString &message ) ++void IntlTest::logln(std::u16string_view message) + { + if( verbose ) { + LL_message( message, true ); +@@ -870,14 +888,14 @@ void IntlTest::logln( const UnicodeString &message ) + void IntlTest::logln() + { + if( verbose ) { +- LL_message( "", true ); ++ LL_message({}, true ); + } + } + + /** + * Unconditionally adds given string to the log. + */ +-void IntlTest::info( const UnicodeString &message ) ++void IntlTest::info(std::u16string_view message) + { + LL_message( message, false ); + } +@@ -886,14 +904,14 @@ void IntlTest::info( const UnicodeString &message ) + * Unconditionally adds given string to the log. Adds a new line to + * the given message. + */ +-void IntlTest::infoln( const UnicodeString &message ) ++void IntlTest::infoln(std::u16string_view message) + { + LL_message( message, true ); + } + + void IntlTest::infoln() + { +- LL_message( "", true ); ++ LL_message({}, true ); + } + + int32_t IntlTest::IncErrorCount() +@@ -915,19 +933,19 @@ void IntlTest::err() + IncErrorCount(); + } + +-void IntlTest::err( const UnicodeString &message ) ++void IntlTest::err(std::u16string_view message) + { + IncErrorCount(); + if (!no_err_msg) LL_message( message, false ); + } + +-void IntlTest::errln( const UnicodeString &message ) ++void IntlTest::errln(std::u16string_view message) + { + IncErrorCount(); + if (!no_err_msg) LL_message( message, true ); + } + +-void IntlTest::dataerr( const UnicodeString &message ) ++void IntlTest::dataerr(std::u16string_view message) + { + IncDataErrorCount(); + +@@ -938,7 +956,7 @@ void IntlTest::dataerr( const UnicodeString &message ) + if (!no_err_msg) LL_message( message, false ); + } + +-void IntlTest::dataerrln( const UnicodeString &message ) ++void IntlTest::dataerrln(std::u16string_view message) + { + int32_t errCount = IncDataErrorCount(); + UnicodeString msg; +@@ -958,7 +976,7 @@ void IntlTest::dataerrln( const UnicodeString &message ) + } + } + +-void IntlTest::errcheckln(UErrorCode status, const UnicodeString &message ) { ++void IntlTest::errcheckln(UErrorCode status, std::u16string_view message) { + if (status == U_FILE_ACCESS_ERROR || status == U_MISSING_RESOURCE_ERROR) { + dataerrln(message); + } else { +@@ -1011,7 +1029,7 @@ UBool IntlTest::logKnownIssue(const char *ticket) { + return logKnownIssue(ticket, UnicodeString()); + } + +-UBool IntlTest::logKnownIssue(const char *ticket, const UnicodeString &msg) { ++UBool IntlTest::logKnownIssue(const char *ticket, std::u16string_view msg) { + if(noKnownIssues) return false; + + char fullpath[2048]; +@@ -1123,7 +1141,7 @@ UBool IntlTest::printKnownIssues() + } + + +-void IntlTest::LL_message( UnicodeString message, UBool newline ) ++void IntlTest::LL_message(std::u16string_view message, UBool newline) + { + // Synchronize this function. + // All error messages generated by tests funnel through here. +@@ -1160,10 +1178,11 @@ void IntlTest::LL_message( UnicodeString message, UBool newline ) + } + + // replace each LineFeed by the indentation string +- message.findAndReplace(UnicodeString(static_cast('\n')), indent); ++ UnicodeString us(message); ++ us.findAndReplace(UnicodeString(static_cast('\n')), indent); + + // stream out the message +- length = message.extract(0, message.length(), buffer, sizeof(buffer)); ++ length = us.extract(0, us.length(), buffer, sizeof(buffer)); + if (length > 0) { + length = length > 30000 ? 30000 : length; + fwrite(buffer, sizeof(*buffer), length, static_cast(testoutfp)); +@@ -1938,8 +1957,8 @@ static inline char16_t toHex(int32_t i) { + return static_cast(i + (i < 10 ? 0x30 : (0x41 - 10))); + } + +-static UnicodeString& escape(const UnicodeString& s, UnicodeString& result) { +- for (int32_t i=0; i(s.length()); ++i) { + char16_t c = s[i]; + if (c <= static_cast(0x7F)) { + result += c; +@@ -2014,8 +2033,8 @@ UBool IntlTest::assertSuccess(const char* message, UErrorCode ec, UBool possible + } + + UBool IntlTest::assertEquals(const char* message, +- const UnicodeString& expected, +- const UnicodeString& actual, ++ std::u16string_view expected, ++ std::u16string_view actual, + UBool possibleDataError) { + if (expected != actual) { + if (possibleDataError) { +@@ -2056,6 +2075,22 @@ UBool IntlTest::assertEquals(const char* message, + return true; + } + ++UBool IntlTest::assertEquals(const char* message, const char* expected, ++ std::u16string_view actual, UBool possibleDataError) { ++ return assertEquals( ++ message, ++ UnicodeString(expected), actual, ++ possibleDataError); ++} ++ ++UBool IntlTest::assertEquals(const char* message, std::u16string_view expected, ++ const char* actual, UBool possibleDataError) { ++ return assertEquals( ++ message, ++ expected, UnicodeString(actual), ++ possibleDataError); ++} ++ + UBool IntlTest::assertEquals(const char* message, + int32_t expected, + int32_t actual) { +@@ -2163,10 +2198,10 @@ UBool IntlTest::assertEquals(const char* message, + + + #if !UCONFIG_NO_FORMATTING +-UBool IntlTest::assertEquals(const char* message, +- const Formattable& expected, +- const Formattable& actual, +- UBool possibleDataError) { ++UBool IntlTest::assertEqualFormattables(const char* message, ++ const Formattable& expected, ++ const Formattable& actual, ++ UBool possibleDataError) { + if (expected != actual) { + if (possibleDataError) { + dataerrln(UnicodeString("FAIL: ") + message + "; got " + +@@ -2273,7 +2308,7 @@ UBool IntlTest::assertEqualsNear(const char* message, + + static char ASSERT_BUF[256]; + +-static const char* extractToAssertBuf(const UnicodeString& message) { ++static const char* extractToAssertBuf(std::u16string_view message) { + UnicodeString buf; + escape(message, buf); + buf.extract(0, 0x7FFFFFFF, ASSERT_BUF, sizeof(ASSERT_BUF) - 1, nullptr); +@@ -2281,82 +2316,87 @@ static const char* extractToAssertBuf(const UnicodeString& message) { + return ASSERT_BUF; + } + +-UBool IntlTest::assertTrue(const UnicodeString& message, UBool condition, UBool quiet, UBool possibleDataError) { ++UBool IntlTest::assertTrue(std::u16string_view message, UBool condition, UBool quiet, UBool possibleDataError) { + return assertTrue(extractToAssertBuf(message), condition, quiet, possibleDataError); + } + +-UBool IntlTest::assertFalse(const UnicodeString& message, UBool condition, UBool quiet, UBool possibleDataError) { ++UBool IntlTest::assertFalse(std::u16string_view message, UBool condition, UBool quiet, UBool possibleDataError) { + return assertFalse(extractToAssertBuf(message), condition, quiet, possibleDataError); + } + +-UBool IntlTest::assertSuccess(const UnicodeString& message, UErrorCode ec) { ++UBool IntlTest::assertSuccess(std::u16string_view message, UErrorCode ec) { + return assertSuccess(extractToAssertBuf(message), ec); + } + +-UBool IntlTest::assertEquals(const UnicodeString& message, +- const UnicodeString& expected, +- const UnicodeString& actual, ++UBool IntlTest::assertEquals(std::u16string_view message, ++ std::u16string_view expected, ++ std::u16string_view actual, + UBool possibleDataError) { + return assertEquals(extractToAssertBuf(message), expected, actual, possibleDataError); + } + +-UBool IntlTest::assertEquals(const UnicodeString& message, ++UBool IntlTest::assertEquals(std::u16string_view message, + const char* expected, + const char* actual) { + return assertEquals(extractToAssertBuf(message), expected, actual); + } +-UBool IntlTest::assertEquals(const UnicodeString& message, ++UBool IntlTest::assertEquals(std::u16string_view message, + UBool expected, + UBool actual) { + return assertEquals(extractToAssertBuf(message), expected, actual); + } +-UBool IntlTest::assertEquals(const UnicodeString& message, ++UBool IntlTest::assertEquals(std::u16string_view message, + int32_t expected, + int32_t actual) { + return assertEquals(extractToAssertBuf(message), expected, actual); + } +-UBool IntlTest::assertEquals(const UnicodeString& message, ++UBool IntlTest::assertEquals(std::u16string_view message, + int64_t expected, + int64_t actual) { + return assertEquals(extractToAssertBuf(message), expected, actual); + } +-UBool IntlTest::assertEquals(const UnicodeString& message, ++UBool IntlTest::assertEquals(std::u16string_view message, + double expected, + double actual) { + return assertEquals(extractToAssertBuf(message), expected, actual); + } +-UBool IntlTest::assertEquals(const UnicodeString& message, ++UBool IntlTest::assertEquals(std::u16string_view message, + UErrorCode expected, + UErrorCode actual) { + return assertEquals(extractToAssertBuf(message), expected, actual); + } +-UBool IntlTest::assertEquals(const UnicodeString& message, ++UBool IntlTest::assertEquals(std::u16string_view message, + const UnicodeSet& expected, + const UnicodeSet& actual) { + return assertEquals(extractToAssertBuf(message), expected, actual); + } +-UBool IntlTest::assertEquals(const UnicodeString& message, ++UBool IntlTest::assertEquals(std::u16string_view message, + const std::vector& expected, + const std::vector& actual) { + return assertEquals(extractToAssertBuf(message), expected, actual); + } +-UBool IntlTest::assertNotEquals(const UnicodeString &message, ++UBool IntlTest::assertNotEquals(std::u16string_view message, + int32_t expectedNot, + int32_t actual) { + return assertNotEquals(extractToAssertBuf(message), expectedNot, actual); + } +-UBool IntlTest::assertEqualsNear(const UnicodeString& message, ++UBool IntlTest::assertEqualsNear(std::u16string_view message, + double expected, + double actual, + double delta) { + return assertEqualsNear(extractToAssertBuf(message), expected, actual, delta); + } + ++UBool IntlTest::assertEquals(std::u16string_view message, const char* expected, ++ std::u16string_view actual, UBool possibleDataError) { ++ return assertEquals(message, UnicodeString(expected), actual, possibleDataError); ++} ++ + #if !UCONFIG_NO_FORMATTING +-UBool IntlTest::assertEquals(const UnicodeString& message, +- const Formattable& expected, +- const Formattable& actual) { +- return assertEquals(extractToAssertBuf(message), expected, actual); ++UBool IntlTest::assertEqualFormattables(std::u16string_view message, ++ const Formattable& expected, ++ const Formattable& actual) { ++ return assertEqualFormattables(extractToAssertBuf(message), expected, actual); + } + #endif + +diff --git a/icu4c/source/test/intltest/intltest.h b/icu4c/source/test/intltest/intltest.h +index 8fb825f6de6..d4ecb9c0353 100644 +--- icu4c/source/test/intltest/intltest.h ++++ icu4c/source/test/intltest/intltest.h +@@ -13,16 +13,22 @@ + #ifndef _INTLTEST + #define _INTLTEST + +-// The following includes utypes.h, uobject.h and unistr.h +-#include "unicode/fmtable.h" +-#include "unicode/testlog.h" +-#include "unicode/uniset.h" +- + #include + #include ++#include ++ ++#include "unicode/utypes.h" ++#include "unicode/testlog.h" ++ ++#if U_SHOW_CPLUSPLUS_API ++#include "unicode/fmtable.h" ++#include "unicode/uniset.h" ++#include "unicode/unistr.h" ++#endif + + U_NAMESPACE_USE + ++#if U_SHOW_CPLUSPLUS_API + + //----------------------------------------------------------------------------- + //convenience classes to ease porting code that uses the Java +@@ -47,6 +53,8 @@ UnicodeString toString(int32_t n); + #endif + UnicodeString toString(UBool b); + ++#endif // U_SHOW_CPLUSPLUS_API ++ + //----------------------------------------------------------------------------- + + // Use the TESTCASE macro in subclasses of IntlTest. Define the +@@ -154,9 +162,9 @@ class IntlTest : public TestLog { + virtual void setCaller( IntlTest* callingTest ); // for internal use only + virtual void setPath( char* path ); // for internal use only + +- virtual void log( const UnicodeString &message ); ++ virtual void log(std::u16string_view message); + +- virtual void logln( const UnicodeString &message ) override; ++ virtual void logln(std::u16string_view message) override; + + virtual void logln(); + +@@ -168,7 +176,7 @@ class IntlTest : public TestLog { + * @param message optional message string + * @return true if test should be skipped + */ +- UBool logKnownIssue( const char *ticket, const UnicodeString &message ); ++ UBool logKnownIssue( const char *ticket, std::u16string_view message); + /** + * Logs that an issue is known. Can be called multiple times. + * Usually used this way: +@@ -192,23 +200,23 @@ class IntlTest : public TestLog { + UBool skipLSTMTest(); + #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ + +- virtual void info( const UnicodeString &message ); ++ virtual void info(std::u16string_view message); + +- virtual void infoln( const UnicodeString &message ); ++ virtual void infoln(std::u16string_view message); + + virtual void infoln(); + + virtual void err(); + +- virtual void err( const UnicodeString &message ); ++ virtual void err(std::u16string_view message); + +- virtual void errln( const UnicodeString &message ) override; ++ virtual void errln(std::u16string_view message) override; + +- virtual void dataerr( const UnicodeString &message ); ++ virtual void dataerr(std::u16string_view message); + +- virtual void dataerrln( const UnicodeString &message ) override; ++ virtual void dataerrln(std::u16string_view message) override; + +- void errcheckln(UErrorCode status, const UnicodeString &message ); ++ void errcheckln(UErrorCode status, std::u16string_view message); + + // convenience functions: sprintf() + errln() etc. + void log(const char *fmt, ...); +@@ -289,13 +297,20 @@ class IntlTest : public TestLog { + * @return true on success, false on failure. + */ + UBool assertSuccess(const char* message, UErrorCode ec, UBool possibleDataError=false, const char *file=nullptr, int line=0); +- UBool assertEquals(const char* message, const UnicodeString& expected, +- const UnicodeString& actual, UBool possibleDataError=false); ++ UBool assertEquals(const char* message, std::u16string_view expected, ++ std::u16string_view actual, UBool possibleDataError=false); + UBool assertEquals(const char* message, const char* expected, const char* actual); + UBool assertEquals(const char* message, UBool expected, UBool actual); + UBool assertEquals(const char* message, int32_t expected, int32_t actual); + UBool assertEquals(const char* message, int64_t expected, int64_t actual); + UBool assertEquals(const char* message, double expected, double actual); ++ ++ // for disambiguation ++ UBool assertEquals(const char* message, const char* expected, ++ std::u16string_view actual, UBool possibleDataError=false); ++ UBool assertEquals(const char* message, std::u16string_view expected, ++ const char* actual, UBool possibleDataError=false); ++ + /** + * Asserts that two doubles are equal to within a positive delta. Returns + * false if they are not. +@@ -311,27 +326,36 @@ class IntlTest : public TestLog { + */ + UBool assertEqualsNear(const char* message, double expected, double actual, double delta); + UBool assertEquals(const char* message, UErrorCode expected, UErrorCode actual); ++#if U_SHOW_CPLUSPLUS_API + UBool assertEquals(const char* message, const UnicodeSet& expected, const UnicodeSet& actual); ++#endif + UBool assertEquals(const char* message, + const std::vector& expected, const std::vector& actual); + ++#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING +- UBool assertEquals(const char* message, const Formattable& expected, +- const Formattable& actual, UBool possibleDataError=false); +- UBool assertEquals(const UnicodeString& message, const Formattable& expected, +- const Formattable& actual); ++ UBool assertEqualFormattables(const char* message, const Formattable& expected, ++ const Formattable& actual, UBool possibleDataError=false); ++ UBool assertEqualFormattables(std::u16string_view message, const Formattable& expected, ++ const Formattable& actual); ++#endif + #endif + UBool assertNotEquals(const char* message, int32_t expectedNot, int32_t actual); +- UBool assertTrue(const UnicodeString& message, UBool condition, UBool quiet=false, UBool possibleDataError=false); +- UBool assertFalse(const UnicodeString& message, UBool condition, UBool quiet=false, UBool possibleDataError=false); +- UBool assertSuccess(const UnicodeString& message, UErrorCode ec); +- UBool assertEquals(const UnicodeString& message, const UnicodeString& expected, +- const UnicodeString& actual, UBool possibleDataError=false); +- UBool assertEquals(const UnicodeString& message, const char* expected, const char* actual); +- UBool assertEquals(const UnicodeString& message, UBool expected, UBool actual); +- UBool assertEquals(const UnicodeString& message, int32_t expected, int32_t actual); +- UBool assertEquals(const UnicodeString& message, int64_t expected, int64_t actual); +- UBool assertEquals(const UnicodeString& message, double expected, double actual); ++ UBool assertTrue(std::u16string_view message, UBool condition, UBool quiet=false, UBool possibleDataError=false); ++ UBool assertFalse(std::u16string_view message, UBool condition, UBool quiet=false, UBool possibleDataError=false); ++ UBool assertSuccess(std::u16string_view message, UErrorCode ec); ++ UBool assertEquals(std::u16string_view message, std::u16string_view expected, ++ std::u16string_view actual, UBool possibleDataError=false); ++ UBool assertEquals(std::u16string_view message, const char* expected, const char* actual); ++ UBool assertEquals(std::u16string_view message, UBool expected, UBool actual); ++ UBool assertEquals(std::u16string_view message, int32_t expected, int32_t actual); ++ UBool assertEquals(std::u16string_view message, int64_t expected, int64_t actual); ++ UBool assertEquals(std::u16string_view message, double expected, double actual); ++ ++ // for disambiguation ++ UBool assertEquals(std::u16string_view message, const char* expected, ++ std::u16string_view actual, UBool possibleDataError=false); ++ + /** + * Asserts that two doubles are equal to within a positive delta. Returns + * false if they are not. +@@ -345,12 +369,14 @@ class IntlTest : public TestLog { + * @param delta - the maximum delta between expected and actual for which + * both numbers are still considered equal. + */ +- UBool assertEqualsNear(const UnicodeString& message, double expected, double actual, double delta); +- UBool assertEquals(const UnicodeString& message, UErrorCode expected, UErrorCode actual); +- UBool assertEquals(const UnicodeString& message, const UnicodeSet& expected, const UnicodeSet& actual); +- UBool assertEquals(const UnicodeString& message, ++ UBool assertEqualsNear(std::u16string_view message, double expected, double actual, double delta); ++ UBool assertEquals(std::u16string_view message, UErrorCode expected, UErrorCode actual); ++#if U_SHOW_CPLUSPLUS_API ++ UBool assertEquals(std::u16string_view message, const UnicodeSet& expected, const UnicodeSet& actual); ++#endif ++ UBool assertEquals(std::u16string_view message, + const std::vector& expected, const std::vector& actual); +- UBool assertNotEquals(const UnicodeString& message, int32_t expectedNot, int32_t actual); ++ UBool assertNotEquals(std::u16string_view message, int32_t expectedNot, int32_t actual); + + virtual void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par = nullptr ); // override ! + +@@ -392,8 +418,9 @@ class IntlTest : public TestLog { + + protected: + +- virtual void LL_message( UnicodeString message, UBool newline ); ++ virtual void LL_message(std::u16string_view message, UBool newline); + ++#if U_SHOW_CPLUSPLUS_API + // used for collation result reporting, defined here for convenience + + static UnicodeString &prettify(const UnicodeString &source, UnicodeString &target); +@@ -404,6 +431,7 @@ class IntlTest : public TestLog { + static inline UnicodeString toHex(int32_t number, int32_t digits=-1) { + return toHex(static_cast(number), digits); + } ++#endif + + public: + static void setICU_DATA(); // Set up ICU_DATA if necessary. +@@ -428,17 +456,24 @@ class IntlTest : public TestLog { + + }; + +-void it_log( UnicodeString message ); +-void it_logln( UnicodeString message ); ++void it_log(std::u16string_view message); ++void it_logln(std::u16string_view message); + void it_logln(); +-void it_info( UnicodeString message ); +-void it_infoln( UnicodeString message ); ++void it_info(std::u16string_view message); ++void it_infoln(std::u16string_view message); + void it_infoln(); + void it_err(); +-void it_err( UnicodeString message ); +-void it_errln( UnicodeString message ); +-void it_dataerr( UnicodeString message ); +-void it_dataerrln( UnicodeString message ); ++void it_err(std::u16string_view message); ++void it_errln(std::u16string_view message); ++void it_dataerr(std::u16string_view message); ++void it_dataerrln(std::u16string_view message); ++ ++void it_logln(const char* message); ++void it_err(const char* message); ++void it_errln(const char* message); ++void it_dataerrln(const char* message); ++ ++#if U_SHOW_CPLUSPLUS_API + + /** + * This is a variant of cintltst/ccolltst.c:CharsToUChars(). +@@ -450,4 +485,6 @@ extern UnicodeString CharsToUnicodeString(const char* chars); + /* alias for CharsToUnicodeString */ + extern UnicodeString ctou(const char* chars); + ++#endif ++ + #endif // _INTLTEST +diff --git a/icu4c/source/test/intltest/itutil.cpp b/icu4c/source/test/intltest/itutil.cpp +index 398f68bc708..ec69e20bed0 100644 +--- icu4c/source/test/intltest/itutil.cpp ++++ icu4c/source/test/intltest/itutil.cpp +@@ -204,19 +204,19 @@ void ErrorCodeTest::TestSubclass() { + + class IcuTestErrorCodeTestHelper : public IntlTest { + public: +- void errln( const UnicodeString &message ) override { ++ void errln(std::u16string_view message) override { + test->assertFalse("Already saw an error", seenError); + seenError = true; +- test->assertEquals("Message for Error", expectedErrln, message); ++ test->assertEquals("Message for Error", std::u16string_view{expectedErrln}, message); + if (expectedDataErr) { + test->errln("Got non-data error, but expected data error"); + } + } + +- void dataerrln( const UnicodeString &message ) override { ++ void dataerrln(std::u16string_view message) override { + test->assertFalse("Already saw an error", seenError); + seenError = true; +- test->assertEquals("Message for Error", expectedErrln, message); ++ test->assertEquals("Message for Error", std::u16string_view{expectedErrln}, message); + if (!expectedDataErr) { + test->errln("Got data error, but expected non-data error"); + } +diff --git a/icu4c/source/test/intltest/localematchertest.cpp b/icu4c/source/test/intltest/localematchertest.cpp +index 2996f8aa706..639b5868220 100644 +--- icu4c/source/test/intltest/localematchertest.cpp ++++ icu4c/source/test/intltest/localematchertest.cpp +@@ -457,7 +457,7 @@ void LocaleMatcherTest::testResolvedLocale() { + + namespace { + +-bool toInvariant(const UnicodeString &s, CharString &inv, ErrorCode &errorCode) { ++bool toInvariant(const UnicodeString &s, CharString &inv, IcuTestErrorCode &errorCode) { + if (errorCode.isSuccess()) { + inv.clear().appendInvariantChars(s, errorCode); + return errorCode.isSuccess(); +@@ -477,7 +477,7 @@ bool getSuffixAfterPrefix(const UnicodeString &s, int32_t limit, + + bool getInvariantSuffixAfterPrefix(const UnicodeString &s, int32_t limit, + const UnicodeString &prefix, CharString &suffix, +- ErrorCode &errorCode) { ++ IcuTestErrorCode &errorCode) { + UnicodeString u_suffix; + return getSuffixAfterPrefix(s, limit, prefix, u_suffix) && + toInvariant(u_suffix, suffix, errorCode); +diff --git a/icu4c/source/test/intltest/numfmtst.cpp b/icu4c/source/test/intltest/numfmtst.cpp +index ede92472295..c855e3e2927 100644 +--- icu4c/source/test/intltest/numfmtst.cpp ++++ icu4c/source/test/intltest/numfmtst.cpp +@@ -2516,7 +2516,7 @@ void NumberFormatTest::TestPerMill() { + if (!assertSuccess("setup", ec)) return; + str.truncate(0); + assertEquals("0.4857 x ###.###m", +- "485.7m", fmt2.format(0.4857, str)); ++ u"485.7m", fmt2.format(0.4857, str)); + } + + /** +@@ -2677,8 +2677,8 @@ void NumberFormatTest::TestCases() { + Formattable m; + fmt->parse(str, m, ec); + assertSuccess("parse", ec); +- assertEquals(where + "\"" + pat + "\".parse(\"" + str + "\")", +- n, m); ++ assertEqualFormattables( ++ where + "\"" + pat + "\".parse(\"" + str + "\")", n, m); + } + } + // p: +@@ -2691,8 +2691,7 @@ void NumberFormatTest::TestCases() { + assertSuccess("parse", ec); + fmt->parse(str, n, ec); + assertSuccess("parse", ec); +- assertEquals(where + "\"" + pat + "\".parse(\"" + str + "\")", +- exp, n); ++ assertEqualFormattables(where + "\"" + pat + "\".parse(\"" + str + "\")", exp, n); + } + break; + case 8: // fpc: +@@ -2734,8 +2733,8 @@ void NumberFormatTest::TestCases() { + + mfmt->parseObject(str, m, ec); + if (assertSuccess("parseCurrency", ec)) { +- assertEquals(where + "getCurrencyFormat(" + mloc + ").parse(\"" + str + "\")", +- n, m); ++ assertEqualFormattables( ++ where + "getCurrencyFormat(" + mloc + ").parse(\"" + str + "\")", n, m); + } else { + errln("FAIL: source " + str); + } +@@ -3767,7 +3766,7 @@ void NumberFormatTest::TestMismatchedCurrencyFormatFail() { + df->setLenient(false); + { + Formattable result; +- ErrorCode failStatus; ++ UErrorCode failStatus = U_ZERO_ERROR; + df->parse(u"1.23\u20AC", result, failStatus); + assertEquals("Should fail to parse", U_INVALID_FORMAT_ERROR, failStatus); + } +@@ -6900,7 +6899,7 @@ void NumberFormatTest::TestDecimal() { + StringPiece num("244444444444444444444444444444444444446.4"); + fmtr->format(num, formattedResult, nullptr, status); + ASSERT_SUCCESS(status); +- ASSERT_EQUALS("244,444,444,444,444,444,444,444,444,444,444,444,446.4", formattedResult); ++ ASSERT_EQUALS(u"244,444,444,444,444,444,444,444,444,444,444,444,446.4", formattedResult); + //std::string ss; std::cout << formattedResult.toUTF8String(ss); + delete fmtr; + } +@@ -6921,7 +6920,7 @@ void NumberFormatTest::TestDecimal() { + ASSERT_SUCCESS(status); + fmtr->format(dl, formattedResult, nullptr, status); + ASSERT_SUCCESS(status); +- ASSERT_EQUALS("1,234,566,666,666,666,666,666,666,666,666,666,666,621,000", formattedResult); ++ ASSERT_EQUALS(u"1,234,566,666,666,666,666,666,666,666,666,666,666,621,000", formattedResult); + + status = U_ZERO_ERROR; + num.set("666.666"); +@@ -6931,7 +6930,7 @@ void NumberFormatTest::TestDecimal() { + formattedResult.remove(); + fmtr->format(dl, formattedResult, pos, status); + ASSERT_SUCCESS(status); +- ASSERT_EQUALS("666.666", formattedResult); ++ ASSERT_EQUALS(u"666.666", formattedResult); + ASSERT_EQUALS(4, pos.getBeginIndex()); + ASSERT_EQUALS(7, pos.getEndIndex()); + delete fmtr; +@@ -8788,7 +8787,7 @@ void NumberFormatTest::Test13391_chakmaParsing() { + Formattable result; + df->parse(expected, result, status); + assertSuccess("Should not fail when parsing in ccp", status); +- assertEquals("Should parse to 12345 in ccp", 12345, result); ++ assertEqualFormattables("Should parse to 12345 in ccp", 12345, result); + + const char16_t* expectedScientific = u"\U00011137.\U00011139E\U00011138"; + UnicodeString actualScientific; +@@ -8802,7 +8801,7 @@ void NumberFormatTest::Test13391_chakmaParsing() { + Formattable resultScientific; + df->parse(expectedScientific, resultScientific, status); + assertSuccess("Should not fail when parsing scientific in ccp", status); +- assertEquals("Should parse scientific to 130 in ccp", 130, resultScientific); ++ assertEqualFormattables("Should parse scientific to 130 in ccp", 130, resultScientific); + } + + +@@ -9592,7 +9591,7 @@ void NumberFormatTest::Test20037_ScientificIntegerOverflow() { + StringPiece sp = result.getDecimalNumber(status); + assertEquals(u"Should snap to zero", + u"0", +- {sp.data(), sp.length(), US_INV}); ++ UnicodeString(sp.data(), sp.length(), US_INV)); + + // Test edge case overflow of exponent + result = Formattable(); +@@ -9600,7 +9599,7 @@ void NumberFormatTest::Test20037_ScientificIntegerOverflow() { + sp = result.getDecimalNumber(status); + assertEquals(u"Should not overflow and should parse only the first exponent", + u"1E-2147483647", +- {sp.data(), sp.length(), US_INV}); ++ UnicodeString(sp.data(), sp.length(), US_INV)); + + // Test edge case overflow of exponent + result = Formattable(); +@@ -9608,7 +9607,7 @@ void NumberFormatTest::Test20037_ScientificIntegerOverflow() { + sp = result.getDecimalNumber(status); + assertEquals(u"Should not overflow", + u"3E-2147483648", +- {sp.data(), sp.length(), US_INV}); ++ UnicodeString(sp.data(), sp.length(), US_INV)); + + // Test largest parseable exponent + result = Formattable(); +@@ -9616,7 +9615,7 @@ void NumberFormatTest::Test20037_ScientificIntegerOverflow() { + sp = result.getDecimalNumber(status); + assertEquals(u"Should not overflow", + u"9.876E+2147483646", +- {sp.data(), sp.length(), US_INV}); ++ UnicodeString(sp.data(), sp.length(), US_INV)); + + // Test max value as well + const char16_t* infinityInputs[] = { +@@ -9632,8 +9631,8 @@ void NumberFormatTest::Test20037_ScientificIntegerOverflow() { + nf->parse(input, result, status); + sp = result.getDecimalNumber(status); + assertEquals(UnicodeString("Should become Infinity: ") + input, +- u"Infinity", +- {sp.data(), sp.length(), US_INV}); ++ u"Infinity", ++ UnicodeString(sp.data(), sp.length(), US_INV)); + } + } + +diff --git a/icu4c/source/test/iotest/iotest.cpp b/icu4c/source/test/iotest/iotest.cpp +index 64ff66fec5d..bb10088fe53 100644 +--- icu4c/source/test/iotest/iotest.cpp ++++ icu4c/source/test/iotest/iotest.cpp +@@ -14,6 +14,9 @@ + * created by: George Rhoten + */ + ++#include ++#include ++#include + + #include "unicode/ustdio.h" + #include "unicode/uclean.h" +@@ -28,9 +31,6 @@ + #include "unicode/tstdtmod.h" + #include "putilimp.h" + +-#include +-#include +- + class DataDrivenLogger : public TestLog { + static const char* fgDataDir; + static char *fgTestDataPath; +@@ -42,23 +42,26 @@ class DataDrivenLogger : public TestLog { + fgTestDataPath = nullptr; + } + } +- virtual void errln( const UnicodeString &message ) override { ++ virtual void errln(std::u16string_view message) override { + char buffer[4000]; +- message.extract(0, message.length(), buffer, sizeof(buffer)); ++ UnicodeString us(message); ++ us.extract(0, us.length(), buffer, sizeof(buffer)); + buffer[3999] = 0; /* NUL terminate */ + log_err(buffer); + } + +- virtual void logln( const UnicodeString &message ) override { ++ virtual void logln(std::u16string_view message) override { + char buffer[4000]; +- message.extract(0, message.length(), buffer, sizeof(buffer)); ++ UnicodeString us(message); ++ us.extract(0, us.length(), buffer, sizeof(buffer)); + buffer[3999] = 0; /* NUL terminate */ + log_info(buffer); + } + +- virtual void dataerrln( const UnicodeString &message ) override { ++ virtual void dataerrln(std::u16string_view message) override { + char buffer[4000]; +- message.extract(0, message.length(), buffer, sizeof(buffer)); ++ UnicodeString us(message); ++ us.extract(0, us.length(), buffer, sizeof(buffer)); + buffer[3999] = 0; /* NUL terminate */ + log_data_err(buffer); + } +diff --git a/icu4c/source/tools/ctestfw/tstdtmod.cpp b/icu4c/source/tools/ctestfw/tstdtmod.cpp +index 649065164b4..5a8e1ef7365 100644 +--- icu4c/source/tools/ctestfw/tstdtmod.cpp ++++ icu4c/source/tools/ctestfw/tstdtmod.cpp +@@ -25,6 +25,22 @@ IcuTestErrorCode::~IcuTestErrorCode() { + } + } + ++UErrorCode IcuTestErrorCode::reset() { ++ UErrorCode code = errorCode; ++ errorCode = U_ZERO_ERROR; ++ return code; ++} ++ ++void IcuTestErrorCode::assertSuccess() const { ++ if(isFailure()) { ++ handleFailure(); ++ } ++} ++ ++const char* IcuTestErrorCode::errorName() const { ++ return u_errorName(errorCode); ++} ++ + UBool IcuTestErrorCode::errIfFailureAndReset() { + if(isFailure()) { + errlog(false, u"expected success", nullptr); +@@ -103,10 +119,11 @@ UBool IcuTestErrorCode::expectErrorAndReset(UErrorCode expectedError, const char + } + + void IcuTestErrorCode::setScope(const char* message) { +- scopeMessage.remove().append({ message, -1, US_INV }); ++ UnicodeString us(message, -1, US_INV); ++ scopeMessage = us; + } + +-void IcuTestErrorCode::setScope(const UnicodeString& message) { ++void IcuTestErrorCode::setScope(std::u16string_view message) { + scopeMessage = message; + } + +@@ -114,12 +131,12 @@ void IcuTestErrorCode::handleFailure() const { + errlog(false, u"(handleFailure)", nullptr); + } + +-void IcuTestErrorCode::errlog(UBool dataErr, const UnicodeString& mainMessage, const char* extraMessage) const { ++void IcuTestErrorCode::errlog(UBool dataErr, std::u16string_view mainMessage, const char* extraMessage) const { + UnicodeString msg(testName, -1, US_INV); + msg.append(u' ').append(mainMessage); + msg.append(u" but got error: ").append(UnicodeString(errorName(), -1, US_INV)); + +- if (!scopeMessage.isEmpty()) { ++ if (!scopeMessage.empty()) { + msg.append(u" scope: ").append(scopeMessage); + } + +diff --git a/icu4c/source/tools/ctestfw/unicode/testlog.h b/icu4c/source/tools/ctestfw/unicode/testlog.h +index a7ffbc60848..3951e729b74 100644 +--- icu4c/source/tools/ctestfw/unicode/testlog.h ++++ icu4c/source/tools/ctestfw/unicode/testlog.h +@@ -13,8 +13,9 @@ + #ifndef U_TESTFW_TESTLOG + #define U_TESTFW_TESTLOG + +-#include "unicode/errorcode.h" +-#include "unicode/unistr.h" ++#include ++#include ++#include "unicode/utypes.h" + #include "unicode/testtype.h" + + /** Facilitates internal logging of data driven test service +@@ -24,18 +25,34 @@ + class T_CTEST_EXPORT_API TestLog { + public: + virtual ~TestLog(); +- virtual void errln( const UnicodeString &message ) = 0; +- virtual void logln( const UnicodeString &message ) = 0; +- virtual void dataerrln( const UnicodeString &message ) = 0; ++ virtual void errln(std::u16string_view message) = 0; ++ virtual void logln(std::u16string_view message) = 0; ++ virtual void dataerrln(std::u16string_view message) = 0; + virtual const char* getTestDataPath(UErrorCode& err) = 0; + }; + +-class T_CTEST_EXPORT_API IcuTestErrorCode : public ErrorCode { ++// Note: The IcuTestErrorCode used to be a subclass of ErrorCode, but that made it not usable for ++// unit tests that work without U_SHOW_CPLUSPLUS_API. ++// So instead we *copy* the ErrorCode API. ++ ++class T_CTEST_EXPORT_API IcuTestErrorCode { + public: + IcuTestErrorCode(TestLog &callingTestClass, const char *callingTestName) +- : testClass(callingTestClass), testName(callingTestName), scopeMessage() {} ++ : errorCode(U_ZERO_ERROR), ++ testClass(callingTestClass), testName(callingTestName), scopeMessage() {} + virtual ~IcuTestErrorCode(); + ++ // ErrorCode API ++ operator UErrorCode & () { return errorCode; } ++ operator UErrorCode * () { return &errorCode; } ++ UBool isSuccess() const { return U_SUCCESS(errorCode); } ++ UBool isFailure() const { return U_FAILURE(errorCode); } ++ UErrorCode get() const { return errorCode; } ++ void set(UErrorCode value) { errorCode=value; } ++ UErrorCode reset(); ++ void assertSuccess() const; ++ const char* errorName() const; ++ + // Returns true if isFailure(). + UBool errIfFailureAndReset(); + UBool errIfFailureAndReset(const char *fmt, ...); +@@ -46,17 +63,18 @@ class T_CTEST_EXPORT_API IcuTestErrorCode : public ErrorCode { + + /** Sets an additional message string to be appended to failure output. */ + void setScope(const char* message); +- void setScope(const UnicodeString& message); ++ void setScope(std::u16string_view message); + + protected: +- virtual void handleFailure() const override; ++ virtual void handleFailure() const; + + private: ++ UErrorCode errorCode; + TestLog &testClass; + const char *const testName; +- UnicodeString scopeMessage; ++ std::u16string scopeMessage; + +- void errlog(UBool dataErr, const UnicodeString& mainMessage, const char* extraMessage) const; ++ void errlog(UBool dataErr, std::u16string_view mainMessage, const char* extraMessage) const; + }; + + #endif +-- +2.47.1 + diff --git a/programming/misc/icu4c/files/fedora/0004-ICU-22954-header-only-test-USet-C-iterators.patch b/programming/misc/icu4c/files/fedora/0004-ICU-22954-header-only-test-USet-C-iterators.patch new file mode 100644 index 0000000000..58d7a06020 --- /dev/null +++ b/programming/misc/icu4c/files/fedora/0004-ICU-22954-header-only-test-USet-C-iterators.patch @@ -0,0 +1,546 @@ +From e3bc073737b226f8bd47302f32f83a3993f7792a Mon Sep 17 00:00:00 2001 +From: Markus Scherer +Date: Thu, 12 Dec 2024 16:32:34 -0800 +Subject: [PATCH] ICU-22954 header-only-test USet C++ iterators + +--- + icu4c/source/test/intltest/Makefile.in | 2 +- + icu4c/source/test/intltest/intltest.vcxproj | 1 + + .../test/intltest/intltest.vcxproj.filters | 15 +- + icu4c/source/test/intltest/itutil.cpp | 2 + + .../test/intltest/usetheaderonlytest.cpp | 219 ++++++++++++++++++ + icu4c/source/test/intltest/usettest.cpp | 173 +------------- + icu4c/source/test/intltest/usettest.h | 4 - + 7 files changed, 243 insertions(+), 173 deletions(-) + create mode 100644 icu4c/source/test/intltest/usetheaderonlytest.cpp + +diff --git a/icu4c/source/test/intltest/Makefile.in b/icu4c/source/test/intltest/Makefile.in +index 66956355c84..81ad5557807 100644 +--- icu4c/source/test/intltest/Makefile.in ++++ icu4c/source/test/intltest/Makefile.in +@@ -75,7 +75,7 @@ numbertest_parse.o numbertest_doubleconversion.o numbertest_skeletons.o \ + static_unisets_test.o numfmtdatadriventest.o numbertest_range.o erarulestest.o \ + formattedvaluetest.o formatted_string_builder_test.o numbertest_permutation.o \ + units_data_test.o units_router_test.o units_test.o displayoptions_test.o \ +-numbertest_simple.o uchar_type_build_test.o ++numbertest_simple.o uchar_type_build_test.o usetheaderonlytest.o + + DEPS = $(OBJECTS:.o=.d) + +diff --git a/icu4c/source/test/intltest/intltest.vcxproj b/icu4c/source/test/intltest/intltest.vcxproj +index 9e6480aa4e1..b58b29b3d4e 100644 +--- icu4c/source/test/intltest/intltest.vcxproj ++++ icu4c/source/test/intltest/intltest.vcxproj +@@ -242,6 +242,7 @@ + + + ++ + + + +diff --git a/icu4c/source/test/intltest/intltest.vcxproj.filters b/icu4c/source/test/intltest/intltest.vcxproj.filters +index f3dca92d191..d5c23d5e4cb 100644 +--- icu4c/source/test/intltest/intltest.vcxproj.filters ++++ icu4c/source/test/intltest/intltest.vcxproj.filters +@@ -571,9 +571,18 @@ + + configuration + +- +- +- ++ ++ formatting ++ ++ ++ formatting ++ ++ ++ formatting ++ ++ ++ misc ++ + + + +diff --git a/icu4c/source/test/intltest/itutil.cpp b/icu4c/source/test/intltest/itutil.cpp +index ec69e20bed0..4585792126d 100644 +--- icu4c/source/test/intltest/itutil.cpp ++++ icu4c/source/test/intltest/itutil.cpp +@@ -35,6 +35,7 @@ + #include "usettest.h" + + extern IntlTest *createBytesTrieTest(); ++extern IntlTest *createUSetHeaderOnlyTest(); + extern IntlTest *createLocaleMatcherTest(); + static IntlTest *createLocalPointerTest(); + extern IntlTest *createUCharsTrieTest(); +@@ -82,6 +83,7 @@ void IntlTestUtilities::runIndexedTest( int32_t index, UBool exec, const char* & + TESTCASE_AUTO_CLASS(LocaleBuilderTest); + TESTCASE_AUTO_CREATE_CLASS(LocaleMatcherTest); + TESTCASE_AUTO_CREATE_CLASS(UHashTest); ++ TESTCASE_AUTO_CREATE_CLASS(USetHeaderOnlyTest); + TESTCASE_AUTO_END; + } + +diff --git a/icu4c/source/test/intltest/usetheaderonlytest.cpp b/icu4c/source/test/intltest/usetheaderonlytest.cpp +new file mode 100644 +index 00000000000..38bc175c174 +--- /dev/null ++++ icu4c/source/test/intltest/usetheaderonlytest.cpp +@@ -0,0 +1,219 @@ ++// © 2024 and later: Unicode, Inc. and others. ++// License & terms of use: http://www.unicode.org/copyright.html ++ ++// usetheaderonlytest.cpp ++// created: 2024dec11 Markus W. Scherer ++ ++#include ++ ++// Test header-only ICU C++ APIs. Do not use other ICU C++ APIs. ++// Non-default configuration: ++#define U_SHOW_CPLUSPLUS_API 0 ++// Default configuration: ++// #define U_SHOW_CPLUSPLUS_HEADER_API 1 ++ ++#include "unicode/utypes.h" ++#include "unicode/uset.h" ++#include "unicode/utf.h" ++#include "unicode/utf16.h" ++#include "intltest.h" ++ ++class USetHeaderOnlyTest : public IntlTest { ++public: ++ USetHeaderOnlyTest() = default; ++ ++ void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par=nullptr) override; ++ ++ void TestUSetCodePointIterator(); ++ void TestUSetRangeIterator(); ++ void TestUSetStringIterator(); ++ void TestUSetElementIterator(); ++}; ++ ++extern IntlTest *createUSetHeaderOnlyTest() { ++ return new USetHeaderOnlyTest(); ++} ++ ++void USetHeaderOnlyTest::runIndexedTest(int32_t index, UBool exec, const char *&name, char * /*par*/) { ++ if(exec) { ++ logln("TestSuite USetHeaderOnlyTest: "); ++ } ++ TESTCASE_AUTO_BEGIN; ++ TESTCASE_AUTO(TestUSetCodePointIterator); ++ TESTCASE_AUTO(TestUSetRangeIterator); ++ TESTCASE_AUTO(TestUSetStringIterator); ++ TESTCASE_AUTO(TestUSetElementIterator); ++ TESTCASE_AUTO_END; ++} ++ ++std::u16string cpString(UChar32 c) { ++ if (U_IS_BMP(c)) { ++ return {static_cast(c)}; ++ } else { ++ return {U16_LEAD(c), U16_TRAIL(c)}; ++ } ++} ++ ++void USetHeaderOnlyTest::TestUSetCodePointIterator() { ++ IcuTestErrorCode errorCode(*this, "TestUSetCodePointIterator"); ++ using U_HEADER_NESTED_NAMESPACE::USetCodePoints; ++ LocalUSetPointer uset(uset_openPattern(u"[abcçカ🚴]", -1, errorCode)); ++ std::u16string result; ++ for (UChar32 c : USetCodePoints(uset.getAlias())) { ++ // Commented-out sample code for pasting into the API docs. ++ // printf("uset.codePoint U+%04lx\n", (long)c); ++ result.append(u" ").append(cpString(c)); ++ } ++ assertEquals(WHERE, u" a b c ç カ 🚴", result); ++ ++ USetCodePoints range1(uset.getAlias()); ++ auto range2(range1); // copy constructor ++ auto iter = range1.begin(); ++ auto limit = range2.end(); ++ // operator* with pre- and post-increment ++ assertEquals(WHERE, u'a', *iter); ++ ++iter; ++ assertEquals(WHERE, u'b', *iter); ++ assertEquals(WHERE, u'c', *++iter); ++ auto iter2(iter); // copy constructor ++ assertEquals(WHERE, u'c', *iter2++); ++ assertEquals(WHERE, u'ç', *iter2++); ++ assertEquals(WHERE, u'カ', *iter2); ++ assertTrue(WHERE, ++iter2 != limit); ++ auto iter3(iter2++); ++ assertEquals(WHERE, U'🚴', *iter3); ++ assertTrue(WHERE, iter2 == limit); ++} ++ ++void USetHeaderOnlyTest::TestUSetRangeIterator() { ++ IcuTestErrorCode errorCode(*this, "TestUSetRangeIterator"); ++ using U_HEADER_NESTED_NAMESPACE::USetRanges; ++ using U_HEADER_NESTED_NAMESPACE::CodePointRange; ++ LocalUSetPointer uset(uset_openPattern(u"[abcçカ🚴]", -1, errorCode)); ++ std::u16string result; ++ for (auto [start, end] : USetRanges(uset.getAlias())) { ++ // Commented-out sample code for pasting into the API docs. ++ // printf("uset.range U+%04lx..U+%04lx\n", (long)start, (long)end); ++ result.append(u" ").append(cpString(start)).append(u"-").append(cpString(end)); ++ } ++ assertEquals(WHERE, u" a-c ç-ç カ-カ 🚴-🚴", result); ++ result.clear(); ++ for (auto range : USetRanges(uset.getAlias())) { ++ for (UChar32 c : range) { ++ // Commented-out sample code for pasting into the API docs. ++ // printf("uset.range.c U+%04lx\n", (long)c); ++ result.append(u" ").append(cpString(c)); ++ } ++ result.append(u" |"); ++ } ++ assertEquals(WHERE, u" a b c | ç | カ | 🚴 |", result); ++ ++ USetRanges range1(uset.getAlias()); ++ auto range2(range1); // copy constructor ++ auto iter = range1.begin(); ++ auto limit = range2.end(); ++ // operator* with pre- and post-increment ++ { ++ auto cpRange = *iter; ++ assertEquals(WHERE, u'a', cpRange.rangeStart); ++ assertEquals(WHERE, u'c', cpRange.rangeEnd); ++ assertEquals(WHERE, 3, cpRange.size()); ++ auto cpRange2(cpRange); ++ auto cpIter = cpRange.begin(); ++ auto cpLimit = cpRange2.end(); ++ assertEquals(WHERE, u'a', *cpIter++); ++ assertEquals(WHERE, u'b', *cpIter); ++ assertTrue(WHERE, cpIter != cpLimit); ++ CodePointRange::iterator cpIter2(u'b'); // public constructor ++ assertTrue(WHERE, cpIter == cpIter2); ++ assertEquals(WHERE, u'c', *++cpIter); ++ assertTrue(WHERE, cpIter != cpIter2); ++ assertTrue(WHERE, ++cpIter == cpLimit); ++ } ++ ++iter; ++ auto iter2(iter); // copy constructor ++ assertEquals(WHERE, u'ç', (*iter2).rangeStart); ++ assertEquals(WHERE, u'ç', (*iter2).rangeEnd); ++ assertEquals(WHERE, 1, (*iter2).size()); ++ assertEquals(WHERE, u'ç', (*iter2++).rangeStart); ++ assertEquals(WHERE, u'カ', (*iter2).rangeStart); ++ assertTrue(WHERE, ++iter2 != limit); ++ auto iter3(iter2++); ++ assertEquals(WHERE, U'🚴', (*iter3).rangeStart); ++ assertTrue(WHERE, iter2 == limit); ++ ++ { ++ CodePointRange cpRange(u'h', u'k'); // public constructor ++ // FYI: currently no operator== ++ assertEquals(WHERE, u'h', cpRange.rangeStart); ++ assertEquals(WHERE, u'k', cpRange.rangeEnd); ++ assertEquals(WHERE, 4, cpRange.size()); ++ assertEquals(WHERE, u'i', *++(cpRange.begin())); ++ } ++} ++ ++void USetHeaderOnlyTest::TestUSetStringIterator() { ++ IcuTestErrorCode errorCode(*this, "TestUSetStringIterator"); ++ using U_HEADER_NESTED_NAMESPACE::USetStrings; ++ LocalUSetPointer uset(uset_openPattern(u"[abcçカ🚴{}{abc}{de}]", -1, errorCode)); ++ std::u16string result; ++ for (auto s : USetStrings(uset.getAlias())) { ++ // Commented-out sample code for pasting into the API docs. ++ // Needs U_SHOW_CPLUSPLUS_API=1 for UnicodeString. ++ // UnicodeString us(s); ++ // std::string u8; ++ // printf("uset.string length %ld \"%s\"\n", (long)s.length(), us.toUTF8String(u8).c_str()); ++ result.append(u" \"").append(s).append(u"\""); ++ } ++ assertEquals(WHERE, uR"( "" "abc" "de")", result); ++ ++ USetStrings range1(uset.getAlias()); ++ auto range2(range1); // copy constructor ++ auto iter = range1.begin(); ++ auto limit = range2.end(); ++ // operator* with pre- and post-increment ++ assertEquals(WHERE, u"", *iter); ++ assertEquals(WHERE, u"abc", *++iter); ++ auto iter2(iter); // copy constructor ++ assertEquals(WHERE, u"abc", *iter2++); ++ assertTrue(WHERE, iter2 != limit); ++ auto iter3(iter2++); ++ assertEquals(WHERE, u"de", *iter3); ++ assertTrue(WHERE, iter2 == limit); ++} ++ ++void USetHeaderOnlyTest::TestUSetElementIterator() { ++ IcuTestErrorCode errorCode(*this, "TestUSetElementIterator"); ++ using U_HEADER_NESTED_NAMESPACE::USetElements; ++ LocalUSetPointer uset(uset_openPattern(u"[abcçカ🚴{}{abc}{de}]", -1, errorCode)); ++ std::u16string result; ++ for (auto el : USetElements(uset.getAlias())) { ++ // Commented-out sample code for pasting into the API docs. ++ // Needs U_SHOW_CPLUSPLUS_API=1 for UnicodeString. ++ // UnicodeString us(el); ++ // std::string u8; ++ // printf("uset.string length %ld \"%s\"\n", (long)us.length(), us.toUTF8String(u8).c_str()); ++ result.append(u" \"").append(el).append(u"\""); ++ } ++ assertEquals(WHERE, uR"( "a" "b" "c" "ç" "カ" "🚴" "" "abc" "de")", result); ++ ++ USetElements range1(uset.getAlias()); ++ auto range2(range1); // copy constructor ++ auto iter = range1.begin(); ++ auto limit = range2.end(); ++ // operator* with pre- and post-increment ++ assertEquals(WHERE, u"a", *iter); ++ ++iter; ++ assertEquals(WHERE, u"b", *iter); ++ assertEquals(WHERE, u"c", *++iter); ++ auto iter2(iter); // copy constructor ++ assertEquals(WHERE, u"c", *iter2++); ++ // skip çカ🚴 ++ ++++++iter2; ++ assertEquals(WHERE, u"", *iter2++); ++ assertEquals(WHERE, u"abc", *iter2); ++ assertTrue(WHERE, ++iter2 != limit); ++ auto iter3(iter2++); ++ assertEquals(WHERE, u"de", *iter3); ++ assertTrue(WHERE, iter2 == limit); ++} +diff --git a/icu4c/source/test/intltest/usettest.cpp b/icu4c/source/test/intltest/usettest.cpp +index 477639e8659..9da0612b148 100644 +--- icu4c/source/test/intltest/usettest.cpp ++++ icu4c/source/test/intltest/usettest.cpp +@@ -107,13 +107,9 @@ UnicodeSetTest::runIndexedTest(int32_t index, UBool exec, + TESTCASE_AUTO(TestSkipToStrings); + TESTCASE_AUTO(TestPatternCodePointComplement); + TESTCASE_AUTO(TestCodePointIterator); +- TESTCASE_AUTO(TestUSetCodePointIterator); + TESTCASE_AUTO(TestRangeIterator); +- TESTCASE_AUTO(TestUSetRangeIterator); + TESTCASE_AUTO(TestStringIterator); +- TESTCASE_AUTO(TestUSetStringIterator); + TESTCASE_AUTO(TestElementIterator); +- TESTCASE_AUTO(TestUSetElementIterator); + TESTCASE_AUTO_END; + } + +@@ -4280,37 +4276,8 @@ void UnicodeSetTest::TestCodePointIterator() { + } + assertEquals(WHERE, u" a b c ç カ 🚴", result); + +- // codePoints() returns USetCodePoints for which explicit APIs are tested via USet. +-} +- +-void UnicodeSetTest::TestUSetCodePointIterator() { +- IcuTestErrorCode errorCode(*this, "TestUSetCodePointIterator"); +- using U_HEADER_NESTED_NAMESPACE::USetCodePoints; +- LocalUSetPointer uset(uset_openPattern(u"[abcçカ🚴]", -1, errorCode)); +- UnicodeString result; +- for (UChar32 c : USetCodePoints(uset.getAlias())) { +- // printf("uset.codePoint U+%04lx\n", (long)c); +- result.append(u' ').append(c); +- } +- assertEquals(WHERE, u" a b c ç カ 🚴", result); +- +- USetCodePoints range1(uset.getAlias()); +- auto range2(range1); // copy constructor +- auto iter = range1.begin(); +- auto limit = range2.end(); +- // operator* with pre- and post-increment +- assertEquals(WHERE, u'a', *iter); +- ++iter; +- assertEquals(WHERE, u'b', *iter); +- assertEquals(WHERE, u'c', *++iter); +- auto iter2(iter); // copy constructor +- assertEquals(WHERE, u'c', *iter2++); +- assertEquals(WHERE, u'ç', *iter2++); +- assertEquals(WHERE, u'カ', *iter2); +- assertTrue(WHERE, ++iter2 != limit); +- auto iter3(iter2++); +- assertEquals(WHERE, U'🚴', *iter3); +- assertTrue(WHERE, iter2 == limit); ++ // codePoints() returns USetCodePoints for which explicit APIs are tested via USet ++ // in a header-only unit test file. + } + + void UnicodeSetTest::TestRangeIterator() { +@@ -4332,72 +4299,8 @@ void UnicodeSetTest::TestRangeIterator() { + } + assertEquals(WHERE, u" a b c | ç | カ | 🚴 |", result); + +- // ranges() returns USetRanges for which explicit APIs are tested via USet. +-} +- +-void UnicodeSetTest::TestUSetRangeIterator() { +- IcuTestErrorCode errorCode(*this, "TestUSetRangeIterator"); +- using U_HEADER_NESTED_NAMESPACE::USetRanges; +- using U_HEADER_NESTED_NAMESPACE::CodePointRange; +- LocalUSetPointer uset(uset_openPattern(u"[abcçカ🚴]", -1, errorCode)); +- UnicodeString result; +- for (auto [start, end] : USetRanges(uset.getAlias())) { +- // printf("uset.range U+%04lx..U+%04lx\n", (long)start, (long)end); +- result.append(u' ').append(start).append(u'-').append(end); +- } +- assertEquals(WHERE, u" a-c ç-ç カ-カ 🚴-🚴", result); +- result.remove(); +- for (auto range : USetRanges(uset.getAlias())) { +- for (UChar32 c : range) { +- // printf("uset.range.c U+%04lx\n", (long)c); +- result.append(u' ').append(c); +- } +- result.append(u" |"); +- } +- assertEquals(WHERE, u" a b c | ç | カ | 🚴 |", result); +- +- USetRanges range1(uset.getAlias()); +- auto range2(range1); // copy constructor +- auto iter = range1.begin(); +- auto limit = range2.end(); +- // operator* with pre- and post-increment +- { +- auto cpRange = *iter; +- assertEquals(WHERE, u'a', cpRange.rangeStart); +- assertEquals(WHERE, u'c', cpRange.rangeEnd); +- assertEquals(WHERE, 3, cpRange.size()); +- auto cpRange2(cpRange); +- auto cpIter = cpRange.begin(); +- auto cpLimit = cpRange2.end(); +- assertEquals(WHERE, u'a', *cpIter++); +- assertEquals(WHERE, u'b', *cpIter); +- assertTrue(WHERE, cpIter != cpLimit); +- CodePointRange::iterator cpIter2(u'b'); // public constructor +- assertTrue(WHERE, cpIter == cpIter2); +- assertEquals(WHERE, u'c', *++cpIter); +- assertTrue(WHERE, cpIter != cpIter2); +- assertTrue(WHERE, ++cpIter == cpLimit); +- } +- ++iter; +- auto iter2(iter); // copy constructor +- assertEquals(WHERE, u'ç', (*iter2).rangeStart); +- assertEquals(WHERE, u'ç', (*iter2).rangeEnd); +- assertEquals(WHERE, 1, (*iter2).size()); +- assertEquals(WHERE, u'ç', (*iter2++).rangeStart); +- assertEquals(WHERE, u'カ', (*iter2).rangeStart); +- assertTrue(WHERE, ++iter2 != limit); +- auto iter3(iter2++); +- assertEquals(WHERE, U'🚴', (*iter3).rangeStart); +- assertTrue(WHERE, iter2 == limit); +- +- { +- CodePointRange cpRange(u'h', u'k'); // public constructor +- // FYI: currently no operator== +- assertEquals(WHERE, u'h', cpRange.rangeStart); +- assertEquals(WHERE, u'k', cpRange.rangeEnd); +- assertEquals(WHERE, 4, cpRange.size()); +- assertEquals(WHERE, u'i', *++(cpRange.begin())); +- } ++ // ranges() returns USetRanges for which explicit APIs are tested via USet ++ // in a header-only unit test file. + } + + void UnicodeSetTest::TestStringIterator() { +@@ -4412,35 +4315,8 @@ void UnicodeSetTest::TestStringIterator() { + } + assertEquals(WHERE, uR"( "" "abc" "de")", result); + +- // strings() returns USetStrins for which explicit APIs are tested via USet. +-} +- +-void UnicodeSetTest::TestUSetStringIterator() { +- IcuTestErrorCode errorCode(*this, "TestUSetStringIterator"); +- using U_HEADER_NESTED_NAMESPACE::USetStrings; +- LocalUSetPointer uset(uset_openPattern(u"[abcçカ🚴{}{abc}{de}]", -1, errorCode)); +- UnicodeString result; +- for (auto s : USetStrings(uset.getAlias())) { +- // UnicodeString us(s); +- // std::string u8; +- // printf("uset.string length %ld \"%s\"\n", (long)s.length(), us.toUTF8String(u8).c_str()); +- result.append(u" \"").append(s).append(u'"'); +- } +- assertEquals(WHERE, uR"( "" "abc" "de")", result); +- +- USetStrings range1(uset.getAlias()); +- auto range2(range1); // copy constructor +- auto iter = range1.begin(); +- auto limit = range2.end(); +- // operator* with pre- and post-increment +- assertEquals(WHERE, UnicodeString(), UnicodeString(*iter)); +- assertEquals(WHERE, u"abc", UnicodeString(*++iter)); +- auto iter2(iter); // copy constructor +- assertEquals(WHERE, u"abc", UnicodeString(*iter2++)); +- assertTrue(WHERE, iter2 != limit); +- auto iter3(iter2++); +- assertEquals(WHERE, u"de", UnicodeString(*iter3)); +- assertTrue(WHERE, iter2 == limit); ++ // strings() returns USetStrins for which explicit APIs are tested via USet ++ // in a header-only unit test file. + } + + void UnicodeSetTest::TestElementIterator() { +@@ -4455,39 +4331,6 @@ void UnicodeSetTest::TestElementIterator() { + } + assertEquals(WHERE, uR"( "a" "b" "c" "ç" "カ" "🚴" "" "abc" "de")", result); + +- // begin() & end() return USetElementIterator for which explicit APIs are tested via USet. +-} +- +-void UnicodeSetTest::TestUSetElementIterator() { +- IcuTestErrorCode errorCode(*this, "TestUSetElementIterator"); +- using U_HEADER_NESTED_NAMESPACE::USetElements; +- LocalUSetPointer uset(uset_openPattern(u"[abcçカ🚴{}{abc}{de}]", -1, errorCode)); +- UnicodeString result; +- for (auto el : USetElements(uset.getAlias())) { +- // UnicodeString us(el); +- // std::string u8; +- // printf("uset.string length %ld \"%s\"\n", (long)us.length(), us.toUTF8String(u8).c_str()); +- result.append(u" \"").append(el).append(u'"'); +- } +- assertEquals(WHERE, uR"( "a" "b" "c" "ç" "カ" "🚴" "" "abc" "de")", result); +- +- USetElements range1(uset.getAlias()); +- auto range2(range1); // copy constructor +- auto iter = range1.begin(); +- auto limit = range2.end(); +- // operator* with pre- and post-increment +- assertEquals(WHERE, u"a", *iter); +- ++iter; +- assertEquals(WHERE, u"b", *iter); +- assertEquals(WHERE, u"c", *++iter); +- auto iter2(iter); // copy constructor +- assertEquals(WHERE, u"c", *iter2++); +- // skip çカ🚴 +- ++++++iter2; +- assertEquals(WHERE, UnicodeString(), *iter2++); +- assertEquals(WHERE, u"abc", *iter2); +- assertTrue(WHERE, ++iter2 != limit); +- auto iter3(iter2++); +- assertEquals(WHERE, u"de", *iter3); +- assertTrue(WHERE, iter2 == limit); ++ // begin() & end() return USetElementIterator for which explicit APIs are tested via USet ++ // in a header-only unit test file. + } +diff --git a/icu4c/source/test/intltest/usettest.h b/icu4c/source/test/intltest/usettest.h +index 0127042c736..2ac22ba72e6 100644 +--- icu4c/source/test/intltest/usettest.h ++++ icu4c/source/test/intltest/usettest.h +@@ -106,13 +106,9 @@ class UnicodeSetTest: public IntlTest { + void TestPatternCodePointComplement(); + + void TestCodePointIterator(); +- void TestUSetCodePointIterator(); + void TestRangeIterator(); +- void TestUSetRangeIterator(); + void TestStringIterator(); +- void TestUSetStringIterator(); + void TestElementIterator(); +- void TestUSetElementIterator(); + + private: + +-- +2.47.1 + diff --git a/programming/misc/icu4c/files/fedora/0005-ICU-22954-Partially-revert-PR-3295-U_ICU_NAMESPACE_O.patch b/programming/misc/icu4c/files/fedora/0005-ICU-22954-Partially-revert-PR-3295-U_ICU_NAMESPACE_O.patch new file mode 100644 index 0000000000..59133c426b --- /dev/null +++ b/programming/misc/icu4c/files/fedora/0005-ICU-22954-Partially-revert-PR-3295-U_ICU_NAMESPACE_O.patch @@ -0,0 +1,153 @@ +From c0a3fe15d4420157fbede62470426fcf91299760 Mon Sep 17 00:00:00 2001 +From: Markus Scherer +Date: Mon, 23 Dec 2024 10:00:43 -0800 +Subject: [PATCH] ICU-22954 Partially revert PR #3295 + U_ICU_NAMESPACE_OR_INTERNAL, header-only localpointer + +This partially reverts commit 3527b3d320d6ad128fbff247e31f739f6ccb7a5a. + +Making LocalPointer header-only, with a different namespace when compiling internally, +turned out to be problematic. +--- + icu4c/source/common/unicode/localpointer.h | 10 +++++----- + icu4c/source/common/unicode/normlzr.h | 4 ++-- + icu4c/source/common/unicode/unistr.h | 8 ++++---- + icu4c/source/common/unicode/uset.h | 6 +++--- + icu4c/source/i18n/unicode/ucol.h | 4 ++-- + 5 files changed, 16 insertions(+), 16 deletions(-) + +diff --git a/icu4c/source/common/unicode/localpointer.h b/icu4c/source/common/unicode/localpointer.h +index 487ddb48b78..9c891bf3088 100644 +--- icu4c/source/common/unicode/localpointer.h ++++ icu4c/source/common/unicode/localpointer.h +@@ -21,7 +21,7 @@ + + /** + * \file +- * \brief C++ header-only API: "Smart pointers" for use with and in ICU4C C++ code. ++ * \brief C++ API: "Smart pointers" for use with and in ICU4C C++ code. + * + * These classes are inspired by + * - std::auto_ptr +@@ -40,11 +40,11 @@ + + #include "unicode/utypes.h" + +-#if U_SHOW_CPLUSPLUS_API || U_SHOW_CPLUSPLUS_HEADER_API ++#if U_SHOW_CPLUSPLUS_API + + #include + +-namespace U_ICU_NAMESPACE_OR_INTERNAL { ++U_NAMESPACE_BEGIN + + /** + * "Smart pointer" base class; do not use directly: use LocalPointer etc. +@@ -603,7 +603,7 @@ class LocalOpenPointer : public LocalPointerBase { + } // namespace internal + #endif + +-} // U_ICU_NAMESPACE_OR_INTERNAL ++U_NAMESPACE_END + +-#endif // U_SHOW_CPLUSPLUS_API || U_SHOW_CPLUSPLUS_HEADER_API ++#endif /* U_SHOW_CPLUSPLUS_API */ + #endif /* __LOCALPOINTER_H__ */ +diff --git a/icu4c/source/common/unicode/normlzr.h b/icu4c/source/common/unicode/normlzr.h +index 40848bf00ca..0309bce5382 100644 +--- icu4c/source/common/unicode/normlzr.h ++++ icu4c/source/common/unicode/normlzr.h +@@ -801,8 +801,8 @@ Normalizer::compare(const UnicodeString &s1, const UnicodeString &s2, + uint32_t options, + UErrorCode &errorCode) { + // all argument checking is done in unorm_compare +- return unorm_compare(U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(s1.getBuffer()), s1.length(), +- U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(s2.getBuffer()), s2.length(), ++ return unorm_compare(toUCharPtr(s1.getBuffer()), s1.length(), ++ toUCharPtr(s2.getBuffer()), s2.length(), + options, + &errorCode); + } +diff --git a/icu4c/source/common/unicode/unistr.h b/icu4c/source/common/unicode/unistr.h +index a1901c91504..39d789fd6ef 100644 +--- icu4c/source/common/unicode/unistr.h ++++ icu4c/source/common/unicode/unistr.h +@@ -4676,7 +4676,7 @@ UnicodeString::startsWith(const UnicodeString& srcText, + inline UBool + UnicodeString::startsWith(ConstChar16Ptr srcChars, int32_t srcLength) const { + if(srcLength < 0) { +- srcLength = u_strlen(U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(srcChars)); ++ srcLength = u_strlen(toUCharPtr(srcChars)); + } + return doEqualsSubstring(0, srcLength, srcChars, 0, srcLength); + } +@@ -4684,7 +4684,7 @@ UnicodeString::startsWith(ConstChar16Ptr srcChars, int32_t srcLength) const { + inline UBool + UnicodeString::startsWith(const char16_t *srcChars, int32_t srcStart, int32_t srcLength) const { + if(srcLength < 0) { +- srcLength = u_strlen(U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(srcChars)); ++ srcLength = u_strlen(toUCharPtr(srcChars)); + } + return doEqualsSubstring(0, srcLength, srcChars, srcStart, srcLength); + } +@@ -4707,7 +4707,7 @@ inline UBool + UnicodeString::endsWith(ConstChar16Ptr srcChars, + int32_t srcLength) const { + if(srcLength < 0) { +- srcLength = u_strlen(U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(srcChars)); ++ srcLength = u_strlen(toUCharPtr(srcChars)); + } + return doEqualsSubstring(length() - srcLength, srcLength, srcChars, 0, srcLength); + } +@@ -4717,7 +4717,7 @@ UnicodeString::endsWith(const char16_t *srcChars, + int32_t srcStart, + int32_t srcLength) const { + if(srcLength < 0) { +- srcLength = u_strlen(U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(srcChars + srcStart)); ++ srcLength = u_strlen(toUCharPtr(srcChars + srcStart)); + } + return doEqualsSubstring(length() - srcLength, srcLength, + srcChars, srcStart, srcLength); +diff --git a/icu4c/source/common/unicode/uset.h b/icu4c/source/common/unicode/uset.h +index 345d6244544..b5333a5f5ce 100644 +--- icu4c/source/common/unicode/uset.h ++++ icu4c/source/common/unicode/uset.h +@@ -346,9 +346,9 @@ uset_openPatternOptions(const UChar* pattern, int32_t patternLength, + U_CAPI void U_EXPORT2 + uset_close(USet* set); + +-#if U_SHOW_CPLUSPLUS_API || U_SHOW_CPLUSPLUS_HEADER_API ++#if U_SHOW_CPLUSPLUS_API + +-namespace U_ICU_NAMESPACE_OR_INTERNAL { ++U_NAMESPACE_BEGIN + + /** + * \class LocalUSetPointer +@@ -361,7 +361,7 @@ namespace U_ICU_NAMESPACE_OR_INTERNAL { + */ + U_DEFINE_LOCAL_OPEN_POINTER(LocalUSetPointer, USet, uset_close); + +-} // U_ICU_NAMESPACE_OR_INTERNAL ++U_NAMESPACE_END + + #endif + +diff --git a/icu4c/source/i18n/unicode/ucol.h b/icu4c/source/i18n/unicode/ucol.h +index 8b6dfeaa0a8..ae4f29c3c6c 100644 +--- icu4c/source/i18n/unicode/ucol.h ++++ icu4c/source/i18n/unicode/ucol.h +@@ -1572,8 +1572,8 @@ class Predicate { + return compare( + ucol_strcoll( + collator, +- U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(lhs.getBuffer()), lhs.length(), +- U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(rhs.getBuffer()), rhs.length()), ++ toUCharPtr(lhs.getBuffer()), lhs.length(), ++ toUCharPtr(rhs.getBuffer()), rhs.length()), + result); + } + +-- +2.47.1 + diff --git a/programming/misc/icu4c/files/fedora/0006-ICU-22954-USetHeaderOnlyTest-use-unique_ptr.patch b/programming/misc/icu4c/files/fedora/0006-ICU-22954-USetHeaderOnlyTest-use-unique_ptr.patch new file mode 100644 index 0000000000..a334dc62d8 --- /dev/null +++ b/programming/misc/icu4c/files/fedora/0006-ICU-22954-USetHeaderOnlyTest-use-unique_ptr.patch @@ -0,0 +1,119 @@ +From b0ae845e4760a26719b2285fca3fc464cf213aee Mon Sep 17 00:00:00 2001 +From: Markus Scherer +Date: Mon, 23 Dec 2024 10:35:05 -0800 +Subject: [PATCH] ICU-22954 USetHeaderOnlyTest use unique_ptr + +--- + .../test/intltest/usetheaderonlytest.cpp | 31 +++++++++++-------- + 1 file changed, 18 insertions(+), 13 deletions(-) + +diff --git a/icu4c/source/test/intltest/usetheaderonlytest.cpp b/icu4c/source/test/intltest/usetheaderonlytest.cpp +index 38bc175c174..49fe420a418 100644 +--- icu4c/source/test/intltest/usetheaderonlytest.cpp ++++ icu4c/source/test/intltest/usetheaderonlytest.cpp +@@ -4,6 +4,7 @@ + // usetheaderonlytest.cpp + // created: 2024dec11 Markus W. Scherer + ++#include + #include + + // Test header-only ICU C++ APIs. Do not use other ICU C++ APIs. +@@ -57,16 +58,17 @@ std::u16string cpString(UChar32 c) { + void USetHeaderOnlyTest::TestUSetCodePointIterator() { + IcuTestErrorCode errorCode(*this, "TestUSetCodePointIterator"); + using U_HEADER_NESTED_NAMESPACE::USetCodePoints; +- LocalUSetPointer uset(uset_openPattern(u"[abcçカ🚴]", -1, errorCode)); ++ std::unique_ptr uset( ++ uset_openPattern(u"[abcçカ🚴]", -1, errorCode), &uset_close); + std::u16string result; +- for (UChar32 c : USetCodePoints(uset.getAlias())) { ++ for (UChar32 c : USetCodePoints(uset.get())) { + // Commented-out sample code for pasting into the API docs. + // printf("uset.codePoint U+%04lx\n", (long)c); + result.append(u" ").append(cpString(c)); + } + assertEquals(WHERE, u" a b c ç カ 🚴", result); + +- USetCodePoints range1(uset.getAlias()); ++ USetCodePoints range1(uset.get()); + auto range2(range1); // copy constructor + auto iter = range1.begin(); + auto limit = range2.end(); +@@ -89,16 +91,17 @@ void USetHeaderOnlyTest::TestUSetRangeIterator() { + IcuTestErrorCode errorCode(*this, "TestUSetRangeIterator"); + using U_HEADER_NESTED_NAMESPACE::USetRanges; + using U_HEADER_NESTED_NAMESPACE::CodePointRange; +- LocalUSetPointer uset(uset_openPattern(u"[abcçカ🚴]", -1, errorCode)); ++ std::unique_ptr uset( ++ uset_openPattern(u"[abcçカ🚴]", -1, errorCode), &uset_close); + std::u16string result; +- for (auto [start, end] : USetRanges(uset.getAlias())) { ++ for (auto [start, end] : USetRanges(uset.get())) { + // Commented-out sample code for pasting into the API docs. + // printf("uset.range U+%04lx..U+%04lx\n", (long)start, (long)end); + result.append(u" ").append(cpString(start)).append(u"-").append(cpString(end)); + } + assertEquals(WHERE, u" a-c ç-ç カ-カ 🚴-🚴", result); + result.clear(); +- for (auto range : USetRanges(uset.getAlias())) { ++ for (auto range : USetRanges(uset.get())) { + for (UChar32 c : range) { + // Commented-out sample code for pasting into the API docs. + // printf("uset.range.c U+%04lx\n", (long)c); +@@ -108,7 +111,7 @@ void USetHeaderOnlyTest::TestUSetRangeIterator() { + } + assertEquals(WHERE, u" a b c | ç | カ | 🚴 |", result); + +- USetRanges range1(uset.getAlias()); ++ USetRanges range1(uset.get()); + auto range2(range1); // copy constructor + auto iter = range1.begin(); + auto limit = range2.end(); +@@ -155,9 +158,10 @@ void USetHeaderOnlyTest::TestUSetRangeIterator() { + void USetHeaderOnlyTest::TestUSetStringIterator() { + IcuTestErrorCode errorCode(*this, "TestUSetStringIterator"); + using U_HEADER_NESTED_NAMESPACE::USetStrings; +- LocalUSetPointer uset(uset_openPattern(u"[abcçカ🚴{}{abc}{de}]", -1, errorCode)); ++ std::unique_ptr uset( ++ uset_openPattern(u"[abcçカ🚴{}{abc}{de}]", -1, errorCode), &uset_close); + std::u16string result; +- for (auto s : USetStrings(uset.getAlias())) { ++ for (auto s : USetStrings(uset.get())) { + // Commented-out sample code for pasting into the API docs. + // Needs U_SHOW_CPLUSPLUS_API=1 for UnicodeString. + // UnicodeString us(s); +@@ -167,7 +171,7 @@ void USetHeaderOnlyTest::TestUSetStringIterator() { + } + assertEquals(WHERE, uR"( "" "abc" "de")", result); + +- USetStrings range1(uset.getAlias()); ++ USetStrings range1(uset.get()); + auto range2(range1); // copy constructor + auto iter = range1.begin(); + auto limit = range2.end(); +@@ -185,9 +189,10 @@ void USetHeaderOnlyTest::TestUSetStringIterator() { + void USetHeaderOnlyTest::TestUSetElementIterator() { + IcuTestErrorCode errorCode(*this, "TestUSetElementIterator"); + using U_HEADER_NESTED_NAMESPACE::USetElements; +- LocalUSetPointer uset(uset_openPattern(u"[abcçカ🚴{}{abc}{de}]", -1, errorCode)); ++ std::unique_ptr uset( ++ uset_openPattern(u"[abcçカ🚴{}{abc}{de}]", -1, errorCode), &uset_close); + std::u16string result; +- for (auto el : USetElements(uset.getAlias())) { ++ for (auto el : USetElements(uset.get())) { + // Commented-out sample code for pasting into the API docs. + // Needs U_SHOW_CPLUSPLUS_API=1 for UnicodeString. + // UnicodeString us(el); +@@ -197,7 +202,7 @@ void USetHeaderOnlyTest::TestUSetElementIterator() { + } + assertEquals(WHERE, uR"( "a" "b" "c" "ç" "カ" "🚴" "" "abc" "de")", result); + +- USetElements range1(uset.getAlias()); ++ USetElements range1(uset.get()); + auto range2(range1); // copy constructor + auto iter = range1.begin(); + auto limit = range2.end(); +-- +2.47.1 + diff --git a/programming/misc/icu4c/files/fedora/0007-ICU-22954-Delete-copy-assign-from-IcuTestErrorCode.patch b/programming/misc/icu4c/files/fedora/0007-ICU-22954-Delete-copy-assign-from-IcuTestErrorCode.patch new file mode 100644 index 0000000000..537d60cb51 --- /dev/null +++ b/programming/misc/icu4c/files/fedora/0007-ICU-22954-Delete-copy-assign-from-IcuTestErrorCode.patch @@ -0,0 +1,56 @@ +From b2a47f9aa47eeaa400018fec1849b0852ca74451 Mon Sep 17 00:00:00 2001 +From: Fredrik Roubert +Date: Mon, 30 Dec 2024 17:52:03 +0900 +Subject: [PATCH] ICU-22954 Delete copy & assign from IcuTestErrorCode. + +There's no reason to ever make a copy of these objects, existing code +that does this is doing it by mistake. +--- + icu4c/source/test/intltest/listformattertest.cpp | 2 +- + icu4c/source/test/intltest/listformattertest.h | 2 +- + icu4c/source/tools/ctestfw/unicode/testlog.h | 3 +++ + 3 files changed, 5 insertions(+), 2 deletions(-) + +diff --git a/icu4c/source/test/intltest/listformattertest.cpp b/icu4c/source/test/intltest/listformattertest.cpp +index 592137e39dd..bd6210266b9 100644 +--- icu4c/source/test/intltest/listformattertest.cpp ++++ icu4c/source/test/intltest/listformattertest.cpp +@@ -618,7 +618,7 @@ void ListFormatterTest::DoTheRealListStyleTesting( + UListFormatterType type, + UListFormatterWidth width, + const char* expected, +- IcuTestErrorCode status) { ++ IcuTestErrorCode& status) { + + LocalPointer formatter( + ListFormatter::createInstance(locale, type, width, status)); +diff --git a/icu4c/source/test/intltest/listformattertest.h b/icu4c/source/test/intltest/listformattertest.h +index 2c6860c1610..65d8aedfe89 100644 +--- icu4c/source/test/intltest/listformattertest.h ++++ icu4c/source/test/intltest/listformattertest.h +@@ -115,7 +115,7 @@ class ListFormatterTest : public IntlTestWithFieldPosition { + UListFormatterType type, + UListFormatterWidth width, + const char* expected, +- IcuTestErrorCode status); ++ IcuTestErrorCode& status); + + private: + // Reused test data. +diff --git a/icu4c/source/tools/ctestfw/unicode/testlog.h b/icu4c/source/tools/ctestfw/unicode/testlog.h +index 3951e729b74..a5e62e80d73 100644 +--- icu4c/source/tools/ctestfw/unicode/testlog.h ++++ icu4c/source/tools/ctestfw/unicode/testlog.h +@@ -37,6 +37,9 @@ class T_CTEST_EXPORT_API TestLog { + + class T_CTEST_EXPORT_API IcuTestErrorCode { + public: ++ IcuTestErrorCode(const IcuTestErrorCode&) = delete; ++ IcuTestErrorCode& operator=(const IcuTestErrorCode&) = delete; ++ + IcuTestErrorCode(TestLog &callingTestClass, const char *callingTestName) + : errorCode(U_ZERO_ERROR), + testClass(callingTestClass), testName(callingTestName), scopeMessage() {} +-- +2.47.1 + diff --git a/programming/misc/icu4c/files/fedora/0008-ICU-22954-Workaround-Replace-std-u16string-member-wi.patch b/programming/misc/icu4c/files/fedora/0008-ICU-22954-Workaround-Replace-std-u16string-member-wi.patch new file mode 100644 index 0000000000..e15112f7cc --- /dev/null +++ b/programming/misc/icu4c/files/fedora/0008-ICU-22954-Workaround-Replace-std-u16string-member-wi.patch @@ -0,0 +1,111 @@ +From df0422ed3fc945386c5633cb8f4717fdce31f9fb Mon Sep 17 00:00:00 2001 +From: Fredrik Roubert +Date: Mon, 30 Dec 2024 21:26:37 +0900 +Subject: [PATCH] ICU-22954 Workaround: Replace std::u16string member with + UnicodeString&. + +--- + icu4c/source/tools/ctestfw/tstdtmod.cpp | 12 +++++++++--- + icu4c/source/tools/ctestfw/unicode/testlog.h | 18 +++++++++++++----- + 2 files changed, 22 insertions(+), 8 deletions(-) + +diff --git a/icu4c/source/tools/ctestfw/tstdtmod.cpp b/icu4c/source/tools/ctestfw/tstdtmod.cpp +index 5a8e1ef7365..15e8913d2b8 100644 +--- icu4c/source/tools/ctestfw/tstdtmod.cpp ++++ icu4c/source/tools/ctestfw/tstdtmod.cpp +@@ -11,6 +11,7 @@ + #include + + #include "unicode/tstdtmod.h" ++#include "unicode/unistr.h" + #include "cmemory.h" + #include + #include "cstr.h" +@@ -18,11 +19,17 @@ + + TestLog::~TestLog() {} + ++IcuTestErrorCode::IcuTestErrorCode(TestLog &callingTestClass, const char *callingTestName) ++ : errorCode(U_ZERO_ERROR), ++ testClass(callingTestClass), testName(callingTestName), scopeMessage(*new UnicodeString) { ++} ++ + IcuTestErrorCode::~IcuTestErrorCode() { + // Safe because our errlog() does not throw exceptions. + if(isFailure()) { + errlog(false, u"destructor: expected success", nullptr); + } ++ delete &scopeMessage; + } + + UErrorCode IcuTestErrorCode::reset() { +@@ -119,8 +126,7 @@ UBool IcuTestErrorCode::expectErrorAndReset(UErrorCode expectedError, const char + } + + void IcuTestErrorCode::setScope(const char* message) { +- UnicodeString us(message, -1, US_INV); +- scopeMessage = us; ++ scopeMessage.remove().append({ message, -1, US_INV }); + } + + void IcuTestErrorCode::setScope(std::u16string_view message) { +@@ -136,7 +142,7 @@ void IcuTestErrorCode::errlog(UBool dataErr, std::u16string_view mainMessage, co + msg.append(u' ').append(mainMessage); + msg.append(u" but got error: ").append(UnicodeString(errorName(), -1, US_INV)); + +- if (!scopeMessage.empty()) { ++ if (!scopeMessage.isEmpty()) { + msg.append(u" scope: ").append(scopeMessage); + } + +diff --git a/icu4c/source/tools/ctestfw/unicode/testlog.h b/icu4c/source/tools/ctestfw/unicode/testlog.h +index a5e62e80d73..44e99954f91 100644 +--- icu4c/source/tools/ctestfw/unicode/testlog.h ++++ icu4c/source/tools/ctestfw/unicode/testlog.h +@@ -13,7 +13,6 @@ + #ifndef U_TESTFW_TESTLOG + #define U_TESTFW_TESTLOG + +-#include + #include + #include "unicode/utypes.h" + #include "unicode/testtype.h" +@@ -35,14 +34,16 @@ class T_CTEST_EXPORT_API TestLog { + // unit tests that work without U_SHOW_CPLUSPLUS_API. + // So instead we *copy* the ErrorCode API. + ++U_NAMESPACE_BEGIN ++class UnicodeString; ++U_NAMESPACE_END ++ + class T_CTEST_EXPORT_API IcuTestErrorCode { + public: + IcuTestErrorCode(const IcuTestErrorCode&) = delete; + IcuTestErrorCode& operator=(const IcuTestErrorCode&) = delete; + +- IcuTestErrorCode(TestLog &callingTestClass, const char *callingTestName) +- : errorCode(U_ZERO_ERROR), +- testClass(callingTestClass), testName(callingTestName), scopeMessage() {} ++ IcuTestErrorCode(TestLog &callingTestClass, const char *callingTestName); + virtual ~IcuTestErrorCode(); + + // ErrorCode API +@@ -75,7 +76,14 @@ class T_CTEST_EXPORT_API IcuTestErrorCode { + UErrorCode errorCode; + TestLog &testClass; + const char *const testName; +- std::u16string scopeMessage; ++ ++ // It's not possible to use a UnicodeString member directly here because ++ // that won't work without U_SHOW_CPLUSPLUS_API, but it's also not possible ++ // to use a std::u16string member because for unknown reasons that leads to ++ // a crash in the icu4c-windows-cygwin-gcc CI job. As a workaround, the ++ // UnicodeString class is forward declared to make it possible to use a ++ // reference here and then heap allocate the object in the constructor. ++ UnicodeString& scopeMessage; + + void errlog(UBool dataErr, std::u16string_view mainMessage, const char* extraMessage) const; + }; +-- +2.47.1 + diff --git a/programming/misc/icu4c/files/fedora/0009-ICU-22954-Revert-to-using-std-u16string-instead-of-U.patch b/programming/misc/icu4c/files/fedora/0009-ICU-22954-Revert-to-using-std-u16string-instead-of-U.patch new file mode 100644 index 0000000000..d5cc4ff3f4 --- /dev/null +++ b/programming/misc/icu4c/files/fedora/0009-ICU-22954-Revert-to-using-std-u16string-instead-of-U.patch @@ -0,0 +1,104 @@ +From 6f93c07a45e7fb1944fa0179591b36413312d16e Mon Sep 17 00:00:00 2001 +From: Fredrik Roubert +Date: Tue, 7 Jan 2025 19:15:44 +0900 +Subject: [PATCH] ICU-22954 Revert to using std::u16string instead of + UnicodeString. + +It seems as if icu4c-windows-cygwin-gcc only crashes if the constructor +is defined inline, so with the exception of the constructor this commit +reverts the code to commit 320220ef694123393a5c5d6eb6a1c7536fc57aba. +--- + icu4c/source/tools/ctestfw/tstdtmod.cpp | 9 ++++----- + icu4c/source/tools/ctestfw/unicode/testlog.h | 14 ++------------ + 2 files changed, 6 insertions(+), 17 deletions(-) + +diff --git a/icu4c/source/tools/ctestfw/tstdtmod.cpp b/icu4c/source/tools/ctestfw/tstdtmod.cpp +index 15e8913d2b8..66ab79a7db5 100644 +--- icu4c/source/tools/ctestfw/tstdtmod.cpp ++++ icu4c/source/tools/ctestfw/tstdtmod.cpp +@@ -11,7 +11,6 @@ + #include + + #include "unicode/tstdtmod.h" +-#include "unicode/unistr.h" + #include "cmemory.h" + #include + #include "cstr.h" +@@ -21,7 +20,7 @@ TestLog::~TestLog() {} + + IcuTestErrorCode::IcuTestErrorCode(TestLog &callingTestClass, const char *callingTestName) + : errorCode(U_ZERO_ERROR), +- testClass(callingTestClass), testName(callingTestName), scopeMessage(*new UnicodeString) { ++ testClass(callingTestClass), testName(callingTestName), scopeMessage() { + } + + IcuTestErrorCode::~IcuTestErrorCode() { +@@ -29,7 +28,6 @@ IcuTestErrorCode::~IcuTestErrorCode() { + if(isFailure()) { + errlog(false, u"destructor: expected success", nullptr); + } +- delete &scopeMessage; + } + + UErrorCode IcuTestErrorCode::reset() { +@@ -126,7 +124,8 @@ UBool IcuTestErrorCode::expectErrorAndReset(UErrorCode expectedError, const char + } + + void IcuTestErrorCode::setScope(const char* message) { +- scopeMessage.remove().append({ message, -1, US_INV }); ++ UnicodeString us(message, -1, US_INV); ++ scopeMessage = us; + } + + void IcuTestErrorCode::setScope(std::u16string_view message) { +@@ -142,7 +141,7 @@ void IcuTestErrorCode::errlog(UBool dataErr, std::u16string_view mainMessage, co + msg.append(u' ').append(mainMessage); + msg.append(u" but got error: ").append(UnicodeString(errorName(), -1, US_INV)); + +- if (!scopeMessage.isEmpty()) { ++ if (!scopeMessage.empty()) { + msg.append(u" scope: ").append(scopeMessage); + } + +diff --git a/icu4c/source/tools/ctestfw/unicode/testlog.h b/icu4c/source/tools/ctestfw/unicode/testlog.h +index 44e99954f91..1b5494bc3fe 100644 +--- icu4c/source/tools/ctestfw/unicode/testlog.h ++++ icu4c/source/tools/ctestfw/unicode/testlog.h +@@ -13,6 +13,7 @@ + #ifndef U_TESTFW_TESTLOG + #define U_TESTFW_TESTLOG + ++#include + #include + #include "unicode/utypes.h" + #include "unicode/testtype.h" +@@ -34,10 +35,6 @@ class T_CTEST_EXPORT_API TestLog { + // unit tests that work without U_SHOW_CPLUSPLUS_API. + // So instead we *copy* the ErrorCode API. + +-U_NAMESPACE_BEGIN +-class UnicodeString; +-U_NAMESPACE_END +- + class T_CTEST_EXPORT_API IcuTestErrorCode { + public: + IcuTestErrorCode(const IcuTestErrorCode&) = delete; +@@ -76,14 +73,7 @@ class T_CTEST_EXPORT_API IcuTestErrorCode { + UErrorCode errorCode; + TestLog &testClass; + const char *const testName; +- +- // It's not possible to use a UnicodeString member directly here because +- // that won't work without U_SHOW_CPLUSPLUS_API, but it's also not possible +- // to use a std::u16string member because for unknown reasons that leads to +- // a crash in the icu4c-windows-cygwin-gcc CI job. As a workaround, the +- // UnicodeString class is forward declared to make it possible to use a +- // reference here and then heap allocate the object in the constructor. +- UnicodeString& scopeMessage; ++ std::u16string scopeMessage; + + void errlog(UBool dataErr, std::u16string_view mainMessage, const char* extraMessage) const; + }; +-- +2.47.1 + diff --git a/programming/misc/icu4c/files/gennorm2-man.patch b/programming/misc/icu4c/files/gennorm2-man.patch new file mode 100644 index 0000000000..07b5b9d32f --- /dev/null +++ b/programming/misc/icu4c/files/gennorm2-man.patch @@ -0,0 +1,128 @@ +Description: supply manual page for program that doesn't have one +Author: Jay Berkenbilt +Bug: http://bugs.icu-project.org/trac/ticket/7554 + +diff -r -u -N icu.orig/source/tools/gennorm2/gennorm2.8.in icu/source/tools/gennorm2/gennorm2.8.in +--- icu.orig/source/tools/gennorm2/gennorm2.8.in 1970-01-01 01:00:00.000000000 +0100 ++++ icu/source/tools/gennorm2/gennorm2.8.in 2013-02-25 16:43:28.297062638 +0100 +@@ -0,0 +1,71 @@ ++.\" Hey, Emacs! This is -*-nroff-*- you know... ++.\" ++.\" gennorm2.8: manual page for the gennorm2 utility ++.\" ++.\" Copyright (C) 2005-2006 International Business Machines Corporation and others ++.\" ++.TH GENNORM2 8 "15 March 2010" "ICU MANPAGE" "ICU @VERSION@ Manual" ++.SH NAME ++.B gennorm2 ++\- Builds binary data file with Unicode normalization data. ++.SH SYNOPSIS ++.B gennorm2 ++[ ++.BR "\-h\fP, \fB\-?\fP, \fB\-\-help" ++] ++[ ++.BR "\-V\fP, \fB\-\-version" ++] ++[ ++.BR "\-c\fP, \fB\-\-copyright" ++] ++[ ++.BR "\-v\fP, \fB\-\-verbose" ++] ++[ ++.BI "\-u\fP, \fB\-\-unicode" " unicode\-version\-number" ++] ++[ ++.BI "\-s\fP, \fB\-\-sourcedir" " source\-directory" ++] ++[ ++.BI "\-o\fP, \fB\-\-output" " output\-filename" ++] ++.BI "\fB\-\-fast" ++.SH DESCRIPTION ++.B gennorm2 ++reads text files that define Unicode normalization, ++them, and builds a binary data file. ++.SH OPTIONS ++.TP ++.BR "\-h\fP, \fB\-?\fP, \fB\-\-help" ++Print help about usage and exit. ++.TP ++.BR "\-V\fP, \fB\-\-version" ++Print the version of ++.B gennorm2 ++and exit. ++.TP ++.BR "\-c\fP, \fB\-\-copyright" ++Include a copyright notice. ++.TP ++.BR "\-v\fP, \fB\-\-verbose" ++Display extra informative messages during execution. ++.TP ++.BR "\-u\fP, \fB\-\-unicode" ++Specify Unicode version number, such as 5.2.0. ++.TP ++.BI "\-s\fP, \fB\-\-sourcedir" " source\-directory" ++Specify the input directory. ++.TP ++.BI "\-s\fP, \fB\-\-sourcedir" " source\-directory" ++Set the name of the output file. ++.TP ++.BI "\fB\-\-fast" ++optimize the .nrm file for fast normalization, ++which might increase its size (Writes fully decomposed ++regular mappings instead of delta mappings. ++You should measure the runtime speed to make sure that ++this is a good trade-off.) ++.SH COPYRIGHT ++Copyright (C) 2009-2010 International Business Machines Corporation and others +diff -r -u -N icu.orig/source/tools/gennorm2/Makefile.in icu/source/tools/gennorm2/Makefile.in +--- icu.orig/source/tools/gennorm2/Makefile.in 2013-01-11 01:23:32.000000000 +0100 ++++ icu/source/tools/gennorm2/Makefile.in 2013-02-25 16:43:28.296062632 +0100 +@@ -16,8 +16,13 @@ + + TARGET_STUB_NAME = gennorm2 + ++SECTION = 8 ++ ++MAN_FILES = $(TARGET_STUB_NAME).$(SECTION) ++ ++ + ## Extra files to remove for 'make clean' +-CLEANFILES = *~ $(DEPS) ++CLEANFILES = *~ $(DEPS) $(MAN_FILES) + + ## Target information + TARGET = $(BINDIR)/$(TARGET_STUB_NAME)$(EXEEXT) +@@ -44,12 +49,16 @@ + dist: dist-local + check: all check-local + +-all-local: $(TARGET) ++all-local: $(TARGET) $(MAN_FILES) + +-install-local: all-local ++install-local: all-local install-man + $(MKINSTALLDIRS) $(DESTDIR)$(sbindir) + $(INSTALL) $(TARGET) $(DESTDIR)$(sbindir) + ++install-man: $(MAN_FILES) ++ $(MKINSTALLDIRS) $(DESTDIR)$(mandir)/man$(SECTION) ++ $(INSTALL_DATA) $? $(DESTDIR)$(mandir)/man$(SECTION) ++ + dist-local: + + clean-local: +@@ -70,6 +79,11 @@ + $(POST_BUILD_STEP) + + ++%.$(SECTION): $(srcdir)/%.$(SECTION).in ++ cd $(top_builddir) \ ++ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status ++ ++ + ifeq (,$(MAKECMDGOALS)) + -include $(DEPS) + else diff --git a/programming/misc/icu4c/files/icuinfo-man.patch b/programming/misc/icu4c/files/icuinfo-man.patch new file mode 100644 index 0000000000..987e87994e --- /dev/null +++ b/programming/misc/icu4c/files/icuinfo-man.patch @@ -0,0 +1,145 @@ +Description: supply manual page for program that doesn't have one +Author: Jay Berkenbilt +Bug: http://bugs.icu-project.org/trac/ticket/7665 +erAck: adapted to ICU 56.1 icu/source/tools/icuinfo/Makefile.in + +diff -Nur orig.icu/source/tools/icuinfo/icuinfo.1.in icu/source/tools/icuinfo/icuinfo.1.in +--- orig.icu/source/tools/icuinfo/icuinfo.1.in 1970-01-01 01:00:00.000000000 +0100 ++++ icu/source/tools/icuinfo/icuinfo.1.in 2015-10-27 19:19:35.184056800 +0100 +@@ -0,0 +1,76 @@ ++.\" Hey, Emacs! This is -*-nroff-*- you know... ++.\" ++.\" icuinfo.1: manual page for the icuinfo utility ++.\" ++.\" Copyright (C) 2005-2006 International Business Machines Corporation and others ++.\" ++.TH ICUINFO 1 "1 May 2010" "ICU MANPAGE" "ICU @VERSION@ Manual" ++.SH NAME ++.B icuinfo ++\- Shows some basic info about the current ICU ++.SH SYNOPSIS ++.B icuinfo ++[ ++.BR "\-h\fP, \fB\-?\fP, \fB\-\-help" ++] ++[ ++.BR "\-V\fP, \fB\-\-version" ++] ++[ ++.BR "\-c\fP, \fB\-\-copyright" ++] ++[ ++.BI "\-i\fP, \fB\-\-icudatadir" " directory" ++] ++[ ++.BR "\-v\fP, \fB\-\-verbose" ++] ++[ ++.BI "\-L\fP, \fB\-\-list-plugins" ++] ++[ ++.BI "\-m\fP, \fB\-\-milisecond-time" ++] ++[ ++.BI "\-K\fP, \fB\-\-cleanup" ++] ++.SH DESCRIPTION ++.B icuinfo ++prints basic information about the current version of ICU. ++.SH OPTIONS ++.TP ++.BR "\-h\fP, \fB\-?\fP, \fB\-\-help" ++Print help about usage and exit. ++.TP ++.BR "\-V\fP, \fB\-\-version" ++Print the version of ++.B icuinfo ++and exit. ++.TP ++.BR "\-c\fP, \fB\-\-copyright" ++Embeds the standard ICU copyright into the ++.IR output-file . ++.TP ++.BR "\-v\fP, \fB\-\-verbose" ++Display extra informative messages during execution. ++.TP ++.BI "\-i\fP, \fB\-\-icudatadir" " directory" ++Look for any necessary ICU data files in ++.IR directory . ++For example, the file ++.B pnames.icu ++must be located when ICU's data is not built as a shared library. ++The default ICU data directory is specified by the environment variable ++.BR ICU_DATA . ++Most configurations of ICU do not require this argument. ++.TP ++.BI "\-L\fP, \fB\-\-list-plugins" ++If specified, list and diagnose issues with ICU plugins. ++.TP ++.BI "\-K\fP, \fB\-\-cleanup" ++Attempt to unload plugins before exiting. ++.TP ++.BI "\-m\fP, \fB\-\-milisecond-time" ++Print the current UTC time in milliseconds. ++.SH COPYRIGHT ++Copyright (C) 2010 International Business Machines Corporation and others +diff -Nur orig.icu/source/tools/icuinfo/Makefile.in icu/source/tools/icuinfo/Makefile.in +--- orig.icu/source/tools/icuinfo/Makefile.in 2015-10-08 05:53:56.000000000 +0200 ++++ icu/source/tools/icuinfo/Makefile.in 2015-10-27 19:23:19.115509906 +0100 +@@ -14,8 +14,15 @@ + ## Build directory information + subdir = tools/icuinfo + ++TARGET_STUB_NAME = icuinfo ++ ++SECTION = 1 ++ ++MAN_FILES = $(TARGET_STUB_NAME).$(SECTION) ++ ++ + ## Extra files to remove for 'make clean' +-CLEANFILES = *~ $(DEPS) $(PLUGIN_OBJECTS) $(PLUGINFILE) $(PLUGIN) ++CLEANFILES = *~ $(DEPS) $(PLUGIN_OBJECTS) $(PLUGINFILE) $(PLUGIN) $(MAN_FILES) + + ## Target information + TARGET = icuinfo$(EXEEXT) +@@ -35,7 +42,8 @@ + + ## List of phony targets + .PHONY : all all-local install install-local clean clean-local \ +-distclean distclean-local dist dist-local check check-local plugin-check ++distclean distclean-local dist dist-local check check-local plugin-check \ ++install-man + + ## Clear suffix list + .SUFFIXES : +@@ -48,12 +56,16 @@ + dist: dist-local + check: all check-local + +-all-local: $(TARGET) ++all-local: $(TARGET) $(MAN_FILES) + +-install-local: all-local ++install-local: all-local install-man + $(MKINSTALLDIRS) $(DESTDIR)$(bindir) + $(INSTALL) $(TARGET) $(DESTDIR)$(bindir) + ++install-man: $(MAN_FILES) ++ $(MKINSTALLDIRS) $(DESTDIR)$(mandir)/man$(SECTION) ++ $(INSTALL_DATA) $? $(DESTDIR)$(mandir)/man$(SECTION) ++ + dist-local: + + clean-local: +@@ -103,6 +115,10 @@ + @echo "Plugins are disabled (use --enable-plugins to enable)" + endif + ++%.$(SECTION): $(srcdir)/%.$(SECTION).in ++ cd $(top_builddir) \ ++ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status ++ + ifeq (,$(MAKECMDGOALS)) + -include $(DEPS) + else diff --git a/programming/misc/icu4c/pspec.xml b/programming/misc/icu4c/pspec.xml index 5d0f2b4236..54bd84794d 100644 --- a/programming/misc/icu4c/pspec.xml +++ b/programming/misc/icu4c/pspec.xml @@ -14,12 +14,23 @@ ICU is a mature, widely used set of C/C++ and Java libraries for Unicode support, software internationalization and globalization (i18n/g11n). This package contains the C/C++ libraries. - https://github.com/unicode-org/icu/releases/download/release-73-2/icu4c-73_2-src.tgz + https://github.com/unicode-org/icu/releases/download/release-76-1/icu4c-76_1-src.tgz libgcc - + + + + fedora/0001-ICU-22954-USet-C-iterator-return-std-u16string.patch + fedora/0002-ICU-22954-U_ICU_NAMESPACE_OR_INTERNAL-header-only-lo.patch + fedora/0003-ICU-22954-intltest.h-IcuTestErrorCode-usable-without.patch + fedora/0004-ICU-22954-header-only-test-USet-C-iterators.patch + fedora/0005-ICU-22954-Partially-revert-PR-3295-U_ICU_NAMESPACE_O.patch + fedora/0006-ICU-22954-USetHeaderOnlyTest-use-unique_ptr.patch + fedora/0007-ICU-22954-Delete-copy-assign-from-IcuTestErrorCode.patch + fedora/0008-ICU-22954-Workaround-Replace-std-u16string-member-wi.patch + fedora/0009-ICU-22954-Revert-to-using-std-u16string-instead-of-U.patch @@ -72,6 +83,13 @@ + + 2025-02-23 + 76.1 + Version bump. + Mustafa Cinasal + muscnsl@gmail.com + 2023-10-16 73.2