mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-25 09:57:32 +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
|
|
@ -65,8 +65,8 @@ LDFLAGS += $(LDFLAGSICUI18N)
|
|||
LIBS = $(LIBICUUC) $(DEFAULT_LIBS)
|
||||
|
||||
OBJECTS = ucln_in.o \
|
||||
fmtable.o format.o msgfmt.o umsg.o numfmt.o unum.o decimfmt.o decimalformatpattern.o dcfmtsym.o \
|
||||
digitlst.o fmtable_cnv.o \
|
||||
fmtable.o format.o msgfmt.o umsg.o numfmt.o unum.o decimfmt.o dcfmtsym.o \
|
||||
fmtable_cnv.o \
|
||||
choicfmt.o datefmt.o smpdtfmt.o reldtfmt.o dtfmtsym.o udat.o dtptngen.o udatpg.o \
|
||||
nfrs.o nfrule.o nfsubs.o rbnf.o numsys.o unumsys.o ucsdet.o \
|
||||
ucal.o calendar.o gregocal.o timezone.o simpletz.o olsontz.o \
|
||||
|
|
@ -81,6 +81,7 @@ collationsets.o \
|
|||
collationcompare.o collationfastlatin.o collationkeys.o rulebasedcollator.o collationroot.o \
|
||||
collationrootelements.o collationdatabuilder.o \
|
||||
collationweights.o collationruleparser.o collationbuilder.o collationfastlatinbuilder.o \
|
||||
listformatter.o ulistformatter.o \
|
||||
strmatch.o usearch.o search.o stsearch.o \
|
||||
translit.o utrans.o esctrn.o unesctrn.o funcrepl.o strrepl.o tridpars.o \
|
||||
cpdtrans.o rbt.o rbt_data.o rbt_pars.o rbt_rule.o rbt_set.o \
|
||||
|
|
@ -92,16 +93,26 @@ csdetect.o csmatch.o csr2022.o csrecog.o csrmbcs.o csrsbcs.o csrucode.o csrutf8.
|
|||
wintzimpl.o windtfmt.o winnmfmt.o basictz.o dtrule.o rbtz.o tzrule.o tztrans.o vtzone.o zonemeta.o \
|
||||
standardplural.o upluralrules.o plurrule.o plurfmt.o selfmt.o dtitvfmt.o dtitvinf.o udateintervalformat.o \
|
||||
tmunit.o tmutamt.o tmutfmt.o currpinf.o \
|
||||
uspoof.o uspoof_impl.o uspoof_build.o uspoof_conf.o decfmtst.o smpdtfst.o \
|
||||
uspoof.o uspoof_impl.o uspoof_build.o uspoof_conf.o smpdtfst.o \
|
||||
ztrans.o zrule.o vzone.o fphdlimp.o fpositer.o ufieldpositer.o \
|
||||
decNumber.o decContext.o alphaindex.o tznames.o tznames_impl.o tzgnames.o \
|
||||
tzfmt.o compactdecimalformat.o gender.o region.o scriptset.o \
|
||||
uregion.o reldatefmt.o quantityformatter.o measunit.o \
|
||||
sharedbreakiterator.o scientificnumberformatter.o digitgrouping.o \
|
||||
digitinterval.o digitformatter.o digitaffix.o valueformatter.o \
|
||||
digitaffixesandpadding.o pluralaffix.o precision.o \
|
||||
affixpatternparser.o smallintformatter.o decimfmtimpl.o \
|
||||
visibledigits.o dayperiodrules.o
|
||||
sharedbreakiterator.o scientificnumberformatter.o dayperiodrules.o nounit.o \
|
||||
number_affixutils.o number_compact.o number_decimalquantity.o \
|
||||
number_decimfmtprops.o number_fluent.o number_formatimpl.o number_grouping.o \
|
||||
number_integerwidth.o number_longnames.o number_modifiers.o number_notation.o \
|
||||
number_padding.o number_patternmodifier.o number_patternstring.o \
|
||||
number_rounding.o number_scientific.o number_stringbuilder.o number_utils.o number_asformat.o \
|
||||
number_mapper.o number_multiplier.o number_currencysymbols.o number_skeletons.o number_capi.o \
|
||||
double-conversion.o double-conversion-bignum-dtoa.o double-conversion-bignum.o \
|
||||
double-conversion-cached-powers.o double-conversion-diy-fp.o \
|
||||
double-conversion-fast-dtoa.o double-conversion-strtod.o \
|
||||
numparse_stringsegment.o numparse_parsednumber.o numparse_impl.o \
|
||||
numparse_symbols.o numparse_decimal.o numparse_scientific.o numparse_currency.o \
|
||||
numparse_affixes.o numparse_compositions.o numparse_validators.o \
|
||||
numrange_fluent.o numrange_impl.o \
|
||||
erarules.o
|
||||
|
||||
## Header files to install
|
||||
HEADERS = $(srcdir)/unicode/*.h
|
||||
|
|
|
|||
|
|
@ -1,696 +0,0 @@
|
|||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
* Copyright (C) 2015, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
* file name: affixpatternparser.cpp
|
||||
*/
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/dcfmtsym.h"
|
||||
#include "unicode/plurrule.h"
|
||||
#include "unicode/ucurr.h"
|
||||
#include "affixpatternparser.h"
|
||||
#include "charstr.h"
|
||||
#include "precision.h"
|
||||
#include "uassert.h"
|
||||
#include "unistrappender.h"
|
||||
|
||||
static UChar gDefaultSymbols[] = {0xa4, 0xa4, 0xa4};
|
||||
|
||||
static UChar gPercent = 0x25;
|
||||
static UChar gPerMill = 0x2030;
|
||||
static UChar gNegative = 0x2D;
|
||||
static UChar gPositive = 0x2B;
|
||||
|
||||
#define PACK_TOKEN_AND_LENGTH(t, l) ((UChar) (((t) << 8) | (l & 0xFF)))
|
||||
|
||||
#define UNPACK_TOKEN(c) ((AffixPattern::ETokenType) (((c) >> 8) & 0x7F))
|
||||
|
||||
#define UNPACK_LONG(c) (((c) >> 8) & 0x80)
|
||||
|
||||
#define UNPACK_LENGTH(c) ((c) & 0xFF)
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
static int32_t
|
||||
nextToken(const UChar *buffer, int32_t idx, int32_t len, UChar *token) {
|
||||
if (buffer[idx] != 0x27 || idx + 1 == len) {
|
||||
*token = buffer[idx];
|
||||
return 1;
|
||||
}
|
||||
*token = buffer[idx + 1];
|
||||
if (buffer[idx + 1] == 0xA4) {
|
||||
int32_t i = 2;
|
||||
for (; idx + i < len && i < 4 && buffer[idx + i] == buffer[idx + 1]; ++i)
|
||||
;
|
||||
return i;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int32_t
|
||||
nextUserToken(const UChar *buffer, int32_t idx, int32_t len, UChar *token) {
|
||||
*token = buffer[idx];
|
||||
int32_t max;
|
||||
switch (buffer[idx]) {
|
||||
case 0x27:
|
||||
max = 2;
|
||||
break;
|
||||
case 0xA4:
|
||||
max = 3;
|
||||
break;
|
||||
default:
|
||||
max = 1;
|
||||
break;
|
||||
}
|
||||
int32_t i = 1;
|
||||
for (; idx + i < len && i < max && buffer[idx + i] == buffer[idx]; ++i)
|
||||
;
|
||||
return i;
|
||||
}
|
||||
|
||||
CurrencyAffixInfo::CurrencyAffixInfo()
|
||||
: fSymbol(gDefaultSymbols, 1),
|
||||
fISO(gDefaultSymbols, 2),
|
||||
fLong(DigitAffix(gDefaultSymbols, 3)),
|
||||
fIsDefault(TRUE) {
|
||||
}
|
||||
|
||||
void
|
||||
CurrencyAffixInfo::set(
|
||||
const char *locale,
|
||||
const PluralRules *rules,
|
||||
const UChar *currency,
|
||||
UErrorCode &status) {
|
||||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
}
|
||||
fIsDefault = FALSE;
|
||||
if (currency == NULL) {
|
||||
fSymbol.setTo(gDefaultSymbols, 1);
|
||||
fISO.setTo(gDefaultSymbols, 2);
|
||||
fLong.remove();
|
||||
fLong.append(gDefaultSymbols, 3);
|
||||
fIsDefault = TRUE;
|
||||
return;
|
||||
}
|
||||
int32_t len;
|
||||
UBool unusedIsChoice;
|
||||
const UChar *symbol = ucurr_getName(
|
||||
currency, locale, UCURR_SYMBOL_NAME, &unusedIsChoice,
|
||||
&len, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
}
|
||||
fSymbol.setTo(symbol, len);
|
||||
fISO.setTo(currency, u_strlen(currency));
|
||||
fLong.remove();
|
||||
StringEnumeration* keywords = rules->getKeywords(status);
|
||||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
}
|
||||
const UnicodeString* pluralCount;
|
||||
while ((pluralCount = keywords->snext(status)) != NULL) {
|
||||
CharString pCount;
|
||||
pCount.appendInvariantChars(*pluralCount, status);
|
||||
const UChar *pluralName = ucurr_getPluralName(
|
||||
currency, locale, &unusedIsChoice, pCount.data(),
|
||||
&len, &status);
|
||||
fLong.setVariant(pCount.data(), UnicodeString(pluralName, len), status);
|
||||
}
|
||||
delete keywords;
|
||||
}
|
||||
|
||||
void
|
||||
CurrencyAffixInfo::adjustPrecision(
|
||||
const UChar *currency, const UCurrencyUsage usage,
|
||||
FixedPrecision &precision, UErrorCode &status) {
|
||||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t digitCount = ucurr_getDefaultFractionDigitsForUsage(
|
||||
currency, usage, &status);
|
||||
precision.fMin.setFracDigitCount(digitCount);
|
||||
precision.fMax.setFracDigitCount(digitCount);
|
||||
double increment = ucurr_getRoundingIncrementForUsage(
|
||||
currency, usage, &status);
|
||||
if (increment == 0.0) {
|
||||
precision.fRoundingIncrement.clear();
|
||||
} else {
|
||||
precision.fRoundingIncrement.set(increment);
|
||||
// guard against round-off error
|
||||
precision.fRoundingIncrement.round(6);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AffixPattern::addLiteral(
|
||||
const UChar *literal, int32_t start, int32_t len) {
|
||||
char32Count += u_countChar32(literal + start, len);
|
||||
literals.append(literal, start, len);
|
||||
int32_t tlen = tokens.length();
|
||||
// Takes 4 UChars to encode maximum literal length.
|
||||
UChar *tokenChars = tokens.getBuffer(tlen + 4);
|
||||
|
||||
// find start of literal size. May be tlen if there is no literal.
|
||||
// While finding start of literal size, compute literal length
|
||||
int32_t literalLength = 0;
|
||||
int32_t tLiteralStart = tlen;
|
||||
while (tLiteralStart > 0 && UNPACK_TOKEN(tokenChars[tLiteralStart - 1]) == kLiteral) {
|
||||
tLiteralStart--;
|
||||
literalLength <<= 8;
|
||||
literalLength |= UNPACK_LENGTH(tokenChars[tLiteralStart]);
|
||||
}
|
||||
// Add number of chars we just added to literal
|
||||
literalLength += len;
|
||||
|
||||
// Now encode the new length starting at tLiteralStart
|
||||
tlen = tLiteralStart;
|
||||
tokenChars[tlen++] = PACK_TOKEN_AND_LENGTH(kLiteral, literalLength & 0xFF);
|
||||
literalLength >>= 8;
|
||||
while (literalLength) {
|
||||
tokenChars[tlen++] = PACK_TOKEN_AND_LENGTH(kLiteral | 0x80, literalLength & 0xFF);
|
||||
literalLength >>= 8;
|
||||
}
|
||||
tokens.releaseBuffer(tlen);
|
||||
}
|
||||
|
||||
void
|
||||
AffixPattern::add(ETokenType t) {
|
||||
add(t, 1);
|
||||
}
|
||||
|
||||
void
|
||||
AffixPattern::addCurrency(uint8_t count) {
|
||||
add(kCurrency, count);
|
||||
}
|
||||
|
||||
void
|
||||
AffixPattern::add(ETokenType t, uint8_t count) {
|
||||
U_ASSERT(t != kLiteral);
|
||||
char32Count += count;
|
||||
switch (t) {
|
||||
case kCurrency:
|
||||
hasCurrencyToken = TRUE;
|
||||
break;
|
||||
case kPercent:
|
||||
hasPercentToken = TRUE;
|
||||
break;
|
||||
case kPerMill:
|
||||
hasPermillToken = TRUE;
|
||||
break;
|
||||
default:
|
||||
// Do nothing
|
||||
break;
|
||||
}
|
||||
tokens.append(PACK_TOKEN_AND_LENGTH(t, count));
|
||||
}
|
||||
|
||||
AffixPattern &
|
||||
AffixPattern::append(const AffixPattern &other) {
|
||||
AffixPatternIterator iter;
|
||||
other.iterator(iter);
|
||||
UnicodeString literal;
|
||||
while (iter.nextToken()) {
|
||||
switch (iter.getTokenType()) {
|
||||
case kLiteral:
|
||||
iter.getLiteral(literal);
|
||||
addLiteral(literal.getBuffer(), 0, literal.length());
|
||||
break;
|
||||
case kCurrency:
|
||||
addCurrency(iter.getTokenLength());
|
||||
break;
|
||||
default:
|
||||
add(iter.getTokenType());
|
||||
break;
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void
|
||||
AffixPattern::remove() {
|
||||
tokens.remove();
|
||||
literals.remove();
|
||||
hasCurrencyToken = FALSE;
|
||||
hasPercentToken = FALSE;
|
||||
hasPermillToken = FALSE;
|
||||
char32Count = 0;
|
||||
}
|
||||
|
||||
// escapes literals for strings where special characters are NOT escaped
|
||||
// except for apostrophe.
|
||||
static void escapeApostropheInLiteral(
|
||||
const UnicodeString &literal, UnicodeStringAppender &appender) {
|
||||
int32_t len = literal.length();
|
||||
const UChar *buffer = literal.getBuffer();
|
||||
for (int32_t i = 0; i < len; ++i) {
|
||||
UChar ch = buffer[i];
|
||||
switch (ch) {
|
||||
case 0x27:
|
||||
appender.append((UChar) 0x27);
|
||||
appender.append((UChar) 0x27);
|
||||
break;
|
||||
default:
|
||||
appender.append(ch);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// escapes literals for user strings where special characters in literals
|
||||
// are escaped with apostrophe.
|
||||
static void escapeLiteral(
|
||||
const UnicodeString &literal, UnicodeStringAppender &appender) {
|
||||
int32_t len = literal.length();
|
||||
const UChar *buffer = literal.getBuffer();
|
||||
for (int32_t i = 0; i < len; ++i) {
|
||||
UChar ch = buffer[i];
|
||||
switch (ch) {
|
||||
case 0x27:
|
||||
appender.append((UChar) 0x27);
|
||||
appender.append((UChar) 0x27);
|
||||
break;
|
||||
case 0x25:
|
||||
appender.append((UChar) 0x27);
|
||||
appender.append((UChar) 0x25);
|
||||
appender.append((UChar) 0x27);
|
||||
break;
|
||||
case 0x2030:
|
||||
appender.append((UChar) 0x27);
|
||||
appender.append((UChar) 0x2030);
|
||||
appender.append((UChar) 0x27);
|
||||
break;
|
||||
case 0xA4:
|
||||
appender.append((UChar) 0x27);
|
||||
appender.append((UChar) 0xA4);
|
||||
appender.append((UChar) 0x27);
|
||||
break;
|
||||
case 0x2D:
|
||||
appender.append((UChar) 0x27);
|
||||
appender.append((UChar) 0x2D);
|
||||
appender.append((UChar) 0x27);
|
||||
break;
|
||||
case 0x2B:
|
||||
appender.append((UChar) 0x27);
|
||||
appender.append((UChar) 0x2B);
|
||||
appender.append((UChar) 0x27);
|
||||
break;
|
||||
default:
|
||||
appender.append(ch);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UnicodeString &
|
||||
AffixPattern::toString(UnicodeString &appendTo) const {
|
||||
AffixPatternIterator iter;
|
||||
iterator(iter);
|
||||
UnicodeStringAppender appender(appendTo);
|
||||
UnicodeString literal;
|
||||
while (iter.nextToken()) {
|
||||
switch (iter.getTokenType()) {
|
||||
case kLiteral:
|
||||
escapeApostropheInLiteral(iter.getLiteral(literal), appender);
|
||||
break;
|
||||
case kPercent:
|
||||
appender.append((UChar) 0x27);
|
||||
appender.append((UChar) 0x25);
|
||||
break;
|
||||
case kPerMill:
|
||||
appender.append((UChar) 0x27);
|
||||
appender.append((UChar) 0x2030);
|
||||
break;
|
||||
case kCurrency:
|
||||
{
|
||||
appender.append((UChar) 0x27);
|
||||
int32_t cl = iter.getTokenLength();
|
||||
for (int32_t i = 0; i < cl; ++i) {
|
||||
appender.append((UChar) 0xA4);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case kNegative:
|
||||
appender.append((UChar) 0x27);
|
||||
appender.append((UChar) 0x2D);
|
||||
break;
|
||||
case kPositive:
|
||||
appender.append((UChar) 0x27);
|
||||
appender.append((UChar) 0x2B);
|
||||
break;
|
||||
default:
|
||||
U_ASSERT(FALSE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return appendTo;
|
||||
}
|
||||
|
||||
UnicodeString &
|
||||
AffixPattern::toUserString(UnicodeString &appendTo) const {
|
||||
AffixPatternIterator iter;
|
||||
iterator(iter);
|
||||
UnicodeStringAppender appender(appendTo);
|
||||
UnicodeString literal;
|
||||
while (iter.nextToken()) {
|
||||
switch (iter.getTokenType()) {
|
||||
case kLiteral:
|
||||
escapeLiteral(iter.getLiteral(literal), appender);
|
||||
break;
|
||||
case kPercent:
|
||||
appender.append((UChar) 0x25);
|
||||
break;
|
||||
case kPerMill:
|
||||
appender.append((UChar) 0x2030);
|
||||
break;
|
||||
case kCurrency:
|
||||
{
|
||||
int32_t cl = iter.getTokenLength();
|
||||
for (int32_t i = 0; i < cl; ++i) {
|
||||
appender.append((UChar) 0xA4);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case kNegative:
|
||||
appender.append((UChar) 0x2D);
|
||||
break;
|
||||
case kPositive:
|
||||
appender.append((UChar) 0x2B);
|
||||
break;
|
||||
default:
|
||||
U_ASSERT(FALSE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return appendTo;
|
||||
}
|
||||
|
||||
class AffixPatternAppender : public UMemory {
|
||||
public:
|
||||
AffixPatternAppender(AffixPattern &dest) : fDest(&dest), fIdx(0) { }
|
||||
|
||||
inline void append(UChar x) {
|
||||
if (fIdx == UPRV_LENGTHOF(fBuffer)) {
|
||||
fDest->addLiteral(fBuffer, 0, fIdx);
|
||||
fIdx = 0;
|
||||
}
|
||||
fBuffer[fIdx++] = x;
|
||||
}
|
||||
|
||||
inline void append(UChar32 x) {
|
||||
if (fIdx >= UPRV_LENGTHOF(fBuffer) - 1) {
|
||||
fDest->addLiteral(fBuffer, 0, fIdx);
|
||||
fIdx = 0;
|
||||
}
|
||||
U16_APPEND_UNSAFE(fBuffer, fIdx, x);
|
||||
}
|
||||
|
||||
inline void flush() {
|
||||
if (fIdx) {
|
||||
fDest->addLiteral(fBuffer, 0, fIdx);
|
||||
}
|
||||
fIdx = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* flush the buffer when we go out of scope.
|
||||
*/
|
||||
~AffixPatternAppender() {
|
||||
flush();
|
||||
}
|
||||
private:
|
||||
AffixPattern *fDest;
|
||||
int32_t fIdx;
|
||||
UChar fBuffer[32];
|
||||
AffixPatternAppender(const AffixPatternAppender &other);
|
||||
AffixPatternAppender &operator=(const AffixPatternAppender &other);
|
||||
};
|
||||
|
||||
|
||||
AffixPattern &
|
||||
AffixPattern::parseUserAffixString(
|
||||
const UnicodeString &affixStr,
|
||||
AffixPattern &appendTo,
|
||||
UErrorCode &status) {
|
||||
if (U_FAILURE(status)) {
|
||||
return appendTo;
|
||||
}
|
||||
int32_t len = affixStr.length();
|
||||
const UChar *buffer = affixStr.getBuffer();
|
||||
// 0 = not quoted; 1 = quoted.
|
||||
int32_t state = 0;
|
||||
AffixPatternAppender appender(appendTo);
|
||||
for (int32_t i = 0; i < len; ) {
|
||||
UChar token;
|
||||
int32_t tokenSize = nextUserToken(buffer, i, len, &token);
|
||||
i += tokenSize;
|
||||
if (token == 0x27 && tokenSize == 1) { // quote
|
||||
state = 1 - state;
|
||||
continue;
|
||||
}
|
||||
if (state == 0) {
|
||||
switch (token) {
|
||||
case 0x25:
|
||||
appender.flush();
|
||||
appendTo.add(kPercent, 1);
|
||||
break;
|
||||
case 0x27: // double quote
|
||||
appender.append((UChar) 0x27);
|
||||
break;
|
||||
case 0x2030:
|
||||
appender.flush();
|
||||
appendTo.add(kPerMill, 1);
|
||||
break;
|
||||
case 0x2D:
|
||||
appender.flush();
|
||||
appendTo.add(kNegative, 1);
|
||||
break;
|
||||
case 0x2B:
|
||||
appender.flush();
|
||||
appendTo.add(kPositive, 1);
|
||||
break;
|
||||
case 0xA4:
|
||||
appender.flush();
|
||||
appendTo.add(kCurrency, tokenSize);
|
||||
break;
|
||||
default:
|
||||
appender.append(token);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (token) {
|
||||
case 0x27: // double quote
|
||||
appender.append((UChar) 0x27);
|
||||
break;
|
||||
case 0xA4: // included b/c tokenSize can be > 1
|
||||
for (int32_t j = 0; j < tokenSize; ++j) {
|
||||
appender.append((UChar) 0xA4);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
appender.append(token);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return appendTo;
|
||||
}
|
||||
|
||||
AffixPattern &
|
||||
AffixPattern::parseAffixString(
|
||||
const UnicodeString &affixStr,
|
||||
AffixPattern &appendTo,
|
||||
UErrorCode &status) {
|
||||
if (U_FAILURE(status)) {
|
||||
return appendTo;
|
||||
}
|
||||
int32_t len = affixStr.length();
|
||||
const UChar *buffer = affixStr.getBuffer();
|
||||
for (int32_t i = 0; i < len; ) {
|
||||
UChar token;
|
||||
int32_t tokenSize = nextToken(buffer, i, len, &token);
|
||||
if (tokenSize == 1) {
|
||||
int32_t literalStart = i;
|
||||
++i;
|
||||
while (i < len && (tokenSize = nextToken(buffer, i, len, &token)) == 1) {
|
||||
++i;
|
||||
}
|
||||
appendTo.addLiteral(buffer, literalStart, i - literalStart);
|
||||
|
||||
// If we reached end of string, we are done
|
||||
if (i == len) {
|
||||
return appendTo;
|
||||
}
|
||||
}
|
||||
i += tokenSize;
|
||||
switch (token) {
|
||||
case 0x25:
|
||||
appendTo.add(kPercent, 1);
|
||||
break;
|
||||
case 0x2030:
|
||||
appendTo.add(kPerMill, 1);
|
||||
break;
|
||||
case 0x2D:
|
||||
appendTo.add(kNegative, 1);
|
||||
break;
|
||||
case 0x2B:
|
||||
appendTo.add(kPositive, 1);
|
||||
break;
|
||||
case 0xA4:
|
||||
{
|
||||
if (tokenSize - 1 > 3) {
|
||||
status = U_PARSE_ERROR;
|
||||
return appendTo;
|
||||
}
|
||||
appendTo.add(kCurrency, tokenSize - 1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
appendTo.addLiteral(&token, 0, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return appendTo;
|
||||
}
|
||||
|
||||
AffixPatternIterator &
|
||||
AffixPattern::iterator(AffixPatternIterator &result) const {
|
||||
result.nextLiteralIndex = 0;
|
||||
result.lastLiteralLength = 0;
|
||||
result.nextTokenIndex = 0;
|
||||
result.tokens = &tokens;
|
||||
result.literals = &literals;
|
||||
return result;
|
||||
}
|
||||
|
||||
UBool
|
||||
AffixPatternIterator::nextToken() {
|
||||
int32_t tlen = tokens->length();
|
||||
if (nextTokenIndex == tlen) {
|
||||
return FALSE;
|
||||
}
|
||||
++nextTokenIndex;
|
||||
const UChar *tokenBuffer = tokens->getBuffer();
|
||||
if (UNPACK_TOKEN(tokenBuffer[nextTokenIndex - 1]) ==
|
||||
AffixPattern::kLiteral) {
|
||||
while (nextTokenIndex < tlen &&
|
||||
UNPACK_LONG(tokenBuffer[nextTokenIndex])) {
|
||||
++nextTokenIndex;
|
||||
}
|
||||
lastLiteralLength = 0;
|
||||
int32_t i = nextTokenIndex - 1;
|
||||
for (; UNPACK_LONG(tokenBuffer[i]); --i) {
|
||||
lastLiteralLength <<= 8;
|
||||
lastLiteralLength |= UNPACK_LENGTH(tokenBuffer[i]);
|
||||
}
|
||||
lastLiteralLength <<= 8;
|
||||
lastLiteralLength |= UNPACK_LENGTH(tokenBuffer[i]);
|
||||
nextLiteralIndex += lastLiteralLength;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
AffixPattern::ETokenType
|
||||
AffixPatternIterator::getTokenType() const {
|
||||
return UNPACK_TOKEN(tokens->charAt(nextTokenIndex - 1));
|
||||
}
|
||||
|
||||
UnicodeString &
|
||||
AffixPatternIterator::getLiteral(UnicodeString &result) const {
|
||||
const UChar *buffer = literals->getBuffer();
|
||||
result.setTo(buffer + (nextLiteralIndex - lastLiteralLength), lastLiteralLength);
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t
|
||||
AffixPatternIterator::getTokenLength() const {
|
||||
const UChar *tokenBuffer = tokens->getBuffer();
|
||||
AffixPattern::ETokenType type = UNPACK_TOKEN(tokenBuffer[nextTokenIndex - 1]);
|
||||
return type == AffixPattern::kLiteral ? lastLiteralLength : UNPACK_LENGTH(tokenBuffer[nextTokenIndex - 1]);
|
||||
}
|
||||
|
||||
AffixPatternParser::AffixPatternParser()
|
||||
: fPercent(gPercent), fPermill(gPerMill), fNegative(gNegative), fPositive(gPositive) {
|
||||
}
|
||||
|
||||
AffixPatternParser::AffixPatternParser(
|
||||
const DecimalFormatSymbols &symbols) {
|
||||
setDecimalFormatSymbols(symbols);
|
||||
}
|
||||
|
||||
void
|
||||
AffixPatternParser::setDecimalFormatSymbols(
|
||||
const DecimalFormatSymbols &symbols) {
|
||||
fPercent = symbols.getConstSymbol(DecimalFormatSymbols::kPercentSymbol);
|
||||
fPermill = symbols.getConstSymbol(DecimalFormatSymbols::kPerMillSymbol);
|
||||
fNegative = symbols.getConstSymbol(DecimalFormatSymbols::kMinusSignSymbol);
|
||||
fPositive = symbols.getConstSymbol(DecimalFormatSymbols::kPlusSignSymbol);
|
||||
}
|
||||
|
||||
PluralAffix &
|
||||
AffixPatternParser::parse(
|
||||
const AffixPattern &affixPattern,
|
||||
const CurrencyAffixInfo ¤cyAffixInfo,
|
||||
PluralAffix &appendTo,
|
||||
UErrorCode &status) const {
|
||||
if (U_FAILURE(status)) {
|
||||
return appendTo;
|
||||
}
|
||||
AffixPatternIterator iter;
|
||||
affixPattern.iterator(iter);
|
||||
UnicodeString literal;
|
||||
while (iter.nextToken()) {
|
||||
switch (iter.getTokenType()) {
|
||||
case AffixPattern::kPercent:
|
||||
appendTo.append(fPercent, UNUM_PERCENT_FIELD);
|
||||
break;
|
||||
case AffixPattern::kPerMill:
|
||||
appendTo.append(fPermill, UNUM_PERMILL_FIELD);
|
||||
break;
|
||||
case AffixPattern::kNegative:
|
||||
appendTo.append(fNegative, UNUM_SIGN_FIELD);
|
||||
break;
|
||||
case AffixPattern::kPositive:
|
||||
appendTo.append(fPositive, UNUM_SIGN_FIELD);
|
||||
break;
|
||||
case AffixPattern::kCurrency:
|
||||
switch (iter.getTokenLength()) {
|
||||
case 1:
|
||||
appendTo.append(
|
||||
currencyAffixInfo.getSymbol(), UNUM_CURRENCY_FIELD);
|
||||
break;
|
||||
case 2:
|
||||
appendTo.append(
|
||||
currencyAffixInfo.getISO(), UNUM_CURRENCY_FIELD);
|
||||
break;
|
||||
case 3:
|
||||
appendTo.append(
|
||||
currencyAffixInfo.getLong(), UNUM_CURRENCY_FIELD, status);
|
||||
break;
|
||||
default:
|
||||
U_ASSERT(FALSE);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case AffixPattern::kLiteral:
|
||||
appendTo.append(iter.getLiteral(literal));
|
||||
break;
|
||||
default:
|
||||
U_ASSERT(FALSE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return appendTo;
|
||||
}
|
||||
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
|
@ -1,402 +0,0 @@
|
|||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2015, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
* affixpatternparser.h
|
||||
*
|
||||
* created on: 2015jan06
|
||||
* created by: Travis Keep
|
||||
*/
|
||||
|
||||
#ifndef __AFFIX_PATTERN_PARSER_H__
|
||||
#define __AFFIX_PATTERN_PARSER_H__
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/unistr.h"
|
||||
#include "unicode/uobject.h"
|
||||
#include "pluralaffix.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
class PluralRules;
|
||||
class FixedPrecision;
|
||||
class DecimalFormatSymbols;
|
||||
|
||||
/**
|
||||
* A representation of the various forms of a particular currency according
|
||||
* to some locale and usage context.
|
||||
*
|
||||
* Includes the symbol, ISO code form, and long form(s) of the currency name
|
||||
* for each plural variation.
|
||||
*/
|
||||
class U_I18N_API CurrencyAffixInfo : public UMemory {
|
||||
public:
|
||||
/**
|
||||
* Symbol is \u00a4; ISO form is \u00a4\u00a4;
|
||||
* long form is \u00a4\u00a4\u00a4.
|
||||
*/
|
||||
CurrencyAffixInfo();
|
||||
|
||||
const UnicodeString &getSymbol() const { return fSymbol; }
|
||||
const UnicodeString &getISO() const { return fISO; }
|
||||
const PluralAffix &getLong() const { return fLong; }
|
||||
void setSymbol(const UnicodeString &symbol) {
|
||||
fSymbol = symbol;
|
||||
fIsDefault = FALSE;
|
||||
}
|
||||
void setISO(const UnicodeString &iso) {
|
||||
fISO = iso;
|
||||
fIsDefault = FALSE;
|
||||
}
|
||||
UBool
|
||||
equals(const CurrencyAffixInfo &other) const {
|
||||
return (fSymbol == other.fSymbol)
|
||||
&& (fISO == other.fISO)
|
||||
&& (fLong.equals(other.fLong))
|
||||
&& (fIsDefault == other.fIsDefault);
|
||||
}
|
||||
|
||||
/**
|
||||
* Intializes this instance.
|
||||
*
|
||||
* @param locale the locale for the currency forms.
|
||||
* @param rules The plural rules for the locale.
|
||||
* @param currency the null terminated, 3 character ISO code of the
|
||||
* currency. If NULL, resets this instance as if it were just created.
|
||||
* In this case, the first 2 parameters may be NULL as well.
|
||||
* @param status any error returned here.
|
||||
*/
|
||||
void set(
|
||||
const char *locale, const PluralRules *rules,
|
||||
const UChar *currency, UErrorCode &status);
|
||||
|
||||
/**
|
||||
* Returns true if this instance is the default. That is has no real
|
||||
* currency. For instance never initialized with set()
|
||||
* or reset with set(NULL, NULL, NULL, status).
|
||||
*/
|
||||
UBool isDefault() const { return fIsDefault; }
|
||||
|
||||
/**
|
||||
* Adjusts the precision used for a particular currency.
|
||||
* @param currency the null terminated, 3 character ISO code of the
|
||||
* currency.
|
||||
* @param usage the usage of the currency
|
||||
* @param precision min/max fraction digits and rounding increment
|
||||
* adjusted.
|
||||
* @params status any error reported here.
|
||||
*/
|
||||
static void adjustPrecision(
|
||||
const UChar *currency, const UCurrencyUsage usage,
|
||||
FixedPrecision &precision, UErrorCode &status);
|
||||
|
||||
private:
|
||||
/**
|
||||
* The symbol form of the currency.
|
||||
*/
|
||||
UnicodeString fSymbol;
|
||||
|
||||
/**
|
||||
* The ISO form of the currency, usually three letter abbreviation.
|
||||
*/
|
||||
UnicodeString fISO;
|
||||
|
||||
/**
|
||||
* The long forms of the currency keyed by plural variation.
|
||||
*/
|
||||
PluralAffix fLong;
|
||||
|
||||
UBool fIsDefault;
|
||||
|
||||
};
|
||||
|
||||
class AffixPatternIterator;
|
||||
|
||||
/**
|
||||
* A locale agnostic representation of an affix pattern.
|
||||
*/
|
||||
class U_I18N_API AffixPattern : public UMemory {
|
||||
public:
|
||||
|
||||
/**
|
||||
* The token types that can appear in an affix pattern.
|
||||
*/
|
||||
enum ETokenType {
|
||||
kLiteral,
|
||||
kPercent,
|
||||
kPerMill,
|
||||
kCurrency,
|
||||
kNegative,
|
||||
kPositive
|
||||
};
|
||||
|
||||
/**
|
||||
* An empty affix pattern.
|
||||
*/
|
||||
AffixPattern()
|
||||
: tokens(), literals(), hasCurrencyToken(FALSE),
|
||||
hasPercentToken(FALSE), hasPermillToken(FALSE), char32Count(0) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a string literal to this affix pattern.
|
||||
*/
|
||||
void addLiteral(const UChar *, int32_t start, int32_t len);
|
||||
|
||||
/**
|
||||
* Adds a token to this affix pattern. t must not be kLiteral as
|
||||
* the addLiteral() method adds literals.
|
||||
* @param t the token type to add
|
||||
*/
|
||||
void add(ETokenType t);
|
||||
|
||||
/**
|
||||
* Adds a currency token with specific count to this affix pattern.
|
||||
* @param count the token count. Used to distinguish between
|
||||
* one, two, or three currency symbols. Note that adding a currency
|
||||
* token with count=2 (Use ISO code) is different than adding two
|
||||
* currency tokens each with count=1 (two currency symbols).
|
||||
*/
|
||||
void addCurrency(uint8_t count);
|
||||
|
||||
/**
|
||||
* Makes this instance be an empty affix pattern.
|
||||
*/
|
||||
void remove();
|
||||
|
||||
/**
|
||||
* Provides an iterator over the tokens in this instance.
|
||||
* @param result this is initialized to point just before the
|
||||
* first token of this instance. Caller must call nextToken()
|
||||
* on the iterator once it is set up to have it actually point
|
||||
* to the first token. This first call to nextToken() will return
|
||||
* FALSE if the AffixPattern being iterated over is empty.
|
||||
* @return result
|
||||
*/
|
||||
AffixPatternIterator &iterator(AffixPatternIterator &result) const;
|
||||
|
||||
/**
|
||||
* Returns TRUE if this instance has currency tokens in it.
|
||||
*/
|
||||
UBool usesCurrency() const {
|
||||
return hasCurrencyToken;
|
||||
}
|
||||
|
||||
UBool usesPercent() const {
|
||||
return hasPercentToken;
|
||||
}
|
||||
|
||||
UBool usesPermill() const {
|
||||
return hasPermillToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of code points a string of this instance
|
||||
* would have if none of the special tokens were escaped.
|
||||
* Used to compute the padding size.
|
||||
*/
|
||||
int32_t countChar32() const {
|
||||
return char32Count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends other to this instance mutating this instance in place.
|
||||
* @param other The pattern appended to the end of this one.
|
||||
* @return a reference to this instance for chaining.
|
||||
*/
|
||||
AffixPattern &append(const AffixPattern &other);
|
||||
|
||||
/**
|
||||
* Converts this AffixPattern back into a user string.
|
||||
* It is the inverse of parseUserAffixString.
|
||||
*/
|
||||
UnicodeString &toUserString(UnicodeString &appendTo) const;
|
||||
|
||||
/**
|
||||
* Converts this AffixPattern back into a string.
|
||||
* It is the inverse of parseAffixString.
|
||||
*/
|
||||
UnicodeString &toString(UnicodeString &appendTo) const;
|
||||
|
||||
/**
|
||||
* Parses an affix pattern string appending it to an AffixPattern.
|
||||
* Parses affix pattern strings produced from using
|
||||
* DecimalFormatPatternParser to parse a format pattern. Affix patterns
|
||||
* include the positive prefix and suffix and the negative prefix
|
||||
* and suffix. This method expects affix patterns strings to be in the
|
||||
* same format that DecimalFormatPatternParser produces. Namely special
|
||||
* characters in the affix that correspond to a field type must be
|
||||
* prefixed with an apostrophe ('). These special character sequences
|
||||
* inluce minus (-), percent (%), permile (U+2030), plus (+),
|
||||
* short currency (U+00a4), medium currency (u+00a4 * 2),
|
||||
* long currency (u+a4 * 3), and apostrophe (')
|
||||
* (apostrophe does not correspond to a field type but has to be escaped
|
||||
* because it itself is the escape character).
|
||||
* Since the expansion of these special character
|
||||
* sequences is locale dependent, these sequences are not expanded in
|
||||
* an AffixPattern instance.
|
||||
* If these special characters are not prefixed with an apostrophe in
|
||||
* the affix pattern string, then they are treated verbatim just as
|
||||
* any other character. If an apostrophe prefixes a non special
|
||||
* character in the affix pattern, the apostrophe is simply ignored.
|
||||
*
|
||||
* @param affixStr the string from DecimalFormatPatternParser
|
||||
* @param appendTo parsed result appended here.
|
||||
* @param status any error parsing returned here.
|
||||
*/
|
||||
static AffixPattern &parseAffixString(
|
||||
const UnicodeString &affixStr,
|
||||
AffixPattern &appendTo,
|
||||
UErrorCode &status);
|
||||
|
||||
/**
|
||||
* Parses an affix pattern string appending it to an AffixPattern.
|
||||
* Parses affix pattern strings as the user would supply them.
|
||||
* In this function, quoting makes special characters like normal
|
||||
* characters whereas in parseAffixString, quoting makes special
|
||||
* characters special.
|
||||
*
|
||||
* @param affixStr the string from the user
|
||||
* @param appendTo parsed result appended here.
|
||||
* @param status any error parsing returned here.
|
||||
*/
|
||||
static AffixPattern &parseUserAffixString(
|
||||
const UnicodeString &affixStr,
|
||||
AffixPattern &appendTo,
|
||||
UErrorCode &status);
|
||||
|
||||
UBool equals(const AffixPattern &other) const {
|
||||
return (tokens == other.tokens)
|
||||
&& (literals == other.literals)
|
||||
&& (hasCurrencyToken == other.hasCurrencyToken)
|
||||
&& (hasPercentToken == other.hasPercentToken)
|
||||
&& (hasPermillToken == other.hasPermillToken)
|
||||
&& (char32Count == other.char32Count);
|
||||
}
|
||||
|
||||
private:
|
||||
/*
|
||||
* Tokens stored here. Each UChar generally stands for one token. A
|
||||
* Each token is of form 'etttttttllllllll' llllllll is the length of
|
||||
* the token and ranges from 0-255. ttttttt is the token type and ranges
|
||||
* from 0-127. If e is set it means this is an extendo token (to be
|
||||
* described later). To accomodate token lengths above 255, each normal
|
||||
* token (e=0) can be followed by 0 or more extendo tokens (e=1) with
|
||||
* the same type. Right now only kLiteral Tokens have extendo tokens.
|
||||
* Each extendo token provides the next 8 higher bits for the length.
|
||||
* If a kLiteral token is followed by 2 extendo tokens then, then the
|
||||
* llllllll of the next extendo token contains bits 8-15 of the length
|
||||
* and the last extendo token contains bits 16-23 of the length.
|
||||
*/
|
||||
UnicodeString tokens;
|
||||
|
||||
/*
|
||||
* The characters of the kLiteral tokens are concatenated together here.
|
||||
* The first characters go with the first kLiteral token, the next
|
||||
* characters go with the next kLiteral token etc.
|
||||
*/
|
||||
UnicodeString literals;
|
||||
UBool hasCurrencyToken;
|
||||
UBool hasPercentToken;
|
||||
UBool hasPermillToken;
|
||||
int32_t char32Count;
|
||||
void add(ETokenType t, uint8_t count);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* An iterator over the tokens in an AffixPattern instance.
|
||||
*/
|
||||
class U_I18N_API AffixPatternIterator : public UMemory {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Using an iterator without first calling iterator on an AffixPattern
|
||||
* instance to initialize the iterator results in
|
||||
* undefined behavior.
|
||||
*/
|
||||
AffixPatternIterator() : nextLiteralIndex(0), lastLiteralLength(0), nextTokenIndex(0), tokens(NULL), literals(NULL) { }
|
||||
/**
|
||||
* Advances this iterator to the next token. Returns FALSE when there
|
||||
* are no more tokens. Calling the other methods after nextToken()
|
||||
* returns FALSE results in undefined behavior.
|
||||
*/
|
||||
UBool nextToken();
|
||||
|
||||
/**
|
||||
* Returns the type of token.
|
||||
*/
|
||||
AffixPattern::ETokenType getTokenType() const;
|
||||
|
||||
/**
|
||||
* For literal tokens, returns the literal string. Calling this for
|
||||
* other token types results in undefined behavior.
|
||||
* @param result replaced with a read-only alias to the literal string.
|
||||
* @return result
|
||||
*/
|
||||
UnicodeString &getLiteral(UnicodeString &result) const;
|
||||
|
||||
/**
|
||||
* Returns the token length. Usually 1, but for currency tokens may
|
||||
* be 2 for ISO code and 3 for long form.
|
||||
*/
|
||||
int32_t getTokenLength() const;
|
||||
private:
|
||||
int32_t nextLiteralIndex;
|
||||
int32_t lastLiteralLength;
|
||||
int32_t nextTokenIndex;
|
||||
const UnicodeString *tokens;
|
||||
const UnicodeString *literals;
|
||||
friend class AffixPattern;
|
||||
AffixPatternIterator(const AffixPatternIterator &);
|
||||
AffixPatternIterator &operator=(const AffixPatternIterator &);
|
||||
};
|
||||
|
||||
/**
|
||||
* A locale aware class that converts locale independent AffixPattern
|
||||
* instances into locale dependent PluralAffix instances.
|
||||
*/
|
||||
class U_I18N_API AffixPatternParser : public UMemory {
|
||||
public:
|
||||
AffixPatternParser();
|
||||
AffixPatternParser(const DecimalFormatSymbols &symbols);
|
||||
void setDecimalFormatSymbols(const DecimalFormatSymbols &symbols);
|
||||
|
||||
/**
|
||||
* Parses affixPattern appending the result to appendTo.
|
||||
* @param affixPattern The affix pattern.
|
||||
* @param currencyAffixInfo contains the currency forms.
|
||||
* @param appendTo The result of parsing affixPattern is appended here.
|
||||
* @param status any error returned here.
|
||||
* @return appendTo.
|
||||
*/
|
||||
PluralAffix &parse(
|
||||
const AffixPattern &affixPattern,
|
||||
const CurrencyAffixInfo ¤cyAffixInfo,
|
||||
PluralAffix &appendTo,
|
||||
UErrorCode &status) const;
|
||||
|
||||
UBool equals(const AffixPatternParser &other) const {
|
||||
return (fPercent == other.fPercent)
|
||||
&& (fPermill == other.fPermill)
|
||||
&& (fNegative == other.fNegative)
|
||||
&& (fPositive == other.fPositive);
|
||||
}
|
||||
|
||||
private:
|
||||
UnicodeString fPercent;
|
||||
UnicodeString fPermill;
|
||||
UnicodeString fNegative;
|
||||
UnicodeString fPositive;
|
||||
};
|
||||
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
#endif // __AFFIX_PATTERN_PARSER_H__
|
||||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
@ -511,8 +511,8 @@ BucketList *AlphabeticIndex::createBucketList(UErrorCode &errorCode) const {
|
|||
ces, errorCode) &&
|
||||
current.charAt(current.length() - 1) != 0xFFFF /* !current.endsWith("\uffff") */) {
|
||||
// "AE-ligature" or "Sch" etc.
|
||||
for (int32_t i = bucketList->size() - 2;; --i) {
|
||||
Bucket *singleBucket = getBucket(*bucketList, i);
|
||||
for (int32_t j = bucketList->size() - 2;; --j) {
|
||||
Bucket *singleBucket = getBucket(*bucketList, j);
|
||||
if (singleBucket->labelType_ != U_ALPHAINDEX_NORMAL) {
|
||||
// There is no single-character bucket since the last
|
||||
// underflow or inflow label.
|
||||
|
|
@ -608,8 +608,8 @@ BucketList *AlphabeticIndex::createBucketList(UErrorCode &errorCode) const {
|
|||
}
|
||||
// Do not call publicBucketList->setDeleter():
|
||||
// This vector shares its objects with the bucketList.
|
||||
for (int32_t i = 0; i < bucketList->size(); ++i) {
|
||||
bucket = getBucket(*bucketList, i);
|
||||
for (int32_t j = 0; j < bucketList->size(); ++j) {
|
||||
bucket = getBucket(*bucketList, j);
|
||||
if (bucket->displayBucket_ == NULL) {
|
||||
publicBucketList->addElement(bucket, errorCode);
|
||||
}
|
||||
|
|
@ -725,7 +725,7 @@ void AlphabeticIndex::addIndexExemplars(const Locale &locale, UErrorCode &status
|
|||
}
|
||||
|
||||
// question: should we add auxiliary exemplars?
|
||||
if (exemplars.containsSome(0x61, 0x7A) /* a-z */ || exemplars.size() == 0) {
|
||||
if (exemplars.containsSome(0x61, 0x7A) /* a-z */ || exemplars.isEmpty()) {
|
||||
exemplars.add(0x61, 0x7A);
|
||||
}
|
||||
if (exemplars.containsSome(0xAC00, 0xD7A3)) { // Hangul syllables
|
||||
|
|
@ -740,14 +740,9 @@ void AlphabeticIndex::addIndexExemplars(const Locale &locale, UErrorCode &status
|
|||
// cut down to small list
|
||||
// make use of the fact that Ethiopic is allocated in 8's, where
|
||||
// the base is 0 mod 8.
|
||||
UnicodeSet ethiopic(
|
||||
UNICODE_STRING_SIMPLE("[[:Block=Ethiopic:]&[:Script=Ethiopic:]]"), status);
|
||||
UnicodeSetIterator it(ethiopic);
|
||||
while (it.next() && !it.isString()) {
|
||||
if ((it.getCodepoint() & 0x7) != 0) {
|
||||
exemplars.remove(it.getCodepoint());
|
||||
}
|
||||
}
|
||||
UnicodeSet ethiopic(UnicodeString(u"[ሀለሐመሠረሰሸቀቈቐቘበቨተቸኀኈነኘአከኰኸዀወዐዘዠየደዸጀገጐጘጠጨጰጸፀፈፐፘ]"), status);
|
||||
ethiopic.retainAll(exemplars);
|
||||
exemplars.remove(u'ሀ', 0x137F).addAll(ethiopic);
|
||||
}
|
||||
|
||||
// Upper-case any that aren't already so.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*****************************************************************
|
||||
|
|
@ -31,9 +31,13 @@
|
|||
|
||||
static const UChar TARGET_SEP = 45; // '-'
|
||||
static const UChar VARIANT_SEP = 47; // '/'
|
||||
static const UChar ANY[] = {65,110,121,0}; // "Any"
|
||||
static const UChar ANY[] = {0x41,0x6E,0x79,0}; // "Any"
|
||||
static const UChar NULL_ID[] = {78,117,108,108,0}; // "Null"
|
||||
static const UChar LATIN_PIVOT[] = {45,76,97,116,105,110,59,76,97,116,105,110,45,0}; // "-Latin;Latin-"
|
||||
static const UChar LATIN_PIVOT[] = {0x2D,0x4C,0x61,0x74,0x6E,0x3B,0x4C,0x61,0x74,0x6E,0x2D,0}; // "-Latn;Latn-"
|
||||
|
||||
// initial size for an Any-XXXX transform's cache of script-XXXX transforms
|
||||
// (will grow as necessary, but we don't expect to have source text with more than 7 scripts)
|
||||
#define ANY_TRANS_CACHE_INIT_SIZE 7
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
|
|
@ -186,7 +190,7 @@ AnyTransliterator::AnyTransliterator(const UnicodeString& id,
|
|||
Transliterator(id, NULL),
|
||||
targetScript(theTargetScript)
|
||||
{
|
||||
cache = uhash_open(uhash_hashLong, uhash_compareLong, NULL, &ec);
|
||||
cache = uhash_openSize(uhash_hashLong, uhash_compareLong, NULL, ANY_TRANS_CACHE_INIT_SIZE, &ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -212,7 +216,7 @@ AnyTransliterator::AnyTransliterator(const AnyTransliterator& o) :
|
|||
{
|
||||
// Don't copy the cache contents
|
||||
UErrorCode ec = U_ZERO_ERROR;
|
||||
cache = uhash_open(uhash_hashLong, uhash_compareLong, NULL, &ec);
|
||||
cache = uhash_openSize(uhash_hashLong, uhash_compareLong, NULL, ANY_TRANS_CACHE_INIT_SIZE, &ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -286,7 +290,7 @@ Transliterator* AnyTransliterator::getTransliterator(UScriptCode source) const {
|
|||
}
|
||||
if (t == NULL) {
|
||||
UErrorCode ec = U_ZERO_ERROR;
|
||||
UnicodeString sourceName(uscript_getName(source), -1, US_INV);
|
||||
UnicodeString sourceName(uscript_getShortName(source), -1, US_INV);
|
||||
UnicodeString id(sourceName);
|
||||
id.append(TARGET_SEP).append(target);
|
||||
|
||||
|
|
@ -387,12 +391,12 @@ void AnyTransliterator::registerIDs() {
|
|||
UnicodeString id;
|
||||
TransliteratorIDParser::STVtoID(UnicodeString(TRUE, ANY, 3), target, variant, id);
|
||||
ec = U_ZERO_ERROR;
|
||||
AnyTransliterator* t = new AnyTransliterator(id, target, variant,
|
||||
AnyTransliterator* tl = new AnyTransliterator(id, target, variant,
|
||||
targetScript, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
delete t;
|
||||
delete tl;
|
||||
} else {
|
||||
Transliterator::_registerInstance(t);
|
||||
Transliterator::_registerInstance(tl);
|
||||
Transliterator::_registerSpecialInverse(target, UnicodeString(TRUE, NULL_ID, 4), FALSE);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
***********************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/************************************************************************
|
||||
* Copyright (C) 1996-2012, International Business Machines Corporation
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/************************************************************************
|
||||
* Copyright (C) 1996-2008, International Business Machines Corporation *
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
* file name: bocsu.cpp
|
||||
* encoding: US-ASCII
|
||||
* encoding: UTF-8
|
||||
* tab size: 8 (not used)
|
||||
* indentation:4
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
* file name: bocsu.h
|
||||
* encoding: US-ASCII
|
||||
* encoding: UTF-8
|
||||
* tab size: 8 (not used)
|
||||
* indentation:4
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
**********************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
**********************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
********************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
@ -8,12 +8,12 @@
|
|||
*
|
||||
* File CALENDAR.CPP
|
||||
*
|
||||
* Modification History:
|
||||
* Modification History:
|
||||
*
|
||||
* Date Name Description
|
||||
* 02/03/97 clhuang Creation.
|
||||
* 04/22/97 aliu Cleaned up, fixed memory leak, made
|
||||
* setWeekCountData() more robust.
|
||||
* 04/22/97 aliu Cleaned up, fixed memory leak, made
|
||||
* setWeekCountData() more robust.
|
||||
* Moved platform code to TPlatformUtilities.
|
||||
* 05/01/97 aliu Made equals(), before(), after() arguments const.
|
||||
* 05/20/97 aliu Changed logic of when to compute fields and time
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include "utypeinfo.h" // for 'typeid' to work
|
||||
#include "utypeinfo.h" // for 'typeid' to work
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
|
|
@ -66,10 +66,8 @@
|
|||
#if !UCONFIG_NO_SERVICE
|
||||
static icu::ICULocaleService* gService = NULL;
|
||||
static icu::UInitOnce gServiceInitOnce = U_INITONCE_INITIALIZER;
|
||||
#endif
|
||||
|
||||
// INTERNAL - for cleanup
|
||||
|
||||
U_CDECL_BEGIN
|
||||
static UBool calendar_cleanup(void) {
|
||||
#if !UCONFIG_NO_SERVICE
|
||||
|
|
@ -82,6 +80,7 @@ static UBool calendar_cleanup(void) {
|
|||
return TRUE;
|
||||
}
|
||||
U_CDECL_END
|
||||
#endif
|
||||
|
||||
// ------------------------------------------
|
||||
//
|
||||
|
|
@ -93,9 +92,9 @@ U_CDECL_END
|
|||
|
||||
#if defined( U_DEBUG_CALSVC ) || defined (U_DEBUG_CAL)
|
||||
|
||||
/**
|
||||
* fldName was removed as a duplicate implementation.
|
||||
* use udbg_ services instead,
|
||||
/**
|
||||
* fldName was removed as a duplicate implementation.
|
||||
* use udbg_ services instead,
|
||||
* which depend on include files and library from ../tools/toolutil, the following circular link:
|
||||
* CPPFLAGS+=-I$(top_srcdir)/tools/toolutil
|
||||
* LIBS+=$(LIBICUTOOLUTIL)
|
||||
|
|
@ -123,7 +122,7 @@ void ucal_dump(const Calendar &cal) {
|
|||
void Calendar::dump() const {
|
||||
int i;
|
||||
fprintf(stderr, "@calendar=%s, timeset=%c, fieldset=%c, allfields=%c, virtualset=%c, t=%.2f",
|
||||
getType(), fIsTimeSet?'y':'n', fAreFieldsSet?'y':'n', fAreAllFieldsSet?'y':'n',
|
||||
getType(), fIsTimeSet?'y':'n', fAreFieldsSet?'y':'n', fAreAllFieldsSet?'y':'n',
|
||||
fAreFieldsVirtuallySet?'y':'n',
|
||||
fTime);
|
||||
|
||||
|
|
@ -135,9 +134,9 @@ void Calendar::dump() const {
|
|||
fprintf(stderr, " %25s: %-11ld", f, fFields[i]);
|
||||
if(fStamp[i] == kUnset) {
|
||||
fprintf(stderr, " (unset) ");
|
||||
} else if(fStamp[i] == kInternallySet) {
|
||||
} else if(fStamp[i] == kInternallySet) {
|
||||
fprintf(stderr, " (internally set) ");
|
||||
//} else if(fStamp[i] == kInternalDefault) {
|
||||
//} else if(fStamp[i] == kInternalDefault) {
|
||||
// fprintf(stderr, " (internal default) ");
|
||||
} else {
|
||||
fprintf(stderr, " %%%d ", fStamp[i]);
|
||||
|
|
@ -213,7 +212,7 @@ const SharedCalendar *LocaleCacheKey<SharedCalendar>::createObject(
|
|||
const void * /*unusedCreationContext*/, UErrorCode &status) const {
|
||||
Calendar *calendar = Calendar::makeInstance(fLoc, status);
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
SharedCalendar *shared = new SharedCalendar(calendar);
|
||||
if (shared == NULL) {
|
||||
|
|
@ -234,7 +233,9 @@ static ECalType getCalendarType(const char *s) {
|
|||
return CALTYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
static UBool isStandardSupportedKeyword(const char *keyword, UErrorCode& status) {
|
||||
#if !UCONFIG_NO_SERVICE
|
||||
// Only used with service registration.
|
||||
static UBool isStandardSupportedKeyword(const char *keyword, UErrorCode& status) {
|
||||
if(U_FAILURE(status)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -242,6 +243,7 @@ static UBool isStandardSupportedKeyword(const char *keyword, UErrorCode& status)
|
|||
return (calType != CALTYPE_UNKNOWN);
|
||||
}
|
||||
|
||||
// only used with service registration.
|
||||
static void getCalendarKeyword(const UnicodeString &id, char *targetBuffer, int32_t targetBufferSize) {
|
||||
UnicodeString calendarKeyword = UNICODE_STRING_SIMPLE("calendar=");
|
||||
int32_t calKeyLen = calendarKeyword.length();
|
||||
|
|
@ -255,6 +257,7 @@ static void getCalendarKeyword(const UnicodeString &id, char *targetBuffer, int3
|
|||
}
|
||||
targetBuffer[keyLen] = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static ECalType getCalendarTypeForLocale(const char *locid) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
|
@ -291,7 +294,7 @@ static ECalType getCalendarTypeForLocale(const char *locid) {
|
|||
if (U_FAILURE(status)) {
|
||||
return CALTYPE_GREGORIAN;
|
||||
}
|
||||
|
||||
|
||||
// Read preferred calendar values from supplementalData calendarPreference
|
||||
UResourceBundle *rb = ures_openDirect(NULL, "supplementalData", &status);
|
||||
ures_getByKey(rb, "calendarPreferenceData", rb, &status);
|
||||
|
|
@ -394,7 +397,7 @@ static Calendar *createStandardCalendar(ECalType calType, const Locale &loc, UEr
|
|||
// -------------------------------------
|
||||
|
||||
/**
|
||||
* a Calendar Factory which creates the "basic" calendar types, that is, those
|
||||
* a Calendar Factory which creates the "basic" calendar types, that is, those
|
||||
* shipped with ICU.
|
||||
*/
|
||||
class BasicCalendarFactory : public LocaleKeyFactory {
|
||||
|
|
@ -408,7 +411,7 @@ public:
|
|||
virtual ~BasicCalendarFactory();
|
||||
|
||||
protected:
|
||||
//virtual UBool isSupportedID( const UnicodeString& id, UErrorCode& status) const {
|
||||
//virtual UBool isSupportedID( const UnicodeString& id, UErrorCode& status) const {
|
||||
// if(U_FAILURE(status)) {
|
||||
// return FALSE;
|
||||
// }
|
||||
|
|
@ -466,7 +469,7 @@ protected:
|
|||
|
||||
BasicCalendarFactory::~BasicCalendarFactory() {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* A factory which looks up the DefaultCalendar resource to determine which class of calendar to use
|
||||
*/
|
||||
|
||||
|
|
@ -510,7 +513,7 @@ public:
|
|||
virtual UObject* cloneInstance(UObject* instance) const {
|
||||
UnicodeString *s = dynamic_cast<UnicodeString *>(instance);
|
||||
if(s != NULL) {
|
||||
return s->clone();
|
||||
return s->clone();
|
||||
} else {
|
||||
#ifdef U_DEBUG_CALSVC_F
|
||||
UErrorCode status2 = U_ZERO_ERROR;
|
||||
|
|
@ -573,7 +576,7 @@ initCalendarService(UErrorCode &status)
|
|||
fprintf(stderr, "Registering classes..\n");
|
||||
#endif
|
||||
|
||||
// Register all basic instances.
|
||||
// Register all basic instances.
|
||||
gService->registerFactory(new BasicCalendarFactory(),status);
|
||||
|
||||
#ifdef U_DEBUG_CALSVC
|
||||
|
|
@ -589,7 +592,7 @@ initCalendarService(UErrorCode &status)
|
|||
}
|
||||
}
|
||||
|
||||
static ICULocaleService*
|
||||
static ICULocaleService*
|
||||
getCalendarService(UErrorCode &status)
|
||||
{
|
||||
umtx_initOnce(gServiceInitOnce, &initCalendarService, status);
|
||||
|
|
@ -705,6 +708,8 @@ fZone(NULL),
|
|||
fRepeatedWallTime(UCAL_WALLTIME_LAST),
|
||||
fSkippedWallTime(UCAL_WALLTIME_LAST)
|
||||
{
|
||||
validLocale[0] = 0;
|
||||
actualLocale[0] = 0;
|
||||
clear();
|
||||
if (U_FAILURE(success)) {
|
||||
return;
|
||||
|
|
@ -731,6 +736,8 @@ fZone(NULL),
|
|||
fRepeatedWallTime(UCAL_WALLTIME_LAST),
|
||||
fSkippedWallTime(UCAL_WALLTIME_LAST)
|
||||
{
|
||||
validLocale[0] = 0;
|
||||
actualLocale[0] = 0;
|
||||
if (U_FAILURE(success)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -743,7 +750,7 @@ fSkippedWallTime(UCAL_WALLTIME_LAST)
|
|||
return;
|
||||
}
|
||||
|
||||
clear();
|
||||
clear();
|
||||
fZone = zone;
|
||||
setWeekData(aLocale, NULL, success);
|
||||
}
|
||||
|
|
@ -763,6 +770,8 @@ fZone(NULL),
|
|||
fRepeatedWallTime(UCAL_WALLTIME_LAST),
|
||||
fSkippedWallTime(UCAL_WALLTIME_LAST)
|
||||
{
|
||||
validLocale[0] = 0;
|
||||
actualLocale[0] = 0;
|
||||
if (U_FAILURE(success)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -819,8 +828,10 @@ Calendar::operator=(const Calendar &right)
|
|||
fWeekendCease = right.fWeekendCease;
|
||||
fWeekendCeaseMillis = right.fWeekendCeaseMillis;
|
||||
fNextStamp = right.fNextStamp;
|
||||
uprv_strcpy(validLocale, right.validLocale);
|
||||
uprv_strcpy(actualLocale, right.actualLocale);
|
||||
uprv_strncpy(validLocale, right.validLocale, sizeof(validLocale));
|
||||
uprv_strncpy(actualLocale, right.actualLocale, sizeof(actualLocale));
|
||||
validLocale[sizeof(validLocale)-1] = 0;
|
||||
actualLocale[sizeof(validLocale)-1] = 0;
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
|
@ -850,7 +861,7 @@ Calendar::createInstance(const Locale& aLocale, UErrorCode& success)
|
|||
return createInstance(TimeZone::createDefault(), aLocale, success);
|
||||
}
|
||||
|
||||
// ------------------------------------- Adopting
|
||||
// ------------------------------------- Adopting
|
||||
|
||||
// Note: this is the bottleneck that actually calls the service routines.
|
||||
|
||||
|
|
@ -903,7 +914,7 @@ Calendar::makeInstance(const Locale& aLocale, UErrorCode& success) {
|
|||
c = (Calendar*)getCalendarService(success)->get(l, LocaleKey::KIND_ANY, &actualLoc2, success);
|
||||
|
||||
if(U_FAILURE(success) || !c) {
|
||||
if(U_SUCCESS(success)) {
|
||||
if(U_SUCCESS(success)) {
|
||||
success = U_INTERNAL_PROGRAM_ERROR; // Propagate some err
|
||||
}
|
||||
return NULL;
|
||||
|
|
@ -911,7 +922,7 @@ Calendar::makeInstance(const Locale& aLocale, UErrorCode& success) {
|
|||
|
||||
str = dynamic_cast<const UnicodeString*>(c);
|
||||
if(str != NULL) {
|
||||
// recursed! Second lookup returned a UnicodeString.
|
||||
// recursed! Second lookup returned a UnicodeString.
|
||||
// Perhaps DefaultCalendar{} was set to another locale.
|
||||
#ifdef U_DEBUG_CALSVC
|
||||
char tmp[200];
|
||||
|
|
@ -985,7 +996,7 @@ Calendar::createInstance(const TimeZone& zone, const Locale& aLocale, UErrorCode
|
|||
if(U_SUCCESS(success) && c) {
|
||||
c->setTimeZone(zone);
|
||||
}
|
||||
return c;
|
||||
return c;
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
|
|
@ -1017,7 +1028,7 @@ Calendar::operator==(const Calendar& that) const
|
|||
U_SUCCESS(status);
|
||||
}
|
||||
|
||||
UBool
|
||||
UBool
|
||||
Calendar::isEquivalentTo(const Calendar& other) const
|
||||
{
|
||||
return typeid(*this) == typeid(other) &&
|
||||
|
|
@ -1099,13 +1110,13 @@ Calendar::getNow()
|
|||
* Gets this Calendar's current time as a long.
|
||||
* @return the current time as UTC milliseconds from the epoch.
|
||||
*/
|
||||
double
|
||||
double
|
||||
Calendar::getTimeInMillis(UErrorCode& status) const
|
||||
{
|
||||
if(U_FAILURE(status))
|
||||
if(U_FAILURE(status))
|
||||
return 0.0;
|
||||
|
||||
if ( ! fIsTimeSet)
|
||||
if ( ! fIsTimeSet)
|
||||
((Calendar*)this)->updateTime(status);
|
||||
|
||||
/* Test for buffer overflows */
|
||||
|
|
@ -1124,9 +1135,9 @@ Calendar::getTimeInMillis(UErrorCode& status) const
|
|||
* when in lenient mode the out of range values are pinned to their respective min/max.
|
||||
* @param date the new time in UTC milliseconds from the epoch.
|
||||
*/
|
||||
void
|
||||
void
|
||||
Calendar::setTimeInMillis( double millis, UErrorCode& status ) {
|
||||
if(U_FAILURE(status))
|
||||
if(U_FAILURE(status))
|
||||
return;
|
||||
|
||||
if (millis > MAX_MILLIS) {
|
||||
|
|
@ -1154,7 +1165,7 @@ Calendar::setTimeInMillis( double millis, UErrorCode& status ) {
|
|||
fStamp[i] = kUnset;
|
||||
fIsSet[i] = FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1479,7 +1490,7 @@ void Calendar::computeFields(UErrorCode &ec)
|
|||
double localMillis = internalGetTime();
|
||||
int32_t rawOffset, dstOffset;
|
||||
getTimeZone().getOffset(localMillis, FALSE, rawOffset, dstOffset, ec);
|
||||
localMillis += (rawOffset + dstOffset);
|
||||
localMillis += (rawOffset + dstOffset);
|
||||
|
||||
// Mark fields as set. Do this before calling handleComputeFields().
|
||||
uint32_t mask = //fInternalSetMask;
|
||||
|
|
@ -1488,7 +1499,7 @@ void Calendar::computeFields(UErrorCode &ec)
|
|||
(1 << UCAL_MONTH) |
|
||||
(1 << UCAL_DAY_OF_MONTH) | // = UCAL_DATE
|
||||
(1 << UCAL_DAY_OF_YEAR) |
|
||||
(1 << UCAL_EXTENDED_YEAR);
|
||||
(1 << UCAL_EXTENDED_YEAR);
|
||||
|
||||
for (int32_t i=0; i<UCAL_FIELD_COUNT; ++i) {
|
||||
if ((mask & 1) == 0) {
|
||||
|
|
@ -1517,7 +1528,7 @@ void Calendar::computeFields(UErrorCode &ec)
|
|||
#if defined (U_DEBUG_CAL)
|
||||
//fprintf(stderr, "%s:%d- Hmm! Jules @ %d, as per %.0lf millis\n",
|
||||
//__FILE__, __LINE__, fFields[UCAL_JULIAN_DAY], localMillis);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
computeGregorianAndDOWFields(fFields[UCAL_JULIAN_DAY], ec);
|
||||
|
||||
|
|
@ -1615,7 +1626,7 @@ void Calendar::computeGregorianFields(int32_t julianDay, UErrorCode & /* ec */)
|
|||
* proleptic Gregorian calendar, which has no field larger than a year.
|
||||
*/
|
||||
void Calendar::computeWeekFields(UErrorCode &ec) {
|
||||
if(U_FAILURE(ec)) {
|
||||
if(U_FAILURE(ec)) {
|
||||
return;
|
||||
}
|
||||
int32_t eyear = fFields[UCAL_EXTENDED_YEAR];
|
||||
|
|
@ -1678,7 +1689,7 @@ void Calendar::computeWeekFields(UErrorCode &ec) {
|
|||
fFields[UCAL_WEEK_OF_MONTH] = weekNumber(dayOfMonth, dayOfWeek);
|
||||
fFields[UCAL_DAY_OF_WEEK_IN_MONTH] = (dayOfMonth-1) / 7 + 1;
|
||||
#if defined (U_DEBUG_CAL)
|
||||
if(fFields[UCAL_DAY_OF_WEEK_IN_MONTH]==0) fprintf(stderr, "%s:%d: DOWIM %d on %g\n",
|
||||
if(fFields[UCAL_DAY_OF_WEEK_IN_MONTH]==0) fprintf(stderr, "%s:%d: DOWIM %d on %g\n",
|
||||
__FILE__, __LINE__,fFields[UCAL_DAY_OF_WEEK_IN_MONTH], fTime);
|
||||
#endif
|
||||
}
|
||||
|
|
@ -1723,7 +1734,7 @@ void Calendar::handleComputeFields(int32_t /* julianDay */, UErrorCode &/* statu
|
|||
// -------------------------------------
|
||||
|
||||
|
||||
void Calendar::roll(EDateFields field, int32_t amount, UErrorCode& status)
|
||||
void Calendar::roll(EDateFields field, int32_t amount, UErrorCode& status)
|
||||
{
|
||||
roll((UCalendarDateFields)field, amount, status);
|
||||
}
|
||||
|
|
@ -2061,7 +2072,7 @@ void Calendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& statu
|
|||
default:
|
||||
// Other fields cannot be rolled by this method
|
||||
#if defined (U_DEBUG_CAL)
|
||||
fprintf(stderr, "%s:%d: ILLEGAL ARG because of roll on non-rollable field %s\n",
|
||||
fprintf(stderr, "%s:%d: ILLEGAL ARG because of roll on non-rollable field %s\n",
|
||||
__FILE__, __LINE__,fldName(field));
|
||||
#endif
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
|
|
@ -2252,7 +2263,7 @@ void Calendar::add(UCalendarDateFields field, int32_t amount, UErrorCode& status
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
|
|
@ -2617,7 +2628,7 @@ Calendar::isWeekend(void) const
|
|||
|
||||
// ------------------------------------- limits
|
||||
|
||||
int32_t
|
||||
int32_t
|
||||
Calendar::getMinimum(EDateFields field) const {
|
||||
return getLimit((UCalendarDateFields) field,UCAL_LIMIT_MINIMUM);
|
||||
}
|
||||
|
|
@ -2668,7 +2679,7 @@ Calendar::getLeastMaximum(UCalendarDateFields field) const
|
|||
}
|
||||
|
||||
// -------------------------------------
|
||||
int32_t
|
||||
int32_t
|
||||
Calendar::getActualMinimum(EDateFields field, UErrorCode& status) const
|
||||
{
|
||||
return getActualMinimum((UCalendarDateFields) field, status);
|
||||
|
|
@ -2744,7 +2755,7 @@ Calendar::getActualMinimum(UCalendarDateFields field, UErrorCode& status) const
|
|||
work->set(field, fieldValue);
|
||||
if (work->get(field, status) != fieldValue) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = fieldValue;
|
||||
fieldValue--;
|
||||
|
|
@ -2800,7 +2811,7 @@ void Calendar::validateField(UCalendarDateFields field, UErrorCode &status) {
|
|||
case UCAL_DAY_OF_WEEK_IN_MONTH:
|
||||
if (internalGet(field) == 0) {
|
||||
#if defined (U_DEBUG_CAL)
|
||||
fprintf(stderr, "%s:%d: ILLEGAL ARG because DOW in month cannot be 0\n",
|
||||
fprintf(stderr, "%s:%d: ILLEGAL ARG because DOW in month cannot be 0\n",
|
||||
__FILE__, __LINE__);
|
||||
#endif
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR; // "DAY_OF_WEEK_IN_MONTH cannot be zero"
|
||||
|
|
@ -2826,7 +2837,7 @@ void Calendar::validateField(UCalendarDateFields field, int32_t min, int32_t max
|
|||
int32_t value = fFields[field];
|
||||
if (value < min || value > max) {
|
||||
#if defined (U_DEBUG_CAL)
|
||||
fprintf(stderr, "%s:%d: ILLEGAL ARG because of field %s out of range %d..%d at %d\n",
|
||||
fprintf(stderr, "%s:%d: ILLEGAL ARG because of field %s out of range %d..%d at %d\n",
|
||||
__FILE__, __LINE__,fldName(field),min,max,value);
|
||||
#endif
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
|
|
@ -2892,7 +2903,7 @@ linesInGroup:
|
|||
}
|
||||
|
||||
const UFieldResolutionTable Calendar::kDatePrecedence[] =
|
||||
{
|
||||
{
|
||||
{
|
||||
{ UCAL_DAY_OF_MONTH, kResolveSTOP },
|
||||
{ UCAL_WEEK_OF_YEAR, UCAL_DAY_OF_WEEK, kResolveSTOP },
|
||||
|
|
@ -2913,12 +2924,12 @@ const UFieldResolutionTable Calendar::kDatePrecedence[] =
|
|||
{ kResolveRemap | UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_DAY_OF_WEEK, kResolveSTOP },
|
||||
{ kResolveRemap | UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_DOW_LOCAL, kResolveSTOP },
|
||||
{ kResolveSTOP }
|
||||
},
|
||||
},
|
||||
{{kResolveSTOP}}
|
||||
};
|
||||
|
||||
|
||||
const UFieldResolutionTable Calendar::kDOWPrecedence[] =
|
||||
const UFieldResolutionTable Calendar::kDOWPrecedence[] =
|
||||
{
|
||||
{
|
||||
{ UCAL_DAY_OF_WEEK,kResolveSTOP, kResolveSTOP },
|
||||
|
|
@ -2929,7 +2940,7 @@ const UFieldResolutionTable Calendar::kDOWPrecedence[] =
|
|||
};
|
||||
|
||||
// precedence for calculating a year
|
||||
const UFieldResolutionTable Calendar::kYearPrecedence[] =
|
||||
const UFieldResolutionTable Calendar::kYearPrecedence[] =
|
||||
{
|
||||
{
|
||||
{ UCAL_YEAR, kResolveSTOP },
|
||||
|
|
@ -2966,7 +2977,7 @@ void Calendar::computeTime(UErrorCode& status) {
|
|||
// }
|
||||
#endif
|
||||
|
||||
int32_t millisInDay;
|
||||
double millisInDay;
|
||||
|
||||
// We only use MILLISECONDS_IN_DAY if it has been set by the user.
|
||||
// This makes it possible for the caller to set the calendar to a
|
||||
|
|
@ -3086,10 +3097,10 @@ UBool Calendar::getImmediatePreviousZoneTransition(UDate base, UDate *transition
|
|||
* reflects local zone wall time.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
int32_t Calendar::computeMillisInDay() {
|
||||
double Calendar::computeMillisInDay() {
|
||||
// Do the time portion of the conversion.
|
||||
|
||||
int32_t millisInDay = 0;
|
||||
double millisInDay = 0;
|
||||
|
||||
// Find the best set of fields specifying the time of day. There
|
||||
// are only two possibilities here; the HOUR_OF_DAY or the
|
||||
|
|
@ -3131,7 +3142,7 @@ int32_t Calendar::computeMillisInDay() {
|
|||
* or range.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
int32_t Calendar::computeZoneOffset(double millis, int32_t millisInDay, UErrorCode &ec) {
|
||||
int32_t Calendar::computeZoneOffset(double millis, double millisInDay, UErrorCode &ec) {
|
||||
int32_t rawOffset, dstOffset;
|
||||
UDate wall = millis + millisInDay;
|
||||
BasicTimeZone* btz = getBasicTimeZone();
|
||||
|
|
@ -3178,7 +3189,7 @@ int32_t Calendar::computeZoneOffset(double millis, int32_t millisInDay, UErrorCo
|
|||
return rawOffset + dstOffset;
|
||||
}
|
||||
|
||||
int32_t Calendar::computeJulianDay()
|
||||
int32_t Calendar::computeJulianDay()
|
||||
{
|
||||
// We want to see if any of the date fields is newer than the
|
||||
// JULIAN_DAY. If not, then we use JULIAN_DAY. If so, then we do
|
||||
|
|
@ -3212,17 +3223,17 @@ int32_t Calendar::handleComputeJulianDay(UCalendarDateFields bestField) {
|
|||
bestField == UCAL_DAY_OF_WEEK_IN_MONTH);
|
||||
int32_t year;
|
||||
|
||||
if (bestField == UCAL_WEEK_OF_YEAR) {
|
||||
year = internalGet(UCAL_YEAR_WOY, handleGetExtendedYear());
|
||||
internalSet(UCAL_EXTENDED_YEAR, year);
|
||||
if (bestField == UCAL_WEEK_OF_YEAR && newerField(UCAL_YEAR_WOY, UCAL_YEAR) == UCAL_YEAR_WOY) {
|
||||
year = internalGet(UCAL_YEAR_WOY);
|
||||
} else {
|
||||
year = handleGetExtendedYear();
|
||||
internalSet(UCAL_EXTENDED_YEAR, year);
|
||||
}
|
||||
|
||||
#if defined (U_DEBUG_CAL)
|
||||
internalSet(UCAL_EXTENDED_YEAR, year);
|
||||
|
||||
#if defined (U_DEBUG_CAL)
|
||||
fprintf(stderr, "%s:%d: bestField= %s - y=%d\n", __FILE__, __LINE__, fldName(bestField), year);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Get the Julian day of the day BEFORE the start of this year.
|
||||
// If useMonth is true, get the day before the start of the month.
|
||||
|
|
@ -3304,9 +3315,9 @@ int32_t Calendar::handleComputeJulianDay(UCalendarDateFields bestField) {
|
|||
date += ((monthLength - date) / 7 + dim + 1) * 7;
|
||||
}
|
||||
} else {
|
||||
#if defined (U_DEBUG_CAL)
|
||||
#if defined (U_DEBUG_CAL)
|
||||
fprintf(stderr, "%s:%d - bf= %s\n", __FILE__, __LINE__, fldName(bestField));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if(bestField == UCAL_WEEK_OF_YEAR) { // ------------------------------------- WOY -------------
|
||||
if(!isSet(UCAL_YEAR_WOY) || // YWOY not set at all or
|
||||
|
|
@ -3317,30 +3328,30 @@ int32_t Calendar::handleComputeJulianDay(UCalendarDateFields bestField) {
|
|||
int32_t woy = internalGet(bestField);
|
||||
|
||||
int32_t nextJulianDay = handleComputeMonthStart(year+1, 0, FALSE); // jd of day before jan 1
|
||||
int32_t nextFirst = julianDayToDayOfWeek(nextJulianDay + 1) - firstDayOfWeek;
|
||||
int32_t nextFirst = julianDayToDayOfWeek(nextJulianDay + 1) - firstDayOfWeek;
|
||||
|
||||
if (nextFirst < 0) { // 0..6 ldow of Jan 1
|
||||
nextFirst += 7;
|
||||
}
|
||||
|
||||
if(woy==1) { // FIRST WEEK ---------------------------------
|
||||
#if defined (U_DEBUG_CAL)
|
||||
fprintf(stderr, "%s:%d - woy=%d, yp=%d, nj(%d)=%d, nf=%d", __FILE__, __LINE__,
|
||||
internalGet(bestField), resolveFields(kYearPrecedence), year+1,
|
||||
#if defined (U_DEBUG_CAL)
|
||||
fprintf(stderr, "%s:%d - woy=%d, yp=%d, nj(%d)=%d, nf=%d", __FILE__, __LINE__,
|
||||
internalGet(bestField), resolveFields(kYearPrecedence), year+1,
|
||||
nextJulianDay, nextFirst);
|
||||
|
||||
fprintf(stderr, " next: %d DFW, min=%d \n", (7-nextFirst), getMinimalDaysInFirstWeek() );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// nextFirst is now the localized DOW of Jan 1 of y-woy+1
|
||||
if((nextFirst > 0) && // Jan 1 starts on FDOW
|
||||
(7-nextFirst) >= getMinimalDaysInFirstWeek()) // or enough days in the week
|
||||
{
|
||||
// Jan 1 of (yearWoy+1) is in yearWoy+1 - recalculate JD to next year
|
||||
#if defined (U_DEBUG_CAL)
|
||||
fprintf(stderr, "%s:%d - was going to move JD from %d to %d [d%d]\n", __FILE__, __LINE__,
|
||||
#if defined (U_DEBUG_CAL)
|
||||
fprintf(stderr, "%s:%d - was going to move JD from %d to %d [d%d]\n", __FILE__, __LINE__,
|
||||
julianDay, nextJulianDay, (nextJulianDay-julianDay));
|
||||
#endif
|
||||
#endif
|
||||
julianDay = nextJulianDay;
|
||||
|
||||
// recalculate 'first' [0-based local dow of jan 1]
|
||||
|
|
@ -3351,7 +3362,7 @@ int32_t Calendar::handleComputeJulianDay(UCalendarDateFields bestField) {
|
|||
// recalculate date.
|
||||
date = 1 - first + dowLocal;
|
||||
}
|
||||
} else if(woy>=getLeastMaximum(bestField)) {
|
||||
} else if(woy>=getLeastMaximum(bestField)) {
|
||||
// could be in the last week- find out if this JD would overstep
|
||||
int32_t testDate = date;
|
||||
if ((7 - first) < getMinimalDaysInFirstWeek()) {
|
||||
|
|
@ -3361,7 +3372,7 @@ int32_t Calendar::handleComputeJulianDay(UCalendarDateFields bestField) {
|
|||
// Now adjust for the week number.
|
||||
testDate += 7 * (woy - 1);
|
||||
|
||||
#if defined (U_DEBUG_CAL)
|
||||
#if defined (U_DEBUG_CAL)
|
||||
fprintf(stderr, "%s:%d - y=%d, y-1=%d doy%d, njd%d (C.F. %d)\n",
|
||||
__FILE__, __LINE__, year, year-1, testDate, julianDay+testDate, nextJulianDay);
|
||||
#endif
|
||||
|
|
@ -3375,7 +3386,7 @@ int32_t Calendar::handleComputeJulianDay(UCalendarDateFields bestField) {
|
|||
}
|
||||
date = 1 - first + dowLocal;
|
||||
|
||||
#if defined (U_DEBUG_CAL)
|
||||
#if defined (U_DEBUG_CAL)
|
||||
fprintf(stderr, "%s:%d - date now %d, jd%d, ywoy%d\n",
|
||||
__FILE__, __LINE__, date, julianDay, year-1);
|
||||
#endif
|
||||
|
|
@ -3400,13 +3411,13 @@ int32_t Calendar::handleComputeJulianDay(UCalendarDateFields bestField) {
|
|||
}
|
||||
|
||||
int32_t
|
||||
Calendar::getDefaultMonthInYear(int32_t /*eyear*/)
|
||||
Calendar::getDefaultMonthInYear(int32_t /*eyear*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t
|
||||
Calendar::getDefaultDayInMonth(int32_t /*eyear*/, int32_t /*month*/)
|
||||
Calendar::getDefaultDayInMonth(int32_t /*eyear*/, int32_t /*month*/)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -3436,13 +3447,13 @@ int32_t Calendar::getLocalDOW()
|
|||
|
||||
int32_t Calendar::handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t woy)
|
||||
{
|
||||
// We have UCAL_YEAR_WOY and UCAL_WEEK_OF_YEAR - from those, determine
|
||||
// We have UCAL_YEAR_WOY and UCAL_WEEK_OF_YEAR - from those, determine
|
||||
// what year we fall in, so that other code can set it properly.
|
||||
// (code borrowed from computeWeekFields and handleComputeJulianDay)
|
||||
//return yearWoy;
|
||||
|
||||
// First, we need a reliable DOW.
|
||||
UCalendarDateFields bestField = resolveFields(kDatePrecedence); // !! Note: if subclasses have a different table, they should override handleGetExtendedYearFromWeekFields
|
||||
UCalendarDateFields bestField = resolveFields(kDatePrecedence); // !! Note: if subclasses have a different table, they should override handleGetExtendedYearFromWeekFields
|
||||
|
||||
// Now, a local DOW
|
||||
int32_t dowLocal = getLocalDOW(); // 0..6
|
||||
|
|
@ -3475,9 +3486,9 @@ int32_t Calendar::handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t w
|
|||
|
||||
int32_t minDays = getMinimalDaysInFirstWeek();
|
||||
UBool jan1InPrevYear = FALSE; // January 1st in the year of WOY is the 1st week? (i.e. first week is < minimal )
|
||||
//UBool nextJan1InPrevYear = FALSE; // January 1st of Year of WOY + 1 is in the first week?
|
||||
//UBool nextJan1InPrevYear = FALSE; // January 1st of Year of WOY + 1 is in the first week?
|
||||
|
||||
if((7 - first) < minDays) {
|
||||
if((7 - first) < minDays) {
|
||||
jan1InPrevYear = TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -3500,8 +3511,8 @@ int32_t Calendar::handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t w
|
|||
return yearWoy; // in this year
|
||||
}
|
||||
}
|
||||
} else if(woy >= getLeastMaximum(bestField)) {
|
||||
// we _might_ be in the last week..
|
||||
} else if(woy >= getLeastMaximum(bestField)) {
|
||||
// we _might_ be in the last week..
|
||||
int32_t jd = // Calculate JD of our target day:
|
||||
jan1Start + // JD of Jan 1
|
||||
(7-first) + // days in the first week (Jan 1.. )
|
||||
|
|
@ -3538,7 +3549,7 @@ int32_t Calendar::handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t w
|
|||
}
|
||||
|
||||
//(internalGet(UCAL_DATE) <= (7-first)) /* && in minDow */ ) {
|
||||
//within 1st week and in this month..
|
||||
//within 1st week and in this month..
|
||||
//return yearWoy+1;
|
||||
return yearWoy;
|
||||
|
||||
|
|
@ -3671,7 +3682,7 @@ void Calendar::prepareGetActual(UCalendarDateFields field, UBool isMinimum, UErr
|
|||
dow += 7;
|
||||
}
|
||||
}
|
||||
#if defined (U_DEBUG_CAL)
|
||||
#if defined (U_DEBUG_CAL)
|
||||
fprintf(stderr, "prepareGetActualHelper(WOM/WOY) - dow=%d\n", dow);
|
||||
#endif
|
||||
set(UCAL_DAY_OF_WEEK, dow);
|
||||
|
|
@ -3687,7 +3698,7 @@ void Calendar::prepareGetActual(UCalendarDateFields field, UBool isMinimum, UErr
|
|||
|
||||
int32_t Calendar::getActualHelper(UCalendarDateFields field, int32_t startValue, int32_t endValue, UErrorCode &status) const
|
||||
{
|
||||
#if defined (U_DEBUG_CAL)
|
||||
#if defined (U_DEBUG_CAL)
|
||||
fprintf(stderr, "getActualHelper(%d,%d .. %d, %s)\n", field, startValue, endValue, u_errorName(status));
|
||||
#endif
|
||||
if (startValue == endValue) {
|
||||
|
|
@ -3723,7 +3734,7 @@ int32_t Calendar::getActualHelper(UCalendarDateFields field, int32_t startValue,
|
|||
int32_t result = startValue;
|
||||
if ((work->get(field, status) != startValue
|
||||
&& field != UCAL_WEEK_OF_MONTH && delta > 0 ) || U_FAILURE(status)) {
|
||||
#if defined (U_DEBUG_CAL)
|
||||
#if defined (U_DEBUG_CAL)
|
||||
fprintf(stderr, "getActualHelper(fld %d) - got %d (not %d) - %s\n", field, work->get(field,status), startValue, u_errorName(status));
|
||||
#endif
|
||||
} else {
|
||||
|
|
@ -3740,7 +3751,7 @@ int32_t Calendar::getActualHelper(UCalendarDateFields field, int32_t startValue,
|
|||
} while (startValue != endValue);
|
||||
}
|
||||
delete work;
|
||||
#if defined (U_DEBUG_CAL)
|
||||
#if defined (U_DEBUG_CAL)
|
||||
fprintf(stderr, "getActualHelper(%d) = %d\n", field, result);
|
||||
#endif
|
||||
return result;
|
||||
|
|
@ -3767,18 +3778,18 @@ Calendar::setWeekData(const Locale& desiredLocale, const char *type, UErrorCode&
|
|||
// Since week and weekend data is territory based instead of language based,
|
||||
// we may need to tweak the locale that we are using to try to get the appropriate
|
||||
// values, using the following logic:
|
||||
// 1). If the locale has a language but no territory, use the territory as defined by
|
||||
// 1). If the locale has a language but no territory, use the territory as defined by
|
||||
// the likely subtags.
|
||||
// 2). If the locale has a script designation then we ignore it,
|
||||
// then remove it ( i.e. "en_Latn_US" becomes "en_US" )
|
||||
|
||||
|
||||
char minLocaleID[ULOC_FULLNAME_CAPACITY] = { 0 };
|
||||
UErrorCode myStatus = U_ZERO_ERROR;
|
||||
|
||||
uloc_minimizeSubtags(desiredLocale.getName(),minLocaleID,ULOC_FULLNAME_CAPACITY,&myStatus);
|
||||
Locale min = Locale::createFromName(minLocaleID);
|
||||
Locale useLocale;
|
||||
if ( uprv_strlen(desiredLocale.getCountry()) == 0 ||
|
||||
if ( uprv_strlen(desiredLocale.getCountry()) == 0 ||
|
||||
(uprv_strlen(desiredLocale.getScript()) > 0 && uprv_strlen(min.getScript()) == 0) ) {
|
||||
char maxLocaleID[ULOC_FULLNAME_CAPACITY] = { 0 };
|
||||
myStatus = U_ZERO_ERROR;
|
||||
|
|
@ -3786,10 +3797,10 @@ Calendar::setWeekData(const Locale& desiredLocale, const char *type, UErrorCode&
|
|||
Locale max = Locale::createFromName(maxLocaleID);
|
||||
useLocale = Locale(max.getLanguage(),max.getCountry());
|
||||
} else {
|
||||
useLocale = Locale(desiredLocale);
|
||||
useLocale = desiredLocale;
|
||||
}
|
||||
|
||||
/* The code here is somewhat of a hack, since week data and weekend data aren't really tied to
|
||||
|
||||
/* The code here is somewhat of a hack, since week data and weekend data aren't really tied to
|
||||
a specific calendar, they aren't truly locale data. But this is the only place where valid and
|
||||
actual locale can be set, so we take a shot at it here by loading a representative resource
|
||||
from the calendar data. The code used to use the dateTimeElements resource to get first day
|
||||
|
|
@ -3865,8 +3876,8 @@ Calendar::setWeekData(const Locale& desiredLocale, const char *type, UErrorCode&
|
|||
* and areFieldsSet. Callers should check isTimeSet and only
|
||||
* call this method if isTimeSet is false.
|
||||
*/
|
||||
void
|
||||
Calendar::updateTime(UErrorCode& status)
|
||||
void
|
||||
Calendar::updateTime(UErrorCode& status)
|
||||
{
|
||||
computeTime(status);
|
||||
if(U_FAILURE(status))
|
||||
|
|
@ -3875,14 +3886,14 @@ Calendar::updateTime(UErrorCode& status)
|
|||
// If we are lenient, we need to recompute the fields to normalize
|
||||
// the values. Also, if we haven't set all the fields yet (i.e.,
|
||||
// in a newly-created object), we need to fill in the fields. [LIU]
|
||||
if (isLenient() || ! fAreAllFieldsSet)
|
||||
if (isLenient() || ! fAreAllFieldsSet)
|
||||
fAreFieldsSet = FALSE;
|
||||
|
||||
fIsTimeSet = TRUE;
|
||||
fAreFieldsVirtuallySet = FALSE;
|
||||
}
|
||||
|
||||
Locale
|
||||
Locale
|
||||
Calendar::getLocale(ULocDataLocaleType type, UErrorCode& status) const {
|
||||
U_LOCALE_BASED(locBased, *this);
|
||||
return locBased.getLocale(type, status);
|
||||
|
|
@ -3945,4 +3956,3 @@ U_NAMESPACE_END
|
|||
|
||||
|
||||
//eof
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
*
|
||||
*******************************************************************************
|
||||
* file name: casetrn.cpp
|
||||
* encoding: US-ASCII
|
||||
* encoding: UTF-8
|
||||
* tab size: 8 (not used)
|
||||
* indentation:4
|
||||
*
|
||||
|
|
@ -92,7 +92,6 @@ UOBJECT_DEFINE_ABSTRACT_RTTI_IMPLEMENTATION(CaseMapTransliterator)
|
|||
*/
|
||||
CaseMapTransliterator::CaseMapTransliterator(const UnicodeString &id, UCaseMapFull *map) :
|
||||
Transliterator(id, 0),
|
||||
fCsp(ucase_getSingleton()),
|
||||
fMap(map)
|
||||
{
|
||||
// TODO test incremental mode with context-sensitive text (e.g. greek sigma)
|
||||
|
|
@ -110,7 +109,7 @@ CaseMapTransliterator::~CaseMapTransliterator() {
|
|||
*/
|
||||
CaseMapTransliterator::CaseMapTransliterator(const CaseMapTransliterator& o) :
|
||||
Transliterator(o),
|
||||
fCsp(o.fCsp), fMap(o.fMap)
|
||||
fMap(o.fMap)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -119,7 +118,6 @@ CaseMapTransliterator::CaseMapTransliterator(const CaseMapTransliterator& o) :
|
|||
*/
|
||||
/*CaseMapTransliterator& CaseMapTransliterator::operator=(const CaseMapTransliterator& o) {
|
||||
Transliterator::operator=(o);
|
||||
fCsp = o.fCsp;
|
||||
fMap = o.fMap;
|
||||
return *this;
|
||||
}*/
|
||||
|
|
@ -151,14 +149,14 @@ void CaseMapTransliterator::handleTransliterate(Replaceable& text,
|
|||
UnicodeString tmp;
|
||||
const UChar *s;
|
||||
UChar32 c;
|
||||
int32_t textPos, delta, result, locCache=0;
|
||||
int32_t textPos, delta, result;
|
||||
|
||||
for(textPos=offsets.start; textPos<offsets.limit;) {
|
||||
csc.cpStart=textPos;
|
||||
c=text.char32At(textPos);
|
||||
csc.cpLimit=textPos+=U16_LENGTH(c);
|
||||
|
||||
result=fMap(fCsp, c, utrans_rep_caseContextIterator, &csc, &s, "", &locCache);
|
||||
result=fMap(c, utrans_rep_caseContextIterator, &csc, &s, UCASE_LOC_ROOT);
|
||||
|
||||
if(csc.b1 && isIncremental) {
|
||||
// fMap() tried to look beyond the context limit
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
*
|
||||
*******************************************************************************
|
||||
* file name: casetrn.h
|
||||
* encoding: US-ASCII
|
||||
* encoding: UTF-8
|
||||
* tab size: 8 (not used)
|
||||
* indentation:4
|
||||
*
|
||||
|
|
@ -84,7 +84,6 @@ protected:
|
|||
UTransPosition& offsets,
|
||||
UBool isIncremental) const;
|
||||
|
||||
const UCaseProps *fCsp;
|
||||
UCaseMapFull *fMap;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*****************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#if !UCONFIG_NO_COLLATION
|
||||
|
||||
#include "unicode/chariter.h"
|
||||
#include "unicode/coleitr.h"
|
||||
#include "unicode/tblcoll.h"
|
||||
#include "unicode/ustring.h"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
******************************************************************************
|
||||
|
|
@ -63,8 +63,10 @@
|
|||
|
||||
static icu::Locale* availableLocaleList = NULL;
|
||||
static int32_t availableLocaleListCount;
|
||||
#if !UCONFIG_NO_SERVICE
|
||||
static icu::ICULocaleService* gService = NULL;
|
||||
static icu::UInitOnce gServiceInitOnce = U_INITONCE_INITIALIZER;
|
||||
#endif
|
||||
static icu::UInitOnce gAvailableLocaleListInitOnce;
|
||||
|
||||
/**
|
||||
|
|
@ -446,6 +448,13 @@ Collator* U_EXPORT2 Collator::createInstance(const Locale& desiredLocale,
|
|||
#endif
|
||||
{
|
||||
coll = makeInstance(desiredLocale, status);
|
||||
// Either returns NULL with U_FAILURE(status), or non-NULL with U_SUCCESS(status)
|
||||
}
|
||||
// The use of *coll in setAttributesFromKeywords can cause the NULL check to be
|
||||
// optimized out of the delete even though setAttributesFromKeywords returns
|
||||
// immediately if U_FAILURE(status), so we add a check here.
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
}
|
||||
setAttributesFromKeywords(desiredLocale, *coll, status);
|
||||
if (U_FAILURE(status)) {
|
||||
|
|
@ -984,8 +993,8 @@ Collator::internalCompareUTF8(const char *left, int32_t leftLength,
|
|||
return UCOL_EQUAL;
|
||||
}
|
||||
return compareUTF8(
|
||||
StringPiece(left, (leftLength < 0) ? uprv_strlen(left) : leftLength),
|
||||
StringPiece(right, (rightLength < 0) ? uprv_strlen(right) : rightLength),
|
||||
StringPiece(left, (leftLength < 0) ? static_cast<int32_t>(uprv_strlen(left)) : leftLength),
|
||||
StringPiece(right, (rightLength < 0) ? static_cast<int32_t>(uprv_strlen(right)) : rightLength),
|
||||
errorCode);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
@ -419,7 +419,8 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
|
|||
tailoring.data, ts, fastLatinPrimaries, UPRV_LENGTHOF(fastLatinPrimaries));
|
||||
if(options == ts.options && ts.variableTop != 0 &&
|
||||
reorderCodesLength == ts.reorderCodesLength &&
|
||||
uprv_memcmp(reorderCodes, ts.reorderCodes, reorderCodesLength * 4) == 0 &&
|
||||
(reorderCodesLength == 0 ||
|
||||
uprv_memcmp(reorderCodes, ts.reorderCodes, reorderCodesLength * 4) == 0) &&
|
||||
fastLatinOptions == ts.fastLatinOptions &&
|
||||
(fastLatinOptions < 0 ||
|
||||
uprv_memcmp(fastLatinPrimaries, ts.fastLatinPrimaries,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
@ -224,7 +224,7 @@ CollationDataWriter::write(UBool isBase, const UVersionInfo dataVersion,
|
|||
int32_t totalSize = indexesLength * 4;
|
||||
|
||||
if(hasMappings && (isBase || data.jamoCE32s != baseData->jamoCE32s)) {
|
||||
indexes[CollationDataReader::IX_JAMO_CE32S_START] = data.jamoCE32s - data.ce32s;
|
||||
indexes[CollationDataReader::IX_JAMO_CE32S_START] = static_cast<int32_t>(data.jamoCE32s - data.ce32s);
|
||||
} else {
|
||||
indexes[CollationDataReader::IX_JAMO_CE32S_START] = -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
@ -607,7 +607,7 @@ CollationFastLatinBuilder::encodeContractions(UErrorCode &errorCode) {
|
|||
}
|
||||
UBool firstTriple = TRUE;
|
||||
for(int32_t index = (int32_t)ce & 0x7fffffff;; index += 3) {
|
||||
int32_t x = contractionCEs.elementAti(index);
|
||||
int32_t x = static_cast<int32_t>(contractionCEs.elementAti(index));
|
||||
if((uint32_t)x == CollationFastLatin::CONTR_CHAR_MASK && !firstTriple) { break; }
|
||||
int64_t cce0 = contractionCEs.elementAti(index + 1);
|
||||
int64_t cce1 = contractionCEs.elementAti(index + 2);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
// 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
|
||||
/*
|
||||
* Copyright (C) 1999-2016, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
* file name: collationfcd.cpp
|
||||
*
|
||||
* machine-generated by: icu/tools/unicode/c/genuca/genuca.cpp
|
||||
*/
|
||||
//
|
||||
// Copyright (C) 1999-2016, International Business Machines
|
||||
// Corporation and others. All Rights Reserved.
|
||||
//
|
||||
// file name: collationfcd.cpp
|
||||
//
|
||||
// machine-generated by: icu/tools/unicode/c/genuca/genuca.cpp
|
||||
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
|
|
@ -22,27 +22,27 @@ const uint8_t CollationFCD::lcccIndex[2048]={
|
|||
0,0,0,0,0,0,0,0,1,1,2,3,0,0,0,0,
|
||||
0,0,0,0,4,0,0,0,0,0,0,0,5,6,7,0,
|
||||
8,0,9,0xa,0,0,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0x10,
|
||||
0x11,0x12,0x13,0,0,0,0x14,0x15,0,0x16,0x17,0,0,0x16,0x18,0,
|
||||
0x11,0x12,0x13,0,0,0,0x14,0x15,0,0x16,0x17,0,0,0x16,0x18,0x19,
|
||||
0,0x16,0x18,0,0,0x16,0x18,0,0,0x16,0x18,0,0,0,0x18,0,
|
||||
0,0,0x19,0,0,0x16,0x18,0,0,0,0x18,0,0,0,0x1a,0,
|
||||
0,0x1b,0x1c,0,0,0x1d,0x1c,0,0x1d,0x1e,0,0x1f,0x20,0,0x21,0,
|
||||
0,0x22,0,0,0x18,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0x23,0,0,0,0,0,
|
||||
0,0,0x1a,0,0,0x16,0x18,0,0,0x1b,0x18,0,0,0,0x1c,0,
|
||||
0,0x1d,0x1e,0,0,0x1f,0x1e,0,0x1f,0x20,0,0x21,0x22,0,0x23,0,
|
||||
0,0x24,0,0,0x18,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0x25,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0x24,0x24,0,0,0,0,0x25,0,
|
||||
0,0,0,0,0,0x26,0,0,0,0x13,0,0,0,0,0,0,
|
||||
0x27,0,0,0x28,0,0x29,0,0,0,0x24,0x2a,0x10,0,0x2b,0,0x2c,
|
||||
0,0x2d,0,0,0,0,0x2e,0x2f,0,0,0,0,0,0,1,0x30,
|
||||
0,0,0,0,0,0,0,0,0x26,0x26,0,0,0,0,0x27,0,
|
||||
0,0,0,0,0,0x28,0,0,0,0x13,0,0,0,0,0,0,
|
||||
0x29,0,0,0x2a,0,0x2b,0,0,0,0x26,0x2c,0x2d,0,0x2e,0,0x2f,
|
||||
0,0x30,0,0,0,0,0x31,0x32,0,0,0,0,0,0,1,0x33,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0x31,0x32,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0x34,0x35,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0x33,0,0,0,0x34,0,0,0,1,
|
||||
0,0,0,0,0,0,0,0x36,0,0,0,0x37,0,0,0,1,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0x35,0,0,0x36,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0x38,0,0,0x39,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
|
|
@ -101,9 +101,9 @@ const uint8_t CollationFCD::lcccIndex[2048]={
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0x37,0x38,0,0,0x39,0,0,0,0,0,0,0,0,
|
||||
0x21,0,0,0,0,0,0x2a,0x3a,0,0x3b,0x3c,0,0,0x3c,0x3d,0,
|
||||
0,0,0,0,0,0x3e,0x3f,0x40,0,0,0,0,0,0,0,0x18,
|
||||
0,0,0,0x3a,0x3b,0,0,0x3c,0,0,0,0,0,0,0,0,
|
||||
0x23,0,0,0,0,0,0x2c,0x3d,0,0x3e,0x3f,0,0,0x3f,0x40,0,
|
||||
0,0,0,0,0,0x41,0x42,0x43,0,0,0,0,0,0,0,0x18,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
|
|
@ -126,7 +126,7 @@ const uint8_t CollationFCD::lcccIndex[2048]={
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0x41,0x42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0x44,0x45,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||
|
|
@ -143,17 +143,17 @@ const uint8_t CollationFCD::lcccIndex[2048]={
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0x43,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0x19,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
};
|
||||
|
||||
const uint32_t CollationFCD::lcccBits[68]={
|
||||
const uint32_t CollationFCD::lcccBits[70]={
|
||||
0,0xffffffff,0xffff7fff,0xffff,0xf8,0xfffe0000,0xbfffffff,0xb6,0x7ff0000,0xfffff800,0x10000,0x9fc00000,0x3d9f,0x20000,0xffff0000,0x7ff,
|
||||
0xff800,0xfbc00000,0x3eef,0xe000000,0xfff00000,0xfffffffb,0x10000000,0x1e2000,0x2000,0x602000,0x400,0x7000000,0xf00,0x3000000,0x2a00000,0x3c3e0000,
|
||||
0xdf,0x40,0x6800000,0xe0000000,0x100000,0x20040000,0x200,0x1800000,0x9fe00001,0x3fff0000,0x10,0xc00,0xc0040,0x800000,0xfff70000,0x31021fd,
|
||||
0xf83fffff,0x1fff0000,0x1ffe2,0x38000,0x80000000,0xfc00,0x6000000,0x3ff08000,0xc0000000,0x30000,0x3ffff,0x3800,0x80000,1,0xc19d0000,2,
|
||||
0x400000,0x40000b5,0x5108000,0x40000000
|
||||
0x200ff800,0xfbc00000,0x3eef,0xe000000,0xfff80000,0xfffffffb,0x10000000,0x1e2000,0x2000,0x40000000,0x602000,0x18000000,0x400,0x7000000,0xf00,0x3000000,
|
||||
0x2a00000,0x3c3e0000,0xdf,0x40,0x6800000,0xe0000000,0x100000,0x20040000,0x200,0x1800000,0x9fe00001,0x3fff0000,0x10,0xff800,0xc00,0xc0040,
|
||||
0x800000,0xfff70000,0x31021fd,0xfbffffff,0x1fff0000,0x1ffe2,0x38000,0x80000000,0xfc00,0x6000000,0x3ff08000,0xc0000000,0x30000,0x3ffff,0x3800,0x80000,
|
||||
1,0xc19d0000,2,0x400000,0x40000fd,0x5108000
|
||||
};
|
||||
|
||||
const uint8_t CollationFCD::tcccIndex[2048]={
|
||||
|
|
@ -161,27 +161,27 @@ const uint8_t CollationFCD::tcccIndex[2048]={
|
|||
0xb,0xc,0,0,0,0,0,0,1,1,0xd,0xe,0xf,0x10,0x11,0,
|
||||
0x12,0x13,0x14,0x15,0x16,0,0x17,0x18,0,0,0,0,0x19,0x1a,0x1b,0,
|
||||
0x1c,0x1d,0x1e,0x1f,0,0,0x20,0x21,0x22,0x23,0x24,0,0,0,0,0x25,
|
||||
0x26,0x27,0x28,0,0,0,0x29,0x2a,0,0x2b,0x2c,0,0,0x2d,0x2e,0,
|
||||
0,0x2f,0x30,0,0,0x2d,0x31,0,0,0x2d,0x32,0,0,0,0x31,0,
|
||||
0,0,0x33,0,0,0x2d,0x31,0,0,0,0x31,0,0,0,0x34,0,
|
||||
0,0x35,0x36,0,0,0x37,0x36,0,0x37,0x38,0,0x39,0x3a,0,0x3b,0,
|
||||
0,0x3c,0,0,0x31,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0x3d,0,0,0,0,0,
|
||||
0x26,0x27,0x28,0,0,0,0x29,0x2a,0,0x2b,0x2c,0,0,0x2d,0x2e,0x2f,
|
||||
0,0x30,0x31,0,0,0x2d,0x32,0,0,0x2d,0x33,0,0,0,0x32,0,
|
||||
0,0,0x34,0,0,0x2d,0x32,0,0,0x35,0x32,0,0,0,0x36,0,
|
||||
0,0x37,0x38,0,0,0x39,0x38,0,0x39,0x3a,0,0x3b,0x3c,0,0x3d,0,
|
||||
0,0x3e,0,0,0x32,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0x3f,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0x3e,0x3e,0,0,0,0,0x3f,0,
|
||||
0,0,0,0,0,0x40,0,0,0,0x28,0,0,0,0,0,0,
|
||||
0x41,0,0,0x42,0,0x43,0,0,0,0x3e,0x44,0x25,0,0x45,0,0x46,
|
||||
0,0x47,0,0,0,0,0x48,0x49,0,0,0,0,0,0,1,0x4a,
|
||||
1,1,1,1,0x4b,1,1,0x4c,0x4d,1,0x4e,0x4f,1,0x50,0x51,0x52,
|
||||
0,0,0,0,0,0,0x53,0x54,0,0x55,0,0,0x56,0x57,0x58,0,
|
||||
0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0,0x5f,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0x40,0x40,0,0,0,0,0x41,0,
|
||||
0,0,0,0,0,0x42,0,0,0,0x28,0,0,0,0,0,0,
|
||||
0x43,0,0,0x44,0,0x45,0,0,0,0x40,0x46,0x47,0,0x48,0,0x49,
|
||||
0,0x4a,0,0,0,0,0x4b,0x4c,0,0,0,0,0,0,1,0x4d,
|
||||
1,1,1,1,0x4e,1,1,0x4f,0x50,1,0x51,0x52,1,0x53,0x54,0x55,
|
||||
0,0,0,0,0,0,0x56,0x57,0,0x58,0,0,0x59,0x5a,0x5b,0,
|
||||
0x5c,0x5d,0x5e,0x5f,0x60,0x61,0,0x62,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0x2d,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0x60,0,0,0,0x61,0,0,0,1,
|
||||
0,0,0,0,0,0,0,0x63,0,0,0,0x64,0,0,0,1,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0x62,0x63,0x64,0x65,0x63,0x64,0x66,0,0,0,0,0,0,0,0,
|
||||
0,0x65,0x66,0x67,0x68,0x66,0x67,0x69,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
|
|
@ -240,9 +240,9 @@ const uint8_t CollationFCD::tcccIndex[2048]={
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0x67,0x68,0,0,0x69,0,0,0,0,0,0,0,0,
|
||||
0x3b,0,0,0,0,0,0x44,0x6a,0,0x6b,0x6c,0,0,0x6c,0x6d,0,
|
||||
0,0,0,0,0,0x6e,0x6f,0x70,0,0,0,0,0,0,0,0x31,
|
||||
0,0,0,0x6a,0x6b,0,0,0x6c,0,0,0,0,0,0,0,0,
|
||||
0x3d,0,0,0,0,0,0x46,0x6d,0,0x6e,0x6f,0,0,0x6f,0x70,0,
|
||||
0,0,0,0,0,0x71,0x72,0x73,0,0,0,0,0,0,0,0x32,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
|
|
@ -265,7 +265,7 @@ const uint8_t CollationFCD::tcccIndex[2048]={
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0x71,0x72,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0x74,0x75,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
|
|
@ -282,20 +282,20 @@ const uint8_t CollationFCD::tcccIndex[2048]={
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0x3d,0x73,0x74,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0x3f,0x76,0x77,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0xe,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
};
|
||||
|
||||
const uint32_t CollationFCD::tcccBits[117]={
|
||||
const uint32_t CollationFCD::tcccBits[120]={
|
||||
0,0xffffffff,0x3e7effbf,0xbe7effbf,0xfffcffff,0x7ef1ff3f,0xfff3f1f8,0x7fffff3f,0x18003,0xdfffe000,0xff31ffcf,0xcfffffff,0xfffc0,0xffff7fff,0xffff,0x1d760,
|
||||
0x1fc00,0x187c00,0x200708b,0x2000000,0x708b0000,0xc00000,0xf8,0xfccf0006,0x33ffcfc,0xfffe0000,0xbfffffff,0xb6,0x7ff0000,0x7c,0xfffff800,0x10000,
|
||||
0x9fc80005,0x3d9f,0x20000,0xffff0000,0x7ff,0xff800,0xfbc00000,0x3eef,0xe000000,0xfff00000,0xfffffffb,0x10120200,0xff1e2000,0x10000000,0xb0002000,0x10480000,
|
||||
0x4e002000,0x2000,0x30002000,0x602100,0x24000400,0x7000000,0xf00,0x3000000,0x2a00000,0x3d7e0000,0xdf,0x40,0x6800000,0xe0000000,0x100000,0x20040000,
|
||||
0x200,0x1800000,0x9fe00001,0x3fff0000,0x10,0xc00,0xc0040,0x800000,0xfff70000,0x31021fd,0xf83fffff,0xbffffff,0x3ffffff,0x3f3fffff,0xaaff3f3f,0x3fffffff,
|
||||
0x1fdfffff,0xefcfffde,0x1fdc7fff,0x1fff0000,0x1ffe2,0x800,0xc000000,0x4000,0xe000,0x1210,0x50,0x292,0x333e005,0x333,0xf000,0x3c0f,
|
||||
0x38000,0x80000000,0xfc00,0x55555000,0x36db02a5,0x46100000,0x47900000,0x3ff08000,0xc0000000,0x30000,0x3ffff,0x3800,0x80000,1,0xc19d0000,2,
|
||||
0x400000,0x40000b5,0x5108000,0x5f7ffc00,0x7fdb
|
||||
0x9fc80005,0x3d9f,0x20000,0xffff0000,0x7ff,0x200ff800,0xfbc00000,0x3eef,0xe000000,0xfff80000,0xfffffffb,0x10120200,0xff1e2000,0x10000000,0xb0002000,0x40000000,
|
||||
0x10480000,0x4e002000,0x2000,0x30002000,0x602100,0x18000000,0x24000400,0x7000000,0xf00,0x3000000,0x2a00000,0x3d7e0000,0xdf,0x40,0x6800000,0xe0000000,
|
||||
0x100000,0x20040000,0x200,0x1800000,0x9fe00001,0x3fff0000,0x10,0xff800,0xc00,0xc0040,0x800000,0xfff70000,0x31021fd,0xfbffffff,0xbffffff,0x3ffffff,
|
||||
0x3f3fffff,0xaaff3f3f,0x3fffffff,0x1fdfffff,0xefcfffde,0x1fdc7fff,0x1fff0000,0x1ffe2,0x800,0xc000000,0x4000,0xe000,0x1210,0x50,0x292,0x333e005,
|
||||
0x333,0xf000,0x3c0f,0x38000,0x80000000,0xfc00,0x55555000,0x36db02a5,0x46100000,0x47900000,0x3ff08000,0xc0000000,0x30000,0x3ffff,0x3800,0x80000,
|
||||
1,0xc19d0000,2,0x400000,0x40000fd,0x5108000,0x5f7ffc00,0x7fdb
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
@ -28,6 +28,21 @@ class SkippedState;
|
|||
class UCharsTrie;
|
||||
class UVector32;
|
||||
|
||||
/* Large enough for CEs of most short strings. */
|
||||
#define CEBUFFER_INITIAL_CAPACITY 40
|
||||
|
||||
// Export an explicit template instantiation of the MaybeStackArray that
|
||||
// is used as a data member of CEBuffer.
|
||||
//
|
||||
// When building DLLs for Windows this is required even though
|
||||
// no direct access to the MaybeStackArray leaks out of the i18n library.
|
||||
//
|
||||
// See digitlst.h, pluralaffix.h, datefmt.h, and others for similar examples.
|
||||
//
|
||||
#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
|
||||
template class U_I18N_API MaybeStackArray<int64_t, CEBUFFER_INITIAL_CAPACITY>;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Collation element iterator and abstract character iterator.
|
||||
*
|
||||
|
|
@ -36,10 +51,10 @@ class UVector32;
|
|||
*/
|
||||
class U_I18N_API CollationIterator : public UObject {
|
||||
private:
|
||||
class CEBuffer {
|
||||
class U_I18N_API CEBuffer {
|
||||
private:
|
||||
/** Large enough for CEs of most short strings. */
|
||||
static const int32_t INITIAL_CAPACITY = 40;
|
||||
static const int32_t INITIAL_CAPACITY = CEBUFFER_INITIAL_CAPACITY;
|
||||
public:
|
||||
CEBuffer() : length(0) {}
|
||||
~CEBuffer();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
@ -403,13 +403,13 @@ CollationKeys::writeSortKeyUpToQuaternary(CollationIterator &iter,
|
|||
uint8_t *secs = secondaries.data();
|
||||
int32_t last = secondaries.length() - 1;
|
||||
if(secSegmentStart < last) {
|
||||
uint8_t *p = secs + secSegmentStart;
|
||||
uint8_t *q = secs + last;
|
||||
uint8_t *q = secs + secSegmentStart;
|
||||
uint8_t *r = secs + last;
|
||||
do {
|
||||
uint8_t b = *p;
|
||||
*p++ = *q;
|
||||
*q-- = b;
|
||||
} while(p < q);
|
||||
uint8_t b = *q;
|
||||
*q++ = *r;
|
||||
*r-- = b;
|
||||
} while(q < r);
|
||||
}
|
||||
secondaries.appendByte(p == Collation::NO_CE_PRIMARY ?
|
||||
Collation::LEVEL_SEPARATOR_BYTE : Collation::MERGE_SEPARATOR_BYTE);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
*
|
||||
*******************************************************************************
|
||||
* file name: collationweights.cpp
|
||||
* encoding: US-ASCII
|
||||
* encoding: UTF-8
|
||||
* tab size: 8 (not used)
|
||||
* indentation:4
|
||||
*
|
||||
|
|
@ -527,7 +527,7 @@ CollationWeights::allocWeights(uint32_t lowerLimit, uint32_t upperLimit, int32_t
|
|||
#ifdef UCOL_DEBUG
|
||||
printf("lengthen the short ranges from %ld bytes to %ld and iterate\n", minLength, minLength+1);
|
||||
#endif
|
||||
for(int32_t i=0; ranges[i].length==minLength; ++i) {
|
||||
for(int32_t i=0; i<rangeCount && ranges[i].length==minLength; ++i) {
|
||||
lengthenRange(ranges[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
*
|
||||
*******************************************************************************
|
||||
* file name: collationweights.h
|
||||
* encoding: US-ASCII
|
||||
* encoding: UTF-8
|
||||
* tab size: 8 (not used)
|
||||
* indentation:4
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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
|
||||
// collunsafe.h
|
||||
// Copyright (C) 2015-2016, International Business Machines Corporation and others.
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
**********************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
**********************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
**********************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
**********************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
**********************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
**********************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
**********************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
**********************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
**********************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
**********************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
**********************************************************************
|
||||
|
|
@ -166,7 +166,7 @@ int32_t CharsetRecog_mbcs::match_mbcs(InputText *det, const uint16_t commonChars
|
|||
doubleByteCharCount++;
|
||||
|
||||
if (commonChars != 0) {
|
||||
if (binarySearch(commonChars, commonCharsLen, iter.charValue) >= 0){
|
||||
if (binarySearch(commonChars, commonCharsLen, static_cast<uint16_t>(iter.charValue)) >= 0){
|
||||
commonCharCount += 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
**********************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
**********************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
**********************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
**********************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
**********************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
**********************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
**********************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
**********************************************************************
|
||||
|
|
@ -19,12 +19,12 @@
|
|||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
CurrencyAmount::CurrencyAmount(const Formattable& amount, const UChar* isoCode,
|
||||
CurrencyAmount::CurrencyAmount(const Formattable& amount, ConstChar16Ptr isoCode,
|
||||
UErrorCode& ec) :
|
||||
Measure(amount, new CurrencyUnit(isoCode, ec), ec) {
|
||||
}
|
||||
|
||||
CurrencyAmount::CurrencyAmount(double amount, const UChar* isoCode,
|
||||
CurrencyAmount::CurrencyAmount(double amount, ConstChar16Ptr isoCode,
|
||||
UErrorCode& ec) :
|
||||
Measure(Formattable(amount), new CurrencyUnit(isoCode, ec), ec) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
**********************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
**********************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
@ -17,9 +17,9 @@
|
|||
#include <iostream>
|
||||
#endif
|
||||
|
||||
|
||||
#include "unicode/locid.h"
|
||||
#include "unicode/plurrule.h"
|
||||
#include "unicode/strenum.h"
|
||||
#include "unicode/ures.h"
|
||||
#include "unicode/numsys.h"
|
||||
#include "cstring.h"
|
||||
|
|
@ -29,7 +29,6 @@
|
|||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
|
||||
static const UChar gNumberPatternSeparator = 0x3B; // ;
|
||||
|
||||
U_CDECL_BEGIN
|
||||
|
|
@ -64,66 +63,86 @@ static const char gDecimalFormatTag[]="decimalFormat";
|
|||
static const char gCurrUnitPtnTag[]="CurrencyUnitPatterns";
|
||||
|
||||
CurrencyPluralInfo::CurrencyPluralInfo(UErrorCode& status)
|
||||
: fPluralCountToCurrencyUnitPattern(NULL),
|
||||
fPluralRules(NULL),
|
||||
fLocale(NULL) {
|
||||
: fPluralCountToCurrencyUnitPattern(nullptr),
|
||||
fPluralRules(nullptr),
|
||||
fLocale(nullptr),
|
||||
fInternalStatus(U_ZERO_ERROR) {
|
||||
initialize(Locale::getDefault(), status);
|
||||
}
|
||||
|
||||
CurrencyPluralInfo::CurrencyPluralInfo(const Locale& locale, UErrorCode& status)
|
||||
: fPluralCountToCurrencyUnitPattern(NULL),
|
||||
fPluralRules(NULL),
|
||||
fLocale(NULL) {
|
||||
: fPluralCountToCurrencyUnitPattern(nullptr),
|
||||
fPluralRules(nullptr),
|
||||
fLocale(nullptr),
|
||||
fInternalStatus(U_ZERO_ERROR) {
|
||||
initialize(locale, status);
|
||||
}
|
||||
|
||||
CurrencyPluralInfo::CurrencyPluralInfo(const CurrencyPluralInfo& info)
|
||||
: UObject(info),
|
||||
fPluralCountToCurrencyUnitPattern(NULL),
|
||||
fPluralRules(NULL),
|
||||
fLocale(NULL) {
|
||||
fPluralCountToCurrencyUnitPattern(nullptr),
|
||||
fPluralRules(nullptr),
|
||||
fLocale(nullptr),
|
||||
fInternalStatus(U_ZERO_ERROR) {
|
||||
*this = info;
|
||||
}
|
||||
|
||||
|
||||
CurrencyPluralInfo&
|
||||
CurrencyPluralInfo::operator=(const CurrencyPluralInfo& info) {
|
||||
if (this == &info) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
fInternalStatus = info.fInternalStatus;
|
||||
if (U_FAILURE(fInternalStatus)) {
|
||||
// bail out early if the object we were copying from was already 'invalid'.
|
||||
return *this;
|
||||
}
|
||||
|
||||
deleteHash(fPluralCountToCurrencyUnitPattern);
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
fPluralCountToCurrencyUnitPattern = initHash(status);
|
||||
fPluralCountToCurrencyUnitPattern = initHash(fInternalStatus);
|
||||
copyHash(info.fPluralCountToCurrencyUnitPattern,
|
||||
fPluralCountToCurrencyUnitPattern, status);
|
||||
if ( U_FAILURE(status) ) {
|
||||
fPluralCountToCurrencyUnitPattern, fInternalStatus);
|
||||
if ( U_FAILURE(fInternalStatus) ) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
delete fPluralRules;
|
||||
fPluralRules = nullptr;
|
||||
delete fLocale;
|
||||
if (info.fPluralRules) {
|
||||
fLocale = nullptr;
|
||||
|
||||
if (info.fPluralRules != nullptr) {
|
||||
fPluralRules = info.fPluralRules->clone();
|
||||
} else {
|
||||
fPluralRules = NULL;
|
||||
if (fPluralRules == nullptr) {
|
||||
fInternalStatus = U_MEMORY_ALLOCATION_ERROR;
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
if (info.fLocale) {
|
||||
if (info.fLocale != nullptr) {
|
||||
fLocale = info.fLocale->clone();
|
||||
} else {
|
||||
fLocale = NULL;
|
||||
if (fLocale == nullptr) {
|
||||
// Note: If clone had an error parameter, then we could check/set that instead.
|
||||
fInternalStatus = U_MEMORY_ALLOCATION_ERROR;
|
||||
return *this;
|
||||
}
|
||||
// If the other locale wasn't bogus, but our clone'd locale is bogus, then OOM happened
|
||||
// during the call to clone().
|
||||
if (!info.fLocale->isBogus() && fLocale->isBogus()) {
|
||||
fInternalStatus = U_MEMORY_ALLOCATION_ERROR;
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
CurrencyPluralInfo::~CurrencyPluralInfo() {
|
||||
deleteHash(fPluralCountToCurrencyUnitPattern);
|
||||
fPluralCountToCurrencyUnitPattern = NULL;
|
||||
fPluralCountToCurrencyUnitPattern = nullptr;
|
||||
delete fPluralRules;
|
||||
delete fLocale;
|
||||
fPluralRules = NULL;
|
||||
fLocale = NULL;
|
||||
fPluralRules = nullptr;
|
||||
fLocale = nullptr;
|
||||
}
|
||||
|
||||
UBool
|
||||
|
|
@ -147,7 +166,14 @@ CurrencyPluralInfo::operator==(const CurrencyPluralInfo& info) const {
|
|||
|
||||
CurrencyPluralInfo*
|
||||
CurrencyPluralInfo::clone() const {
|
||||
return new CurrencyPluralInfo(*this);
|
||||
CurrencyPluralInfo* newObj = new CurrencyPluralInfo(*this);
|
||||
// Since clone doesn't have a 'status' parameter, the best we can do is return nullptr
|
||||
// if the new object was not full constructed properly (an error occurred).
|
||||
if (newObj != nullptr && U_FAILURE(newObj->fInternalStatus)) {
|
||||
delete newObj;
|
||||
newObj = nullptr;
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
|
||||
const PluralRules*
|
||||
|
|
@ -160,15 +186,15 @@ CurrencyPluralInfo::getCurrencyPluralPattern(const UnicodeString& pluralCount,
|
|||
UnicodeString& result) const {
|
||||
const UnicodeString* currencyPluralPattern =
|
||||
(UnicodeString*)fPluralCountToCurrencyUnitPattern->get(pluralCount);
|
||||
if (currencyPluralPattern == NULL) {
|
||||
if (currencyPluralPattern == nullptr) {
|
||||
// fall back to "other"
|
||||
if (pluralCount.compare(gPluralCountOther, 5)) {
|
||||
currencyPluralPattern =
|
||||
(UnicodeString*)fPluralCountToCurrencyUnitPattern->get(UnicodeString(TRUE, gPluralCountOther, 5));
|
||||
}
|
||||
if (currencyPluralPattern == NULL) {
|
||||
if (currencyPluralPattern == nullptr) {
|
||||
// no currencyUnitPatterns defined,
|
||||
// fallback to predefined defult.
|
||||
// fallback to predefined default.
|
||||
// This should never happen when ICU resource files are
|
||||
// available, since currencyUnitPattern of "other" is always
|
||||
// defined in root.
|
||||
|
|
@ -189,44 +215,57 @@ void
|
|||
CurrencyPluralInfo::setPluralRules(const UnicodeString& ruleDescription,
|
||||
UErrorCode& status) {
|
||||
if (U_SUCCESS(status)) {
|
||||
if (fPluralRules) {
|
||||
delete fPluralRules;
|
||||
}
|
||||
delete fPluralRules;
|
||||
fPluralRules = PluralRules::createRules(ruleDescription, status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CurrencyPluralInfo::setCurrencyPluralPattern(const UnicodeString& pluralCount,
|
||||
const UnicodeString& pattern,
|
||||
UErrorCode& status) {
|
||||
if (U_SUCCESS(status)) {
|
||||
fPluralCountToCurrencyUnitPattern->put(pluralCount, new UnicodeString(pattern), status);
|
||||
UnicodeString* oldValue = static_cast<UnicodeString*>(
|
||||
fPluralCountToCurrencyUnitPattern->get(pluralCount));
|
||||
delete oldValue;
|
||||
LocalPointer<UnicodeString> p(new UnicodeString(pattern), status);
|
||||
if (U_SUCCESS(status)) {
|
||||
// the p object allocated above will be owned by fPluralCountToCurrencyUnitPattern
|
||||
// after the call to put(), even if the method returns failure.
|
||||
fPluralCountToCurrencyUnitPattern->put(pluralCount, p.orphan(), status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CurrencyPluralInfo::setLocale(const Locale& loc, UErrorCode& status) {
|
||||
initialize(loc, status);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CurrencyPluralInfo::initialize(const Locale& loc, UErrorCode& status) {
|
||||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
}
|
||||
delete fLocale;
|
||||
fLocale = nullptr;
|
||||
delete fPluralRules;
|
||||
fPluralRules = nullptr;
|
||||
|
||||
fLocale = loc.clone();
|
||||
if (fPluralRules) {
|
||||
delete fPluralRules;
|
||||
if (fLocale == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
// If the locale passed in wasn't bogus, but our clone'd locale is bogus, then OOM happened
|
||||
// during the call to loc.clone().
|
||||
if (!loc.isBogus() && fLocale->isBogus()) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
fPluralRules = PluralRules::forLocale(loc, status);
|
||||
setupCurrencyPluralPattern(loc, status);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CurrencyPluralInfo::setupCurrencyPluralPattern(const Locale& loc, UErrorCode& status) {
|
||||
|
|
@ -234,31 +273,32 @@ CurrencyPluralInfo::setupCurrencyPluralPattern(const Locale& loc, UErrorCode& st
|
|||
return;
|
||||
}
|
||||
|
||||
if (fPluralCountToCurrencyUnitPattern) {
|
||||
deleteHash(fPluralCountToCurrencyUnitPattern);
|
||||
}
|
||||
deleteHash(fPluralCountToCurrencyUnitPattern);
|
||||
fPluralCountToCurrencyUnitPattern = initHash(status);
|
||||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
}
|
||||
|
||||
NumberingSystem *ns = NumberingSystem::createInstance(loc,status);
|
||||
LocalPointer<NumberingSystem> ns(NumberingSystem::createInstance(loc, status), status);
|
||||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
}
|
||||
UErrorCode ec = U_ZERO_ERROR;
|
||||
UResourceBundle *rb = ures_open(NULL, loc.getName(), &ec);
|
||||
UResourceBundle *numElements = ures_getByKeyWithFallback(rb, gNumberElementsTag, NULL, &ec);
|
||||
rb = ures_getByKeyWithFallback(numElements, ns->getName(), rb, &ec);
|
||||
rb = ures_getByKeyWithFallback(rb, gPatternsTag, rb, &ec);
|
||||
LocalUResourceBundlePointer rb(ures_open(nullptr, loc.getName(), &ec));
|
||||
LocalUResourceBundlePointer numElements(ures_getByKeyWithFallback(rb.getAlias(), gNumberElementsTag, nullptr, &ec));
|
||||
ures_getByKeyWithFallback(numElements.getAlias(), ns->getName(), rb.getAlias(), &ec);
|
||||
ures_getByKeyWithFallback(rb.getAlias(), gPatternsTag, rb.getAlias(), &ec);
|
||||
int32_t ptnLen;
|
||||
const UChar* numberStylePattern = ures_getStringByKeyWithFallback(rb, gDecimalFormatTag, &ptnLen, &ec);
|
||||
const UChar* numberStylePattern = ures_getStringByKeyWithFallback(rb.getAlias(), gDecimalFormatTag, &ptnLen, &ec);
|
||||
// Fall back to "latn" if num sys specific pattern isn't there.
|
||||
if ( ec == U_MISSING_RESOURCE_ERROR && uprv_strcmp(ns->getName(),gLatnTag)) {
|
||||
if ( ec == U_MISSING_RESOURCE_ERROR && (uprv_strcmp(ns->getName(), gLatnTag) != 0)) {
|
||||
ec = U_ZERO_ERROR;
|
||||
rb = ures_getByKeyWithFallback(numElements, gLatnTag, rb, &ec);
|
||||
rb = ures_getByKeyWithFallback(rb, gPatternsTag, rb, &ec);
|
||||
numberStylePattern = ures_getStringByKeyWithFallback(rb, gDecimalFormatTag, &ptnLen, &ec);
|
||||
ures_getByKeyWithFallback(numElements.getAlias(), gLatnTag, rb.getAlias(), &ec);
|
||||
ures_getByKeyWithFallback(rb.getAlias(), gPatternsTag, rb.getAlias(), &ec);
|
||||
numberStylePattern = ures_getStringByKeyWithFallback(rb.getAlias(), gDecimalFormatTag, &ptnLen, &ec);
|
||||
}
|
||||
int32_t numberStylePatternLen = ptnLen;
|
||||
const UChar* negNumberStylePattern = NULL;
|
||||
const UChar* negNumberStylePattern = nullptr;
|
||||
int32_t negNumberStylePatternLen = 0;
|
||||
// TODO: Java
|
||||
// parse to check whether there is ";" separator in the numberStylePattern
|
||||
|
|
@ -275,127 +315,127 @@ CurrencyPluralInfo::setupCurrencyPluralPattern(const Locale& loc, UErrorCode& st
|
|||
}
|
||||
}
|
||||
|
||||
ures_close(numElements);
|
||||
ures_close(rb);
|
||||
delete ns;
|
||||
|
||||
if (U_FAILURE(ec)) {
|
||||
// If OOM occurred during the above code, then we want to report that back to the caller.
|
||||
if (ec == U_MEMORY_ALLOCATION_ERROR) {
|
||||
status = ec;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
UResourceBundle *currRb = ures_open(U_ICUDATA_CURR, loc.getName(), &ec);
|
||||
UResourceBundle *currencyRes = ures_getByKeyWithFallback(currRb, gCurrUnitPtnTag, NULL, &ec);
|
||||
LocalUResourceBundlePointer currRb(ures_open(U_ICUDATA_CURR, loc.getName(), &ec));
|
||||
LocalUResourceBundlePointer currencyRes(ures_getByKeyWithFallback(currRb.getAlias(), gCurrUnitPtnTag, nullptr, &ec));
|
||||
|
||||
#ifdef CURRENCY_PLURAL_INFO_DEBUG
|
||||
std::cout << "in set up\n";
|
||||
#endif
|
||||
StringEnumeration* keywords = fPluralRules->getKeywords(ec);
|
||||
LocalPointer<StringEnumeration> keywords(fPluralRules->getKeywords(ec), ec);
|
||||
if (U_SUCCESS(ec)) {
|
||||
const char* pluralCount;
|
||||
while ((pluralCount = keywords->next(NULL, ec)) != NULL) {
|
||||
if ( U_SUCCESS(ec) ) {
|
||||
int32_t ptnLen;
|
||||
UErrorCode err = U_ZERO_ERROR;
|
||||
const UChar* patternChars = ures_getStringByKeyWithFallback(
|
||||
currencyRes, pluralCount, &ptnLen, &err);
|
||||
if (U_SUCCESS(err) && ptnLen > 0) {
|
||||
UnicodeString* pattern = new UnicodeString(patternChars, ptnLen);
|
||||
#ifdef CURRENCY_PLURAL_INFO_DEBUG
|
||||
char result_1[1000];
|
||||
pattern->extract(0, pattern->length(), result_1, "UTF-8");
|
||||
std::cout << "pluralCount: " << pluralCount << "; pattern: " << result_1 << "\n";
|
||||
#endif
|
||||
pattern->findAndReplace(UnicodeString(TRUE, gPart0, 3),
|
||||
UnicodeString(numberStylePattern, numberStylePatternLen));
|
||||
pattern->findAndReplace(UnicodeString(TRUE, gPart1, 3), UnicodeString(TRUE, gTripleCurrencySign, 3));
|
||||
|
||||
if (hasSeparator) {
|
||||
UnicodeString negPattern(patternChars, ptnLen);
|
||||
negPattern.findAndReplace(UnicodeString(TRUE, gPart0, 3),
|
||||
UnicodeString(negNumberStylePattern, negNumberStylePatternLen));
|
||||
negPattern.findAndReplace(UnicodeString(TRUE, gPart1, 3), UnicodeString(TRUE, gTripleCurrencySign, 3));
|
||||
pattern->append(gNumberPatternSeparator);
|
||||
pattern->append(negPattern);
|
||||
}
|
||||
#ifdef CURRENCY_PLURAL_INFO_DEBUG
|
||||
pattern->extract(0, pattern->length(), result_1, "UTF-8");
|
||||
std::cout << "pluralCount: " << pluralCount << "; pattern: " << result_1 << "\n";
|
||||
#endif
|
||||
|
||||
fPluralCountToCurrencyUnitPattern->put(UnicodeString(pluralCount, -1, US_INV), pattern, status);
|
||||
while (((pluralCount = keywords->next(nullptr, ec)) != nullptr) && U_SUCCESS(ec)) {
|
||||
int32_t ptnLength;
|
||||
UErrorCode err = U_ZERO_ERROR;
|
||||
const UChar* patternChars = ures_getStringByKeyWithFallback(currencyRes.getAlias(), pluralCount, &ptnLength, &err);
|
||||
if (err == U_MEMORY_ALLOCATION_ERROR || patternChars == nullptr) {
|
||||
ec = err;
|
||||
break;
|
||||
}
|
||||
if (U_SUCCESS(err) && ptnLength > 0) {
|
||||
UnicodeString* pattern = new UnicodeString(patternChars, ptnLength);
|
||||
if (pattern == nullptr) {
|
||||
ec = U_MEMORY_ALLOCATION_ERROR;
|
||||
break;
|
||||
}
|
||||
#ifdef CURRENCY_PLURAL_INFO_DEBUG
|
||||
char result_1[1000];
|
||||
pattern->extract(0, pattern->length(), result_1, "UTF-8");
|
||||
std::cout << "pluralCount: " << pluralCount << "; pattern: " << result_1 << "\n";
|
||||
#endif
|
||||
pattern->findAndReplace(UnicodeString(TRUE, gPart0, 3),
|
||||
UnicodeString(numberStylePattern, numberStylePatternLen));
|
||||
pattern->findAndReplace(UnicodeString(TRUE, gPart1, 3), UnicodeString(TRUE, gTripleCurrencySign, 3));
|
||||
|
||||
if (hasSeparator) {
|
||||
UnicodeString negPattern(patternChars, ptnLength);
|
||||
negPattern.findAndReplace(UnicodeString(TRUE, gPart0, 3),
|
||||
UnicodeString(negNumberStylePattern, negNumberStylePatternLen));
|
||||
negPattern.findAndReplace(UnicodeString(TRUE, gPart1, 3), UnicodeString(TRUE, gTripleCurrencySign, 3));
|
||||
pattern->append(gNumberPatternSeparator);
|
||||
pattern->append(negPattern);
|
||||
}
|
||||
#ifdef CURRENCY_PLURAL_INFO_DEBUG
|
||||
pattern->extract(0, pattern->length(), result_1, "UTF-8");
|
||||
std::cout << "pluralCount: " << pluralCount << "; pattern: " << result_1 << "\n";
|
||||
#endif
|
||||
// the 'pattern' object allocated above will be owned by the fPluralCountToCurrencyUnitPattern after the call to
|
||||
// put(), even if the method returns failure.
|
||||
fPluralCountToCurrencyUnitPattern->put(UnicodeString(pluralCount, -1, US_INV), pattern, status);
|
||||
}
|
||||
}
|
||||
}
|
||||
delete keywords;
|
||||
ures_close(currencyRes);
|
||||
ures_close(currRb);
|
||||
// If OOM occurred during the above code, then we want to report that back to the caller.
|
||||
if (ec == U_MEMORY_ALLOCATION_ERROR) {
|
||||
status = ec;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
CurrencyPluralInfo::deleteHash(Hashtable* hTable)
|
||||
{
|
||||
if ( hTable == NULL ) {
|
||||
CurrencyPluralInfo::deleteHash(Hashtable* hTable) {
|
||||
if ( hTable == nullptr ) {
|
||||
return;
|
||||
}
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement* element = NULL;
|
||||
while ( (element = hTable->nextElement(pos)) != NULL ) {
|
||||
const UHashElement* element = nullptr;
|
||||
while ( (element = hTable->nextElement(pos)) != nullptr ) {
|
||||
const UHashTok valueTok = element->value;
|
||||
const UnicodeString* value = (UnicodeString*)valueTok.pointer;
|
||||
delete value;
|
||||
}
|
||||
delete hTable;
|
||||
hTable = NULL;
|
||||
hTable = nullptr;
|
||||
}
|
||||
|
||||
|
||||
Hashtable*
|
||||
CurrencyPluralInfo::initHash(UErrorCode& status) {
|
||||
if ( U_FAILURE(status) ) {
|
||||
return NULL;
|
||||
if (U_FAILURE(status)) {
|
||||
return nullptr;
|
||||
}
|
||||
Hashtable* hTable;
|
||||
if ( (hTable = new Hashtable(TRUE, status)) == NULL ) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
if ( U_FAILURE(status) ) {
|
||||
delete hTable;
|
||||
return NULL;
|
||||
LocalPointer<Hashtable> hTable(new Hashtable(TRUE, status), status);
|
||||
if (U_FAILURE(status)) {
|
||||
return nullptr;
|
||||
}
|
||||
hTable->setValueComparator(ValueComparator);
|
||||
return hTable;
|
||||
return hTable.orphan();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CurrencyPluralInfo::copyHash(const Hashtable* source,
|
||||
Hashtable* target,
|
||||
UErrorCode& status) {
|
||||
if ( U_FAILURE(status) ) {
|
||||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
}
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement* element = NULL;
|
||||
if ( source ) {
|
||||
while ( (element = source->nextElement(pos)) != NULL ) {
|
||||
const UHashElement* element = nullptr;
|
||||
if (source) {
|
||||
while ( (element = source->nextElement(pos)) != nullptr ) {
|
||||
const UHashTok keyTok = element->key;
|
||||
const UnicodeString* key = (UnicodeString*)keyTok.pointer;
|
||||
const UHashTok valueTok = element->value;
|
||||
const UnicodeString* value = (UnicodeString*)valueTok.pointer;
|
||||
UnicodeString* copy = new UnicodeString(*value);
|
||||
target->put(UnicodeString(*key), copy, status);
|
||||
if ( U_FAILURE(status) ) {
|
||||
LocalPointer<UnicodeString> copy(new UnicodeString(*value), status);
|
||||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
}
|
||||
// The HashTable owns the 'copy' object after the call to put().
|
||||
target->put(UnicodeString(*key), copy.orphan(), status);
|
||||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
**********************************************************************
|
||||
|
|
@ -16,26 +16,62 @@
|
|||
|
||||
#include "unicode/currunit.h"
|
||||
#include "unicode/ustring.h"
|
||||
#include "cstring.h"
|
||||
#include "uinvchar.h"
|
||||
|
||||
static constexpr char16_t kDefaultCurrency[] = u"XXX";
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
CurrencyUnit::CurrencyUnit(const UChar* _isoCode, UErrorCode& ec) {
|
||||
*isoCode = 0;
|
||||
if (U_SUCCESS(ec)) {
|
||||
if (_isoCode && u_strlen(_isoCode)==3) {
|
||||
u_strcpy(isoCode, _isoCode);
|
||||
char simpleIsoCode[4];
|
||||
u_UCharsToChars(isoCode, simpleIsoCode, 4);
|
||||
initCurrency(simpleIsoCode);
|
||||
} else {
|
||||
ec = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
}
|
||||
CurrencyUnit::CurrencyUnit(ConstChar16Ptr _isoCode, UErrorCode& ec) {
|
||||
// The constructor always leaves the CurrencyUnit in a valid state (with a 3-character currency code).
|
||||
// Note: in ICU4J Currency.getInstance(), we check string length for 3, but in ICU4C we allow a
|
||||
// non-NUL-terminated string to be passed as an argument, so it is not possible to check length.
|
||||
// However, we allow a NUL-terminated empty string, which should have the same behavior as nullptr.
|
||||
// Consider NUL-terminated strings of length 1 or 2 as invalid.
|
||||
const char16_t* isoCodeToUse;
|
||||
if (U_FAILURE(ec) || _isoCode == nullptr || _isoCode[0] == 0) {
|
||||
isoCodeToUse = kDefaultCurrency;
|
||||
} else if (_isoCode[1] == 0 || _isoCode[2] == 0) {
|
||||
isoCodeToUse = kDefaultCurrency;
|
||||
ec = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
} else if (!uprv_isInvariantUString(_isoCode, 3)) {
|
||||
// TODO: Perform a more strict ASCII check like in ICU4J isAlpha3Code?
|
||||
isoCodeToUse = kDefaultCurrency;
|
||||
ec = U_INVARIANT_CONVERSION_ERROR;
|
||||
} else {
|
||||
isoCodeToUse = _isoCode;
|
||||
}
|
||||
// TODO: Perform uppercasing here like in ICU4J Currency.getInstance()?
|
||||
uprv_memcpy(isoCode, isoCodeToUse, sizeof(UChar) * 3);
|
||||
isoCode[3] = 0;
|
||||
char simpleIsoCode[4];
|
||||
u_UCharsToChars(isoCode, simpleIsoCode, 4);
|
||||
initCurrency(simpleIsoCode);
|
||||
}
|
||||
|
||||
CurrencyUnit::CurrencyUnit(const CurrencyUnit& other) : MeasureUnit(other) {
|
||||
u_strcpy(isoCode, other.isoCode);
|
||||
}
|
||||
|
||||
CurrencyUnit::CurrencyUnit(const MeasureUnit& other, UErrorCode& ec) : MeasureUnit(other) {
|
||||
// Make sure this is a currency.
|
||||
// OK to hard-code the string because we are comparing against another hard-coded string.
|
||||
if (uprv_strcmp("currency", getType()) != 0) {
|
||||
ec = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
isoCode[0] = 0;
|
||||
} else {
|
||||
// Get the ISO Code from the subtype field.
|
||||
u_charsToUChars(getSubtype(), isoCode, 4);
|
||||
isoCode[3] = 0; // make 100% sure it is NUL-terminated
|
||||
}
|
||||
}
|
||||
|
||||
CurrencyUnit::CurrencyUnit(const CurrencyUnit& other) :
|
||||
MeasureUnit(other) {
|
||||
u_strcpy(isoCode, other.isoCode);
|
||||
CurrencyUnit::CurrencyUnit() : MeasureUnit() {
|
||||
u_strcpy(isoCode, kDefaultCurrency);
|
||||
char simpleIsoCode[4];
|
||||
u_UCharsToChars(isoCode, simpleIsoCode, 4);
|
||||
initCurrency(simpleIsoCode);
|
||||
}
|
||||
|
||||
CurrencyUnit& CurrencyUnit::operator=(const CurrencyUnit& other) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
******************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*****************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
@ -80,7 +80,7 @@ public:
|
|||
fSkeleton(other.fSkeleton) { }
|
||||
virtual ~DateFmtBestPatternKey();
|
||||
virtual int32_t hashCode() const {
|
||||
return 37 * LocaleCacheKey<DateFmtBestPattern>::hashCode() + fSkeleton.hashCode();
|
||||
return (int32_t)(37u * (uint32_t)LocaleCacheKey<DateFmtBestPattern>::hashCode() + (uint32_t)fSkeleton.hashCode());
|
||||
}
|
||||
virtual UBool operator==(const CacheKeyBase &other) const {
|
||||
// reflexive
|
||||
|
|
@ -498,7 +498,7 @@ DateFormat* U_EXPORT2
|
|||
DateFormat::create(EStyle timeStyle, EStyle dateStyle, const Locale& locale)
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
#if U_PLATFORM_HAS_WIN32_API
|
||||
#if U_PLATFORM_USES_ONLY_WIN32_API
|
||||
char buffer[8];
|
||||
int32_t count = locale.getKeywordValue("compat", buffer, sizeof(buffer), status);
|
||||
|
||||
|
|
@ -586,6 +586,7 @@ DateFormat::adoptNumberFormat(NumberFormat* newNumberFormat)
|
|||
delete fNumberFormat;
|
||||
fNumberFormat = newNumberFormat;
|
||||
newNumberFormat->setParseIntegerOnly(TRUE);
|
||||
newNumberFormat->setGroupingUsed(FALSE);
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
|
@ -738,7 +739,7 @@ DateFormat::setBooleanAttribute(UDateFormatBooleanAttribute attr,
|
|||
UBool
|
||||
DateFormat::getBooleanAttribute(UDateFormatBooleanAttribute attr, UErrorCode &/*status*/) const {
|
||||
|
||||
return fBoolFlags.get(attr);
|
||||
return static_cast<UBool>(fBoolFlags.get(attr));
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
@ -174,7 +174,7 @@ struct DayPeriodRulesDataSink : public ResourceSink {
|
|||
}
|
||||
}
|
||||
|
||||
void addCutoff(CutoffType type, UnicodeString hour_str, UErrorCode &errorCode) {
|
||||
void addCutoff(CutoffType type, const UnicodeString &hour_str, UErrorCode &errorCode) {
|
||||
if (U_FAILURE(errorCode)) { return; }
|
||||
|
||||
if (type == CUTOFF_TYPE_UNKNOWN) {
|
||||
|
|
@ -340,7 +340,7 @@ const DayPeriodRules *DayPeriodRules::getInstance(const Locale &locale, UErrorCo
|
|||
// does), return NULL.
|
||||
if(U_FAILURE(errorCode)) { return NULL; }
|
||||
|
||||
const char *localeCode = locale.getName();
|
||||
const char *localeCode = locale.getBaseName();
|
||||
char name[ULOC_FULLNAME_CAPACITY];
|
||||
char parentName[ULOC_FULLNAME_CAPACITY];
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
|
|||
|
|
@ -1,54 +0,0 @@
|
|||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
********************************************************************************
|
||||
* Copyright (C) 2012-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef DCFMTIMP_H
|
||||
#define DCFMTIMP_H
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
|
||||
#if UCONFIG_FORMAT_FASTPATHS_49
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
enum EDecimalFormatFastpathStatus {
|
||||
kFastpathNO = 0,
|
||||
kFastpathYES = 1,
|
||||
kFastpathUNKNOWN = 2, /* not yet set */
|
||||
kFastpathMAYBE = 3 /* depends on value being formatted. */
|
||||
};
|
||||
|
||||
/**
|
||||
* Must be smaller than DecimalFormat::fReserved
|
||||
*/
|
||||
struct DecimalFormatInternal {
|
||||
uint8_t fFastFormatStatus;
|
||||
uint8_t fFastParseStatus;
|
||||
|
||||
DecimalFormatInternal &operator=(const DecimalFormatInternal& rhs) {
|
||||
fFastParseStatus = rhs.fFastParseStatus;
|
||||
fFastFormatStatus = rhs.fFastFormatStatus;
|
||||
return *this;
|
||||
}
|
||||
#ifdef FMT_DEBUG
|
||||
void dump() const {
|
||||
printf("DecimalFormatInternal: fFastFormatStatus=%c, fFastParseStatus=%c\n",
|
||||
"NY?"[(int)fFastFormatStatus&3],
|
||||
"NY?"[(int)fFastParseStatus&3]
|
||||
);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -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
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
@ -38,6 +38,7 @@
|
|||
#include "uresimp.h"
|
||||
#include "ureslocs.h"
|
||||
#include "charstr.h"
|
||||
#include "uassert.h"
|
||||
|
||||
// *****************************************************************************
|
||||
// class DecimalFormatSymbols
|
||||
|
|
@ -65,7 +66,7 @@ static const UChar INTL_CURRENCY_SYMBOL_STR[] = {0xa4, 0xa4, 0};
|
|||
static const char *gNumberElementKeys[DecimalFormatSymbols::kFormatSymbolCount] = {
|
||||
"decimal",
|
||||
"group",
|
||||
"list",
|
||||
NULL, /* #11897: the <list> symbol is NOT the pattern separator symbol */
|
||||
"percentSign",
|
||||
NULL, /* Native zero digit is deprecated from CLDR - get it from the numbering system */
|
||||
NULL, /* Pattern digit character is deprecated from CLDR - use # by default always */
|
||||
|
|
@ -97,9 +98,7 @@ static const char *gNumberElementKeys[DecimalFormatSymbols::kFormatSymbolCount]
|
|||
// Initializes this with the decimal format symbols in the default locale.
|
||||
|
||||
DecimalFormatSymbols::DecimalFormatSymbols(UErrorCode& status)
|
||||
: UObject(),
|
||||
locale()
|
||||
{
|
||||
: UObject(), locale(), currPattern(NULL) {
|
||||
initialize(locale, status, TRUE);
|
||||
}
|
||||
|
||||
|
|
@ -107,16 +106,17 @@ DecimalFormatSymbols::DecimalFormatSymbols(UErrorCode& status)
|
|||
// Initializes this with the decimal format symbols in the desired locale.
|
||||
|
||||
DecimalFormatSymbols::DecimalFormatSymbols(const Locale& loc, UErrorCode& status)
|
||||
: UObject(),
|
||||
locale(loc)
|
||||
{
|
||||
: UObject(), locale(loc), currPattern(NULL) {
|
||||
initialize(locale, status);
|
||||
}
|
||||
|
||||
DecimalFormatSymbols::DecimalFormatSymbols(const Locale& loc, const NumberingSystem& ns, UErrorCode& status)
|
||||
: UObject(), locale(loc), currPattern(NULL) {
|
||||
initialize(locale, status, FALSE, &ns);
|
||||
}
|
||||
|
||||
DecimalFormatSymbols::DecimalFormatSymbols()
|
||||
: UObject(),
|
||||
locale(Locale::getRoot()),
|
||||
currPattern(NULL) {
|
||||
: UObject(), locale(Locale::getRoot()), currPattern(NULL) {
|
||||
*validLocale = *actualLocale = 0;
|
||||
initialize();
|
||||
}
|
||||
|
|
@ -166,6 +166,7 @@ DecimalFormatSymbols::operator=(const DecimalFormatSymbols& rhs)
|
|||
uprv_strcpy(actualLocale, rhs.actualLocale);
|
||||
fIsCustomCurrencySymbol = rhs.fIsCustomCurrencySymbol;
|
||||
fIsCustomIntlCurrencySymbol = rhs.fIsCustomIntlCurrencySymbol;
|
||||
fCodePointZero = rhs.fCodePointZero;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -197,6 +198,7 @@ DecimalFormatSymbols::operator==(const DecimalFormatSymbols& that) const
|
|||
return FALSE;
|
||||
}
|
||||
}
|
||||
// No need to check fCodePointZero since it is based on fSymbols
|
||||
return locale == that.locale &&
|
||||
uprv_strcmp(validLocale, that.validLocale) == 0 &&
|
||||
uprv_strcmp(actualLocale, that.actualLocale) == 0;
|
||||
|
|
@ -342,11 +344,11 @@ CurrencySpacingSink::~CurrencySpacingSink() {}
|
|||
} // namespace
|
||||
|
||||
void
|
||||
DecimalFormatSymbols::initialize(const Locale& loc, UErrorCode& status, UBool useLastResortData)
|
||||
DecimalFormatSymbols::initialize(const Locale& loc, UErrorCode& status,
|
||||
UBool useLastResortData, const NumberingSystem* ns)
|
||||
{
|
||||
if (U_FAILURE(status)) { return; }
|
||||
*validLocale = *actualLocale = 0;
|
||||
currPattern = NULL;
|
||||
|
||||
// First initialize all the symbols to the fallbacks for anything we can't find
|
||||
initialize();
|
||||
|
|
@ -355,7 +357,13 @@ DecimalFormatSymbols::initialize(const Locale& loc, UErrorCode& status, UBool us
|
|||
// Next get the numbering system for this locale and set zero digit
|
||||
// and the digit string based on the numbering system for the locale
|
||||
//
|
||||
LocalPointer<NumberingSystem> ns(NumberingSystem::createInstance(loc, status));
|
||||
LocalPointer<NumberingSystem> nsLocal;
|
||||
if (ns == nullptr) {
|
||||
// Use the numbering system according to the locale.
|
||||
// Save it into a LocalPointer so it gets cleaned up.
|
||||
nsLocal.adoptInstead(NumberingSystem::createInstance(loc, status));
|
||||
ns = nsLocal.getAlias();
|
||||
}
|
||||
const char *nsName;
|
||||
if (U_SUCCESS(status) && ns->getRadix() == 10 && !ns->isAlgorithmic()) {
|
||||
nsName = ns->getName();
|
||||
|
|
@ -427,18 +435,37 @@ DecimalFormatSymbols::initialize(const Locale& loc, UErrorCode& status, UBool us
|
|||
// Let the monetary number separators equal the default number separators if necessary.
|
||||
sink.resolveMissingMonetarySeparators(fSymbols);
|
||||
|
||||
// Resolve codePointZero
|
||||
UChar32 tempCodePointZero = -1;
|
||||
for (int32_t i=0; i<=9; i++) {
|
||||
const UnicodeString& stringDigit = getConstDigitSymbol(i);
|
||||
if (stringDigit.countChar32() != 1) {
|
||||
tempCodePointZero = -1;
|
||||
break;
|
||||
}
|
||||
UChar32 cp = stringDigit.char32At(0);
|
||||
if (i == 0) {
|
||||
tempCodePointZero = cp;
|
||||
} else if (cp != tempCodePointZero + i) {
|
||||
tempCodePointZero = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
fCodePointZero = tempCodePointZero;
|
||||
|
||||
// Obtain currency data from the currency API. This is strictly
|
||||
// for backward compatibility; we don't use DecimalFormatSymbols
|
||||
// for currency data anymore.
|
||||
UErrorCode internalStatus = U_ZERO_ERROR; // don't propagate failures out
|
||||
UChar curriso[4];
|
||||
UnicodeString tempStr;
|
||||
ucurr_forLocale(locStr, curriso, 4, &internalStatus);
|
||||
|
||||
uprv_getStaticCurrencyName(curriso, locStr, tempStr, internalStatus);
|
||||
if (U_SUCCESS(internalStatus)) {
|
||||
fSymbols[kIntlCurrencySymbol].setTo(curriso, -1);
|
||||
fSymbols[kCurrencySymbol] = tempStr;
|
||||
int32_t currisoLength = ucurr_forLocale(locStr, curriso, UPRV_LENGTHOF(curriso), &internalStatus);
|
||||
if (U_SUCCESS(internalStatus) && currisoLength == 3) {
|
||||
uprv_getStaticCurrencyName(curriso, locStr, tempStr, internalStatus);
|
||||
if (U_SUCCESS(internalStatus)) {
|
||||
fSymbols[kIntlCurrencySymbol].setTo(curriso, currisoLength);
|
||||
fSymbols[kCurrencySymbol] = tempStr;
|
||||
}
|
||||
}
|
||||
/* else use the default values. */
|
||||
|
||||
|
|
@ -449,6 +476,7 @@ DecimalFormatSymbols::initialize(const Locale& loc, UErrorCode& status, UBool us
|
|||
UErrorCode localStatus = U_ZERO_ERROR;
|
||||
uccLen = ucurr_forLocale(locName, ucc, uccLen, &localStatus);
|
||||
|
||||
// TODO: Currency pattern data loading is duplicated in number_formatimpl.cpp
|
||||
if(U_SUCCESS(localStatus) && uccLen > 0) {
|
||||
char cc[4]={0};
|
||||
u_UCharsToChars(ucc, cc, uccLen);
|
||||
|
|
@ -523,6 +551,8 @@ DecimalFormatSymbols::initialize() {
|
|||
fSymbols[kExponentMultiplicationSymbol] = (UChar)0xd7; // 'x' multiplication symbol for exponents
|
||||
fIsCustomCurrencySymbol = FALSE;
|
||||
fIsCustomIntlCurrencySymbol = FALSE;
|
||||
fCodePointZero = 0x30;
|
||||
U_ASSERT(fCodePointZero == fSymbols[kZeroDigitSymbol].char32At(0));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Decimal Context module */
|
||||
|
|
@ -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
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Decimal Context module header */
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Decimal Number arithmetic module */
|
||||
|
|
@ -386,7 +386,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberFromUInt32(decNumber *dn, uInt uin) {
|
|||
*up=(Unit)(uin%(DECDPUNMAX+1));
|
||||
uin=uin/(DECDPUNMAX+1);
|
||||
}
|
||||
dn->digits=decGetDigits(dn->lsu, up-dn->lsu);
|
||||
dn->digits=decGetDigits(dn->lsu, static_cast<int32_t>(up - dn->lsu));
|
||||
return dn;
|
||||
} /* decNumberFromUInt32 */
|
||||
|
||||
|
|
@ -627,10 +627,12 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberFromString(decNumber *dn, const char
|
|||
|
||||
for (; *c=='0' && *(c+1)!='\0';) c++; /* strip insignificant zeros */
|
||||
firstexp=c; /* save exponent digit place */
|
||||
uInt uexponent = 0; /* Avoid undefined behavior on signed int overflow */
|
||||
for (; ;c++) {
|
||||
if (*c<'0' || *c>'9') break; /* not a digit */
|
||||
exponent=X10(exponent)+(Int)*c-(Int)'0';
|
||||
uexponent=X10(uexponent)+(uInt)*c-(uInt)'0';
|
||||
} /* c */
|
||||
exponent = (Int)uexponent;
|
||||
/* if not now on a '\0', *c must not be a digit */
|
||||
if (*c!='\0') break;
|
||||
|
||||
|
|
@ -666,7 +668,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberFromString(decNumber *dn, const char
|
|||
|
||||
/* Handle decimal point... */
|
||||
if (dotchar!=NULL && dotchar<last) /* non-trailing '.' found? */
|
||||
exponent-=(last-dotchar); /* adjust exponent */
|
||||
exponent -= static_cast<int32_t>(last-dotchar); /* adjust exponent */
|
||||
/* [we can now ignore the .] */
|
||||
|
||||
/* OK, the digits string is good. Assemble in the decNumber, or in */
|
||||
|
|
@ -866,7 +868,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberAnd(decNumber *res, const decNumber *
|
|||
} /* both OK */
|
||||
} /* each unit */
|
||||
/* [here uc-1 is the msu of the result] */
|
||||
res->digits=decGetDigits(res->lsu, uc-res->lsu);
|
||||
res->digits=decGetDigits(res->lsu, static_cast<int32_t>(uc - res->lsu));
|
||||
res->exponent=0; /* integer */
|
||||
res->bits=0; /* sign=0 */
|
||||
return res; /* [no status to set] */
|
||||
|
|
@ -1253,7 +1255,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberInvert(decNumber *res, const decNumbe
|
|||
} /* each digit */
|
||||
} /* each unit */
|
||||
/* [here uc-1 is the msu of the result] */
|
||||
res->digits=decGetDigits(res->lsu, uc-res->lsu);
|
||||
res->digits=decGetDigits(res->lsu, static_cast<int32_t>(uc - res->lsu));
|
||||
res->exponent=0; /* integer */
|
||||
res->bits=0; /* sign=0 */
|
||||
return res; /* [no status to set] */
|
||||
|
|
@ -1880,7 +1882,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberOr(decNumber *res, const decNumber *l
|
|||
} /* non-zero */
|
||||
} /* each unit */
|
||||
/* [here uc-1 is the msu of the result] */
|
||||
res->digits=decGetDigits(res->lsu, uc-res->lsu);
|
||||
res->digits=decGetDigits(res->lsu, static_cast<int32_t>(uc-res->lsu));
|
||||
res->exponent=0; /* integer */
|
||||
res->bits=0; /* sign=0 */
|
||||
return res; /* [no status to set] */
|
||||
|
|
@ -2586,7 +2588,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberRotate(decNumber *res, const decNumbe
|
|||
} /* whole units to rotate */
|
||||
/* the rotation may have left an undetermined number of zeros */
|
||||
/* on the left, so true length needs to be calculated */
|
||||
res->digits=decGetDigits(res->lsu, msumax-res->lsu+1);
|
||||
res->digits=decGetDigits(res->lsu, static_cast<int32_t>(msumax-res->lsu+1));
|
||||
} /* rotate needed */
|
||||
} /* rhs OK */
|
||||
} /* numerics */
|
||||
|
|
@ -3310,7 +3312,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberXor(decNumber *res, const decNumber *
|
|||
} /* non-zero */
|
||||
} /* each unit */
|
||||
/* [here uc-1 is the msu of the result] */
|
||||
res->digits=decGetDigits(res->lsu, uc-res->lsu);
|
||||
res->digits=decGetDigits(res->lsu, static_cast<int32_t>(uc-res->lsu));
|
||||
res->exponent=0; /* integer */
|
||||
res->bits=0; /* sign=0 */
|
||||
return res; /* [no status to set] */
|
||||
|
|
@ -5007,7 +5009,7 @@ static decNumber * decMultiplyOp(decNumber *res, const decNumber *lhs,
|
|||
|
||||
/* Make sure no signed int overflow below. This is always true */
|
||||
/* if the given numbers have less digits than DEC_MAX_DIGITS. */
|
||||
U_ASSERT(iacc <= INT32_MAX/sizeof(uLong));
|
||||
U_ASSERT((uint32_t)iacc <= INT32_MAX/sizeof(uLong));
|
||||
needbytes=iacc*sizeof(uLong);
|
||||
#if DECDPUN==1
|
||||
zoff=(iacc+7)/8; /* items to offset by */
|
||||
|
|
@ -5101,7 +5103,7 @@ static decNumber * decMultiplyOp(decNumber *res, const decNumber *lhs,
|
|||
} /* p */
|
||||
*up=(Unit)item; up++; /* [final needs no division] */
|
||||
} /* lp */
|
||||
accunits=up-acc; /* count of units */
|
||||
accunits = static_cast<int32_t>(up-acc); /* count of units */
|
||||
}
|
||||
else { /* here to use units directly, without chunking ['old code'] */
|
||||
#endif
|
||||
|
|
@ -6587,11 +6589,11 @@ static Int decUnitAddSub(const Unit *a, Int alength,
|
|||
|
||||
/* OK, all A and B processed; might still have carry or borrow */
|
||||
/* return number of Units in the result, negated if a borrow */
|
||||
if (carry==0) return c-clsu; /* no carry, so no more to do */
|
||||
if (carry==0) return static_cast<int32_t>(c-clsu); /* no carry, so no more to do */
|
||||
if (carry>0) { /* positive carry */
|
||||
*c=(Unit)carry; /* place as new unit */
|
||||
c++; /* .. */
|
||||
return c-clsu;
|
||||
return static_cast<int32_t>(c-clsu);
|
||||
}
|
||||
/* -ve carry: it's a borrow; complement needed */
|
||||
add=1; /* temporary carry... */
|
||||
|
|
@ -6614,7 +6616,7 @@ static Int decUnitAddSub(const Unit *a, Int alength,
|
|||
*c=(Unit)(add-carry-1);
|
||||
c++; /* interesting, include it */
|
||||
}
|
||||
return clsu-c; /* -ve result indicates borrowed */
|
||||
return static_cast<int32_t>(clsu-c); /* -ve result indicates borrowed */
|
||||
} /* decUnitAddSub */
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
|
@ -6798,7 +6800,7 @@ static Int decShiftToLeast(Unit *uar, Int units, Int shift) {
|
|||
if (cut==DECDPUN) { /* unit-boundary case; easy */
|
||||
up=uar+D2U(shift);
|
||||
for (; up<uar+units; target++, up++) *target=*up;
|
||||
return target-uar;
|
||||
return static_cast<int32_t>(target-uar);
|
||||
}
|
||||
|
||||
/* messier */
|
||||
|
|
@ -6826,7 +6828,7 @@ static Int decShiftToLeast(Unit *uar, Int units, Int shift) {
|
|||
count-=cut;
|
||||
if (count<=0) break;
|
||||
}
|
||||
return target-uar+1;
|
||||
return static_cast<int32_t>(target-uar+1);
|
||||
} /* decShiftToLeast */
|
||||
|
||||
#if DECSUBSET
|
||||
|
|
@ -7690,7 +7692,7 @@ static decNumber *decDecap(decNumber *dn, Int drop) {
|
|||
cut=MSUDIGITS(dn->digits-drop); /* digits to be in use in msu */
|
||||
if (cut!=DECDPUN) *msu%=powers[cut]; /* clear left digits */
|
||||
/* that may have left leading zero digits, so do a proper count... */
|
||||
dn->digits=decGetDigits(dn->lsu, msu-dn->lsu+1);
|
||||
dn->digits=decGetDigits(dn->lsu, static_cast<int32_t>(msu-dn->lsu+1));
|
||||
return dn;
|
||||
} /* decDecap */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue