mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-20 23:37:33 +09:00
Issue #1971 - Part 2: Update ICU source to 63.2.
This commit is contained in:
parent
8df84683be
commit
1e69214382
3160 changed files with 275815 additions and 234203 deletions
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// © 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
@ -21,13 +21,16 @@
|
|||
#include "plurrule_impl.h"
|
||||
#include "uassert.h"
|
||||
#include "uhash.h"
|
||||
#include "precision.h"
|
||||
#include "visibledigits.h"
|
||||
#include "number_decimalquantity.h"
|
||||
#include "number_utils.h"
|
||||
#include "number_utypes.h"
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
using number::impl::DecimalQuantity;
|
||||
|
||||
static const UChar OTHER_STRING[] = {
|
||||
0x6F, 0x74, 0x68, 0x65, 0x72, 0 // "other"
|
||||
};
|
||||
|
|
@ -258,45 +261,33 @@ PluralFormat::format(const Formattable& numberObject, double number,
|
|||
if (msgPattern.countParts() == 0) {
|
||||
return numberFormat->format(numberObject, appendTo, pos, status);
|
||||
}
|
||||
|
||||
// Get the appropriate sub-message.
|
||||
// Select it based on the formatted number-offset.
|
||||
double numberMinusOffset = number - offset;
|
||||
UnicodeString numberString;
|
||||
FieldPosition ignorePos;
|
||||
FixedPrecision fp;
|
||||
VisibleDigitsWithExponent dec;
|
||||
fp.initVisibleDigitsWithExponent(numberMinusOffset, dec, status);
|
||||
if (U_FAILURE(status)) {
|
||||
return appendTo;
|
||||
}
|
||||
// Call NumberFormatter to get both the DecimalQuantity and the string.
|
||||
// This call site needs to use more internal APIs than the Java equivalent.
|
||||
number::impl::UFormattedNumberData data;
|
||||
if (offset == 0) {
|
||||
DecimalFormat *decFmt = dynamic_cast<DecimalFormat *>(numberFormat);
|
||||
if(decFmt != NULL) {
|
||||
decFmt->initVisibleDigitsWithExponent(
|
||||
numberObject, dec, status);
|
||||
if (U_FAILURE(status)) {
|
||||
return appendTo;
|
||||
}
|
||||
decFmt->format(dec, numberString, ignorePos, status);
|
||||
} else {
|
||||
numberFormat->format(
|
||||
numberObject, numberString, ignorePos, status); // could be BigDecimal etc.
|
||||
}
|
||||
// could be BigDecimal etc.
|
||||
numberObject.populateDecimalQuantity(data.quantity, status);
|
||||
} else {
|
||||
DecimalFormat *decFmt = dynamic_cast<DecimalFormat *>(numberFormat);
|
||||
if(decFmt != NULL) {
|
||||
decFmt->initVisibleDigitsWithExponent(
|
||||
numberMinusOffset, dec, status);
|
||||
if (U_FAILURE(status)) {
|
||||
return appendTo;
|
||||
}
|
||||
decFmt->format(dec, numberString, ignorePos, status);
|
||||
data.quantity.setToDouble(numberMinusOffset);
|
||||
}
|
||||
UnicodeString numberString;
|
||||
auto *decFmt = dynamic_cast<DecimalFormat *>(numberFormat);
|
||||
if(decFmt != nullptr) {
|
||||
decFmt->toNumberFormatter().formatImpl(&data, status); // mutates &data
|
||||
numberString = data.string.toUnicodeString();
|
||||
} else {
|
||||
if (offset == 0) {
|
||||
numberFormat->format(numberObject, numberString, status);
|
||||
} else {
|
||||
numberFormat->format(
|
||||
numberMinusOffset, numberString, ignorePos, status);
|
||||
numberFormat->format(numberMinusOffset, numberString, status);
|
||||
}
|
||||
}
|
||||
int32_t partIndex = findSubMessage(msgPattern, 0, pluralRulesWrapper, &dec, number, status);
|
||||
|
||||
int32_t partIndex = findSubMessage(msgPattern, 0, pluralRulesWrapper, &data.quantity, number, status);
|
||||
if (U_FAILURE(status)) { return appendTo; }
|
||||
// Replace syntactic # signs in the top level of this sub-message
|
||||
// (not in nested arguments) with the formatted number-offset.
|
||||
|
|
@ -585,7 +576,7 @@ PluralFormat::PluralSelectorAdapter::~PluralSelectorAdapter() {
|
|||
UnicodeString PluralFormat::PluralSelectorAdapter::select(void *context, double number,
|
||||
UErrorCode& /*ec*/) const {
|
||||
(void)number; // unused except in the assertion
|
||||
VisibleDigitsWithExponent *dec=static_cast<VisibleDigitsWithExponent *>(context);
|
||||
IFixedDecimal *dec=static_cast<IFixedDecimal *>(context);
|
||||
return pluralRules->select(*dec);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue