Skip to content

Commit

Permalink
Merge branch 'surili' into 𒅗𒇻𒋗𒉑
Browse files Browse the repository at this point in the history
  • Loading branch information
eggrobin committed Jan 21, 2025
2 parents e504948 + 3718cf9 commit f880cf0
Show file tree
Hide file tree
Showing 200 changed files with 2,221 additions and 1,595 deletions.
31 changes: 31 additions & 0 deletions docs/processes/release/tasks/healthy-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,37 @@ the UTF-8 signature byte sequence ("BOM").~~
## Clean up import statements
### From command line
This can be done from command line using the
[Google Java Format](https://github.com/google/google-java-format) tool.
**WARNING:** requires JDK 17 or newer (December 2024)
Download the latest Google Java Format from Maven Central:
```sh
mvn dependency:copy -Dartifact=com.google.googlejavaformat:google-java-format:LATEST:jar:all-deps \
-DoutputDirectory=/tmp \
-Dmdep.stripVersion=true \
-q -ntp
```
Cleanup all Java files (only imports, nothing else):
```sh
find . -type f -name '*.java' | xargs java -jar /tmp/google-java-format-all-deps.jar -i --aosp --fix-imports-only --skip-sorting-imports
```
Remove the Google Java Format artifact from the temporary folder:
```sh
rm /tmp/google-java-format-all-deps.jar
```
You can (of course) download it from
[GitHub Releases](https://github.com/google/google-java-format/releases). \
Or save it in a personal tools folder and keep it around.
### From Eclipse
The Eclipse IDE provides a feature which allow you to organize import statements
for multiple files. Right click on projects/source folders/files, you can select
\[Source\] - \[Organize Imports\] which resolve all wildcard imports and sort
Expand Down
10 changes: 6 additions & 4 deletions docs/processes/release/tasks/versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ need to be correspondingly updated. See below for more files to be updated and s
[icu4c/source/data/misc/icuver.txt](https://github.com/unicode-org/icu/blob/main/icu4c/source/data/misc/icuver.txt)
needs to be updated with the correct version number for ICU and its data.

### CLDR-to-ICU Conversion

#### Since ICU 77

The tool takes the `icuVersion` and `icuDataVersion` from the official ICU APIs.
Expand Down Expand Up @@ -171,7 +173,7 @@ Changing the version for Java starting with ICU 74 requires a few steps:
2. [icu4j/main/core/src/test/java/com/ibm/icu/dev/test/util/DebugUtilitiesData.java](https://github.com/unicode-org/icu/blob/main/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/util/DebugUtilitiesData.java)

There is a public string named `ICU4C_VERSION` which should be updated accordingly.
'public static final String ICU4C_VERSION="74.0.1";'
`public static final String ICU4C_VERSION="74.0.1";`

3. When creating the final release of a major ICU version,
or a point release (minor version update on a maintenance branch),
Expand Down Expand Up @@ -208,7 +210,7 @@ The command requires a version number string that follows the typical Java / Mav
This should happen at the same time and along with the work in the previous step for the version number
when the version number is updated on `main` in the commit after the release/maintanence branch is cut.
In other words, the above `versions:set-property` step should be executed at the same time
`mvn versions:set -DnewVersion=74.0.1-SNAPSHOT` is executed.
`mvn versions:set -DnewVersion=74.0.1-SNAPSHOT -DgenerateBackupPoms=false` is executed.
5. Update the following variables in `icu4j/releases_tools/shared.sh`
Expand All @@ -229,7 +231,7 @@ Since ICU 77 this moved to a property:
```
Which can be easily be set from command line:
```sh
mvn versions:set-property -Dproperty=icu4j.version -DnewVersion=77.1 -f $ICU_DIR/tools/cldr/cldr-to-icu
mvn versions:set-property -Dproperty=icu4j.version -DnewVersion=77.1 -f $ICU_DIR/tools/cldr/cldr-to-icu -DgenerateBackupPoms=false
```

#### Until ICU 73 (inclusive)
Expand Down Expand Up @@ -291,7 +293,7 @@ For updating ICU version numbers, follow the steps below.
3. [icu4j/main/core/src/main/java/com/ibm/icu/util/VersionInfo.java](https://github.com/unicode-org/icu/blob/main/icu4j/main/core/src/main/java/com/ibm/icu/util/VersionInfo.java)

There is a static block starting at line 501 (as of 54.1) in the source file.

Update the `ICU_VERSION` value, where the first three arguments represent the
major, minor, and patch versions of a semantic version.
Use the `getInstance(major, 0, 1, 0)` as the version during pre-release development,
Expand Down
2 changes: 1 addition & 1 deletion icu4c/source/allinone/Build.Windows.IcuVersion.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- This file is used to set the ICU Major Version number, which is used as a suffix on various file names in other Visual Studio projects. -->
<PropertyGroup>
<IcuMajorVersion>76</IcuMajorVersion>
<IcuMajorVersion>77</IcuMajorVersion>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions icu4c/source/common/characterproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "umutex.h"
#include "uprops.h"

using icu::LocalPointer;
using U_ICU_NAMESPACE_OR_INTERNAL::LocalPointer;
#if !UCONFIG_NO_NORMALIZATION
using icu::Normalizer2Factory;
using icu::Normalizer2Impl;
Expand Down Expand Up @@ -340,7 +340,7 @@ UnicodeSet *makeSet(UProperty property, UErrorCode &errorCode) {
UCPMap *makeMap(UProperty property, UErrorCode &errorCode) {
if (U_FAILURE(errorCode)) { return nullptr; }
uint32_t nullValue = property == UCHAR_SCRIPT ? USCRIPT_UNKNOWN : 0;
icu::LocalUMutableCPTriePointer mutableTrie(
U_ICU_NAMESPACE_OR_INTERNAL::LocalUMutableCPTriePointer mutableTrie(
umutablecptrie_open(nullValue, nullValue, &errorCode));
const UnicodeSet *inclusions =
icu::CharacterProperties::getInclusionsForProperty(property, errorCode);
Expand Down
3 changes: 2 additions & 1 deletion icu4c/source/common/locavailable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ UBool U_CALLCONV uloc_cleanup() {
void U_CALLCONV loadInstalledLocales(UErrorCode& status) {
ucln_common_registerCleanup(UCLN_COMMON_ULOC, uloc_cleanup);

icu::LocalUResourceBundlePointer rb(ures_openDirect(nullptr, "res_index", &status));
U_ICU_NAMESPACE_OR_INTERNAL::LocalUResourceBundlePointer rb(
ures_openDirect(nullptr, "res_index", &status));
AvailableLocalesSink sink;
ures_getAllItemsWithFallback(rb.getAlias(), "", sink, status);
}
Expand Down
17 changes: 10 additions & 7 deletions icu4c/source/common/locdispnames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#include "ureslocs.h"
#include "ustr_imp.h"

using U_ICU_NAMESPACE_OR_INTERNAL::LocalUEnumerationPointer;
using U_ICU_NAMESPACE_OR_INTERNAL::LocalUResourceBundlePointer;

// C++ API ----------------------------------------------------------------- ***

U_NAMESPACE_BEGIN
Expand Down Expand Up @@ -313,7 +316,7 @@ _getStringOrCopyKey(const char *path, const char *locale,

if(itemKey==nullptr) {
/* top-level item: normal resource bundle access */
icu::LocalUResourceBundlePointer rb(ures_open(path, locale, &errorCode));
LocalUResourceBundlePointer rb(ures_open(path, locale, &errorCode));

if(U_SUCCESS(errorCode)) {
s=ures_getStringByKey(rb.getAlias(), tableKey, &length, &errorCode);
Expand Down Expand Up @@ -539,9 +542,9 @@ uloc_getDisplayName(const char *locale,
{
UErrorCode status = U_ZERO_ERROR;

icu::LocalUResourceBundlePointer locbundle(
LocalUResourceBundlePointer locbundle(
ures_open(U_ICUDATA_LANG, displayLocale, &status));
icu::LocalUResourceBundlePointer dspbundle(
LocalUResourceBundlePointer dspbundle(
ures_getByKeyWithFallback(locbundle.getAlias(), _kLocaleDisplayPattern, nullptr, &status));

separator=ures_getStringByKeyWithFallback(dspbundle.getAlias(), _kSeparator, &sepLen, &status);
Expand Down Expand Up @@ -613,7 +616,7 @@ uloc_getDisplayName(const char *locale,
int32_t langPos=0; /* position in output of language substitution */
int32_t restLen=0; /* length of 'everything else' substitution */
int32_t restPos=0; /* position in output of 'everything else' substitution */
icu::LocalUEnumerationPointer kenum; /* keyword enumeration */
LocalUEnumerationPointer kenum; /* keyword enumeration */

/* prefix of pattern, extremely likely to be empty */
if(sub0Pos) {
Expand Down Expand Up @@ -855,11 +858,11 @@ uloc_getDisplayKeywordValue( const char* locale,
int32_t dispNameLen = 0;
const char16_t *dispName = nullptr;

icu::LocalUResourceBundlePointer bundle(
LocalUResourceBundlePointer bundle(
ures_open(U_ICUDATA_CURR, displayLocale, status));
icu::LocalUResourceBundlePointer currencies(
LocalUResourceBundlePointer currencies(
ures_getByKey(bundle.getAlias(), _kCurrencies, nullptr, status));
icu::LocalUResourceBundlePointer currency(
LocalUResourceBundlePointer currency(
ures_getByKeyWithFallback(currencies.getAlias(), keywordValue.data(), nullptr, status));

dispName = ures_getStringByIndex(currency.getAlias(), UCURRENCY_DISPLAY_NAME_INDEX, &dispNameLen, status);
Expand Down
3 changes: 2 additions & 1 deletion icu4c/source/common/locresdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ uloc_getTableStringWithFallback(const char *path, const char *locale,
* this falls back through the locale's chain to root
*/
errorCode=U_ZERO_ERROR;
icu::LocalUResourceBundlePointer rb(ures_open(path, locale, &errorCode));
U_ICU_NAMESPACE_OR_INTERNAL::LocalUResourceBundlePointer rb(
ures_open(path, locale, &errorCode));

if(U_FAILURE(errorCode)) {
/* total failure, not even root could be opened */
Expand Down
3 changes: 2 additions & 1 deletion icu4c/source/common/locutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ LocaleUtility::getAvailableLocaleNames(const UnicodeString& bundleID)
CharString cbundleID;
cbundleID.appendInvariantChars(bundleID, status);
const char* path = cbundleID.isEmpty() ? nullptr : cbundleID.data();
icu::LocalUEnumerationPointer uenum(ures_openAvailableLocales(path, &status));
U_ICU_NAMESPACE_OR_INTERNAL::LocalUEnumerationPointer uenum(
ures_openAvailableLocales(path, &status));
for (;;) {
const char16_t* id = uenum_unext(uenum.getAlias(), nullptr, &status);
if (id == nullptr) {
Expand Down
25 changes: 12 additions & 13 deletions icu4c/source/common/uloc_tag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
#include "ulocimp.h"
#include "uassert.h"

using U_ICU_NAMESPACE_OR_INTERNAL::LocalPointer;
using U_ICU_NAMESPACE_OR_INTERNAL::LocalUEnumerationPointer;

namespace {

/* struct holding a single variant */
Expand Down Expand Up @@ -354,10 +357,6 @@ const char*
ultag_getLegacy(const ULanguageTag* langtag);
#endif

} // namespace

U_NAMESPACE_BEGIN

/**
* \class LocalULanguageTagPointer
* "Smart pointer" class, closes a ULanguageTag via ultag_close().
Expand All @@ -369,7 +368,7 @@ U_NAMESPACE_BEGIN
*/
U_DEFINE_LOCAL_OPEN_POINTER(LocalULanguageTagPointer, ULanguageTag, ultag_close);

U_NAMESPACE_END
} // namespace

/*
* -------------------------------------------------
Expand Down Expand Up @@ -869,7 +868,7 @@ namespace {
*/

bool
_addVariantToList(VariantListEntry **first, icu::LocalPointer<VariantListEntry> var) {
_addVariantToList(VariantListEntry **first, LocalPointer<VariantListEntry> var) {
if (*first == nullptr) {
var->next = nullptr;
*first = var.orphan();
Expand Down Expand Up @@ -1212,7 +1211,7 @@ _appendVariantsToLanguageTag(std::string_view localeID, icu::ByteSink& sink, boo
if (_isVariantSubtag(pVar, -1)) {
if (uprv_strcmp(pVar, POSIX_VALUE) || buf.length() != static_cast<int32_t>(uprv_strlen(POSIX_VALUE))) {
/* emit the variant to the list */
icu::LocalPointer<VariantListEntry> var(new VariantListEntry, status);
LocalPointer<VariantListEntry> var(new VariantListEntry, status);
if (U_FAILURE(status)) {
break;
}
Expand Down Expand Up @@ -1284,7 +1283,7 @@ _appendKeywordsToLanguageTag(const char* localeID, icu::ByteSink& sink, bool str
icu::MemoryPool<ExtensionListEntry> extPool;
icu::MemoryPool<icu::CharString> strPool;

icu::LocalUEnumerationPointer keywordEnum(uloc_openKeywords(localeID, &status));
LocalUEnumerationPointer keywordEnum(uloc_openKeywords(localeID, &status));
if (U_FAILURE(status) && !hadPosix) {
return;
}
Expand Down Expand Up @@ -1984,7 +1983,7 @@ ultag_parse(const char* tag, int32_t tagLen, int32_t* parsedLen, UErrorCode& sta
char *pSubtag, *pNext, *pLastGoodPosition;
int32_t subtagLen;
int32_t extlangIdx;
icu::LocalPointer<ExtensionListEntry> pExtension;
LocalPointer<ExtensionListEntry> pExtension;
char *pExtValueSubtag, *pExtValueSubtagEnd;
int32_t i;
bool privateuseVar = false;
Expand All @@ -2011,7 +2010,7 @@ ultag_parse(const char* tag, int32_t tagLen, int32_t* parsedLen, UErrorCode& sta
*(tagBuf + tagLen) = 0;

/* create a ULanguageTag */
icu::LocalULanguageTagPointer t(
LocalULanguageTagPointer t(
static_cast<ULanguageTag*>(uprv_malloc(sizeof(ULanguageTag))));
if (t.isNull()) {
uprv_free(tagBuf);
Expand Down Expand Up @@ -2197,7 +2196,7 @@ ultag_parse(const char* tag, int32_t tagLen, int32_t* parsedLen, UErrorCode& sta
if (next & VART) {
if (_isVariantSubtag(pSubtag, subtagLen) ||
(privateuseVar && _isPrivateuseVariantSubtag(pSubtag, subtagLen))) {
icu::LocalPointer<VariantListEntry> var(new VariantListEntry, status);
LocalPointer<VariantListEntry> var(new VariantListEntry, status);
if (U_FAILURE(status)) {
return nullptr;
}
Expand Down Expand Up @@ -2609,7 +2608,7 @@ ulocimp_toLanguageTag(const char* localeID,
int kwdCnt = 0;
bool done = false;

icu::LocalUEnumerationPointer kwdEnum(uloc_openKeywords(canonical.data(), &tmpStatus));
LocalUEnumerationPointer kwdEnum(uloc_openKeywords(canonical.data(), &tmpStatus));
if (U_SUCCESS(tmpStatus)) {
kwdCnt = uenum_count(kwdEnum.getAlias(), &tmpStatus);
if (kwdCnt == 1) {
Expand Down Expand Up @@ -2691,7 +2690,7 @@ ulocimp_forLanguageTag(const char* langtag,
int32_t i, n;
bool noRegion = true;

icu::LocalULanguageTagPointer lt(ultag_parse(langtag, tagLen, parsedLength, status));
LocalULanguageTagPointer lt(ultag_parse(langtag, tagLen, parsedLength, status));
if (U_FAILURE(status)) {
return;
}
Expand Down
51 changes: 47 additions & 4 deletions icu4c/source/common/unicode/char16ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@

#include "unicode/utypes.h"

#if U_SHOW_CPLUSPLUS_API
#if U_SHOW_CPLUSPLUS_API || U_SHOW_CPLUSPLUS_HEADER_API

#include <cstddef>
#include <string_view>
#include <type_traits>

#endif

/**
* \file
Expand All @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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<typename T, typename = std::enable_if_t<std::is_same_v<T, UChar>>>
inline const char16_t *uprv_char16PtrFromUChar(const T *p) {
if constexpr (std::is_same_v<UChar, char16_t>) {
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<const char16_t *>(p);
#endif
}
}
#endif

/**
* Converts from const char16_t * to const UChar *.
* Includes an aliasing barrier if available.
Expand Down Expand Up @@ -307,6 +341,15 @@ inline OldUChar *toOldUCharPtr(char16_t *p) {
return reinterpret_cast<OldUChar *>(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?
Expand Down Expand Up @@ -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__
Loading

0 comments on commit f880cf0

Please sign in to comment.