diff options
author | romankoshelev <romankoshelev@yandex-team.com> | 2023-08-14 19:51:50 +0300 |
---|---|---|
committer | romankoshelev <romankoshelev@yandex-team.com> | 2023-08-15 01:24:11 +0300 |
commit | cfcd865e05c0d0525ea27d1e153a043b32a85138 (patch) | |
tree | 68d3b3b25271e8a4998505897a269ff7ce119b76 /contrib/libs/icu/i18n/measunit_extra.cpp | |
parent | ccb790c507bd5e8ffe2ef9886ce5ee0a7ce22a15 (diff) | |
download | ydb-cfcd865e05c0d0525ea27d1e153a043b32a85138.tar.gz |
Update ICU to 73.2
Diffstat (limited to 'contrib/libs/icu/i18n/measunit_extra.cpp')
-rw-r--r-- | contrib/libs/icu/i18n/measunit_extra.cpp | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/contrib/libs/icu/i18n/measunit_extra.cpp b/contrib/libs/icu/i18n/measunit_extra.cpp index 8281119007..295d6a8ce8 100644 --- a/contrib/libs/icu/i18n/measunit_extra.cpp +++ b/contrib/libs/icu/i18n/measunit_extra.cpp @@ -148,7 +148,7 @@ const struct UnitPrefixStrings { * int32_t *unitCategories[ARR_SIZE]; * SimpleUnitIdentifiersSink identifierSink(gSerializedUnitCategoriesTrie, unitIdentifiers, * unitCategories, ARR_SIZE, b, kTrieValueOffset); - * LocalUResourceBundlePointer unitsBundle(ures_openDirect(NULL, "units", &status)); + * LocalUResourceBundlePointer unitsBundle(ures_openDirect(nullptr, "units", &status)); * ures_getAllItemsWithFallback(unitsBundle.getAlias(), "convertUnits", identifierSink, status); */ class SimpleUnitIdentifiersSink : public icu::ResourceSink { @@ -220,7 +220,7 @@ class SimpleUnitIdentifiersSink : public icu::ResourceSink { break; } int32_t len; - const UChar* uTarget = value.getString(len, status); + const char16_t* uTarget = value.getString(len, status); CharString target; target.appendInvariantChars(uTarget, len, status); if (U_FAILURE(status)) { return; } @@ -255,15 +255,15 @@ class SimpleUnitIdentifiersSink : public icu::ResourceSink { * * For example: "kilogram" -> "mass", "meter-per-second" -> "speed". * - * In C++ unitQuantity values are collected in order into a UChar* array, while + * In C++ unitQuantity values are collected in order into a char16_t* array, while * unitQuantity keys are added added to a TrieBuilder, with associated values - * being the index into the aforementioned UChar* array. + * being the index into the aforementioned char16_t* array. */ class CategoriesSink : public icu::ResourceSink { public: /** * Constructor. - * @param out Array of UChar* to which unitQuantity values will be saved. + * @param out Array of char16_t* to which unitQuantity values will be saved. * The pointers returned not owned: they point directly at the resource * strings in static memory. * @param outSize The size of the `out` array. @@ -271,7 +271,7 @@ class CategoriesSink : public icu::ResourceSink { * each unitQuantity will be added, each with value being the offset * into `out`. */ - explicit CategoriesSink(const UChar **out, int32_t &outSize, BytesTrieBuilder &trieBuilder) + explicit CategoriesSink(const char16_t **out, int32_t &outSize, BytesTrieBuilder &trieBuilder) : outQuantitiesArray(out), outSize(outSize), trieBuilder(trieBuilder), outIndex(0) {} void put(const char * /*key*/, ResourceValue &value, UBool /*noFallback*/, UErrorCode &status) override { @@ -305,14 +305,14 @@ class CategoriesSink : public icu::ResourceSink { } private: - const UChar **outQuantitiesArray; + const char16_t **outQuantitiesArray; int32_t &outSize; BytesTrieBuilder &trieBuilder; int32_t outIndex; }; -icu::UInitOnce gUnitExtrasInitOnce = U_INITONCE_INITIALIZER; +icu::UInitOnce gUnitExtrasInitOnce {}; // Array of simple unit IDs. // @@ -327,11 +327,11 @@ int32_t *gSimpleUnitCategories = nullptr; char *gSerializedUnitExtrasStemTrie = nullptr; -// Array of UChar* pointing at the unit categories (aka "quantities", aka +// Array of char16_t* pointing at the unit categories (aka "quantities", aka // "types"), as found in the `unitQuantities` resource. The array memory itself -// is owned by this pointer, but the individual UChar* in that array point at +// is owned by this pointer, but the individual char16_t* in that array point at // static memory. -const UChar **gCategories = nullptr; +const char16_t **gCategories = nullptr; // Number of items in `gCategories`. int32_t gCategoriesCount = 0; // Serialized BytesTrie for mapping from base units to indices into gCategories. @@ -349,7 +349,7 @@ UBool U_CALLCONV cleanupUnitExtras() { uprv_free(gSimpleUnits); gSimpleUnits = nullptr; gUnitExtrasInitOnce.reset(); - return TRUE; + return true; } void U_CALLCONV initUnitExtras(UErrorCode& status) { @@ -362,8 +362,8 @@ void U_CALLCONV initUnitExtras(UErrorCode& status) { ures_getByKey(unitsBundle.getAlias(), CATEGORY_TABLE_NAME, nullptr, &status)); if (U_FAILURE(status)) { return; } gCategoriesCount = unitQuantities.getAlias()->fSize; - size_t quantitiesMallocSize = sizeof(UChar *) * gCategoriesCount; - gCategories = static_cast<const UChar **>(uprv_malloc(quantitiesMallocSize)); + size_t quantitiesMallocSize = sizeof(char16_t *) * gCategoriesCount; + gCategories = static_cast<const char16_t **>(uprv_malloc(quantitiesMallocSize)); if (gCategories == nullptr) { status = U_MEMORY_ALLOCATION_ERROR; return; @@ -615,7 +615,7 @@ private: // Set to true when we've seen a "-per-" or a "per-", after which all units // are in the denominator. Until we find an "-and-", at which point the - // identifier is invalid pending TODO(CLDR-13700). + // identifier is invalid pending TODO(CLDR-13701). bool fAfterPer = false; Parser() : fSource(""), fTrie(u"") {} @@ -669,7 +669,7 @@ private: * dimensionality. * * Returns an error if we parse both compound units and "-and-", since mixed - * compound units are not yet supported - TODO(CLDR-13700). + * compound units are not yet supported - TODO(CLDR-13701). * * @param result Will be overwritten by the result, if status shows success. * @param sawAnd If an "-and-" was parsed prior to finding the "single @@ -718,7 +718,7 @@ private: case COMPOUND_PART_PER: if (sawAnd) { // Mixed compound units not yet supported, - // TODO(CLDR-13700). + // TODO(CLDR-13701). status = kUnitIdentifierSyntaxError; return result; } @@ -735,7 +735,7 @@ private: case COMPOUND_PART_AND: if (fAfterPer) { // Can't start with "-and-", and mixed compound units - // not yet supported, TODO(CLDR-13700). + // not yet supported, TODO(CLDR-13701). status = kUnitIdentifierSyntaxError; return result; } @@ -946,7 +946,7 @@ const char *SingleUnitImpl::getSimpleUnitID() const { return gSimpleUnits[index]; } -void SingleUnitImpl::appendNeutralIdentifier(CharString &result, UErrorCode &status) const { +void SingleUnitImpl::appendNeutralIdentifier(CharString &result, UErrorCode &status) const UPRV_NO_SANITIZE_UNDEFINED { int32_t absPower = std::abs(this->dimensionality); U_ASSERT(absPower > 0); // "this function does not support the dimensionless single units"; @@ -1195,7 +1195,7 @@ UMeasurePrefix MeasureUnit::getPrefix(UErrorCode& status) const { return SingleUnitImpl::forMeasureUnit(*this, status).unitPrefix; } -MeasureUnit MeasureUnit::withPrefix(UMeasurePrefix prefix, UErrorCode& status) const { +MeasureUnit MeasureUnit::withPrefix(UMeasurePrefix prefix, UErrorCode& status) const UPRV_NO_SANITIZE_UNDEFINED { SingleUnitImpl singleUnit = SingleUnitImpl::forMeasureUnit(*this, status); singleUnit.unitPrefix = prefix; return singleUnit.build(status); |