ICU-12614 Rollback of: DateFormatSymbols resource bundle data loading updated to use the ResourceSink.

X-SVN-Rev: 38963
This commit is contained in:
Felipe Balbontín 2016-07-08 23:31:15 +00:00
parent f6b7511c46
commit bfe100bab8
8 changed files with 511 additions and 874 deletions

1
.gitattributes vendored
View File

@ -104,7 +104,6 @@ icu4c/source/data/translit/zu_chr.txt -text
icu4c/source/data/unit/pool.res -text
icu4c/source/data/zone/pool.res -text
icu4c/source/extra/uconv/uconv.vcxproj -text
icu4c/source/i18n/dt_impl.h -text
icu4c/source/samples/break/break.vcxproj -text
icu4c/source/samples/case/case.vcxproj -text
icu4c/source/samples/citer/citer.vcxproj -text

View File

@ -1,92 +0,0 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2007-2016, International Business Machines Corporation and
* others. All Rights Reserved.
*******************************************************************************
*
* File dt_impl.h
*
*******************************************************************************
*/
#ifndef DT_IMPL_H__
#define DT_IMPL_H__
/**
* \file
* \brief C++ API: Defines macros for interval format implementation
*/
#if !UCONFIG_NO_FORMATTING
#include "unicode/unistr.h"
#define QUOTE ((UChar)0x0027)
#define LOW_LINE ((UChar)0x005F)
#define COLON ((UChar)0x003A)
#define LEFT_CURLY_BRACKET ((UChar)0x007B)
#define RIGHT_CURLY_BRACKET ((UChar)0x007D)
#define SPACE ((UChar)0x0020)
#define EN_DASH ((UChar)0x2013)
#define SOLIDUS ((UChar)0x002F)
#define PERCENT ((UChar)0x0025)
#define DIGIT_ZERO ((UChar)0x0030)
#define DIGIT_ONE ((UChar)0x0031)
#define LOW_A ((UChar)0x0061)
#define LOW_B ((UChar)0x0062)
#define LOW_C ((UChar)0x0063)
#define LOW_D ((UChar)0x0064)
#define LOW_E ((UChar)0x0065)
#define LOW_F ((UChar)0x0066)
#define LOW_G ((UChar)0x0067)
#define LOW_H ((UChar)0x0068)
#define LOW_I ((UChar)0x0069)
#define LOW_J ((UChar)0x006a)
#define LOW_K ((UChar)0x006B)
#define LOW_L ((UChar)0x006C)
#define LOW_M ((UChar)0x006D)
#define LOW_N ((UChar)0x006E)
#define LOW_O ((UChar)0x006F)
#define LOW_P ((UChar)0x0070)
#define LOW_Q ((UChar)0x0071)
#define LOW_R ((UChar)0x0072)
#define LOW_S ((UChar)0x0073)
#define LOW_T ((UChar)0x0074)
#define LOW_U ((UChar)0x0075)
#define LOW_V ((UChar)0x0076)
#define LOW_W ((UChar)0x0077)
#define LOW_Y ((UChar)0x0079)
#define LOW_Z ((UChar)0x007A)
#define CAP_A ((UChar)0x0041)
#define CAP_C ((UChar)0x0043)
#define CAP_D ((UChar)0x0044)
#define CAP_E ((UChar)0x0045)
#define CAP_F ((UChar)0x0046)
#define CAP_G ((UChar)0x0047)
#define CAP_H ((UChar)0x0048)
#define CAP_K ((UChar)0x004B)
#define CAP_L ((UChar)0x004C)
#define CAP_M ((UChar)0x004D)
#define CAP_N ((UChar)0x004E)
#define CAP_O ((UChar)0x004F)
#define CAP_P ((UChar)0x0050)
#define CAP_Q ((UChar)0x0051)
#define CAP_S ((UChar)0x0053)
#define CAP_T ((UChar)0x0054)
#define CAP_U ((UChar)0x0055)
#define CAP_V ((UChar)0x0056)
#define CAP_W ((UChar)0x0057)
#define CAP_Y ((UChar)0x0059)
#define CAP_Z ((UChar)0x005A)
#endif /* #if !UCONFIG_NO_FORMATTING */
#endif
//eof

File diff suppressed because it is too large Load Diff

View File

@ -233,6 +233,97 @@ CalendarData::getByKey(const char *key, UErrorCode& status) {
return fFillin;
}
UResourceBundle* CalendarData::getByKey2(const char *key, const char *subKey, UErrorCode& status) {
if(U_FAILURE(status)) {
return NULL;
}
if(fBundle) {
#if defined (U_DEBUG_CALDATA)
fprintf(stderr, "%p: //\n");
#endif
fFillin = ures_getByKeyWithFallback(fBundle, key, fFillin, &status);
fOtherFillin = ures_getByKeyWithFallback(fFillin, U_FORMAT_KEY, fOtherFillin, &status);
fFillin = ures_getByKeyWithFallback(fOtherFillin, subKey, fFillin, &status);
#if defined (U_DEBUG_CALDATA)
fprintf(stderr, "%p: get %s/format/%s -> %s - from MAIN %s\n", this, key, subKey, u_errorName(status), ures_getLocale(fFillin, &status));
#endif
}
if(fFallback && (status == U_MISSING_RESOURCE_ERROR)) {
status = U_ZERO_ERROR; // retry with fallback (gregorian)
fFillin = ures_getByKeyWithFallback(fFallback, key, fFillin, &status);
fOtherFillin = ures_getByKeyWithFallback(fFillin, U_FORMAT_KEY, fOtherFillin, &status);
fFillin = ures_getByKeyWithFallback(fOtherFillin, subKey, fFillin, &status);
#if defined (U_DEBUG_CALDATA)
fprintf(stderr, "%p: get %s/format/%s -> %s - from FALLBACK %s\n",this, key, subKey, u_errorName(status), ures_getLocale(fFillin,&status));
#endif
}
//// handling of 'default' keyword on failure: Commented out for 3.0.
// if((status == U_MISSING_RESOURCE_ERROR) &&
// uprv_strcmp(subKey,U_DEFAULT_KEY)) { // avoid recursion
// #if defined (U_DEBUG_CALDATA)
// fprintf(stderr, "%p: - attempting fallback -\n", this);
// fflush(stderr);
// #endif
// UErrorCode subStatus = U_ZERO_ERROR;
// int32_t len;
// char kwBuf[128] = "";
// const UChar *kw;
// /* fFillin = */ getByKey2(key, U_DEFAULT_KEY, subStatus);
// kw = ures_getString(fFillin, &len, &subStatus);
// if(len>126) { // too big
// len = 0;
// }
// if(U_SUCCESS(subStatus) && (len>0)) {
// u_UCharsToChars(kw, kwBuf, len+1);
// if(*kwBuf && uprv_strcmp(kwBuf,subKey)) {
// #if defined (U_DEBUG_CALDATA)
// fprintf(stderr, "%p: trying %s/format/default -> \"%s\"\n",this, key, kwBuf);
// #endif
// // now try again with the default
// status = U_ZERO_ERROR;
// /* fFillin = */ getByKey2(key, kwBuf, status);
// }
// #if defined (U_DEBUG_CALDATA)
// } else {
// fprintf(stderr, "%p: could not load %s/format/default - fail out (%s)\n",this, key, kwBuf, u_errorName(status));
// #endif
// }
// }
return fFillin;
}
UResourceBundle* CalendarData::getByKey3(const char *key, const char *contextKey, const char *subKey, UErrorCode& status) {
if(U_FAILURE(status)) {
return NULL;
}
if(fBundle) {
#if defined (U_DEBUG_CALDATA)
fprintf(stderr, "%p: //\n");
#endif
fFillin = ures_getByKeyWithFallback(fBundle, key, fFillin, &status);
fOtherFillin = ures_getByKeyWithFallback(fFillin, contextKey, fOtherFillin, &status);
fFillin = ures_getByKeyWithFallback(fOtherFillin, subKey, fFillin, &status);
#if defined (U_DEBUG_CALDATA)
fprintf(stderr, "%p: get %s/%s/%s -> %s - from MAIN %s\n", this, key, contextKey, subKey, u_errorName(status), ures_getLocale(fFillin, &status));
#endif
}
if(fFallback && (status == U_MISSING_RESOURCE_ERROR)) {
status = U_ZERO_ERROR; // retry with fallback (gregorian)
fFillin = ures_getByKeyWithFallback(fFallback, key, fFillin, &status);
fOtherFillin = ures_getByKeyWithFallback(fFillin, contextKey, fOtherFillin, &status);
fFillin = ures_getByKeyWithFallback(fOtherFillin, subKey, fFillin, &status);
#if defined (U_DEBUG_CALDATA)
fprintf(stderr, "%p: get %s/%s/%s -> %s - from FALLBACK %s\n",this, key, contextKey, subKey, u_errorName(status), ures_getLocale(fFillin,&status));
#endif
}
return fFillin;
}
U_NAMESPACE_END
#endif

View File

@ -318,6 +318,34 @@ public:
*/
UResourceBundle* getByKey(const char *key, UErrorCode& status);
/**
* Load data for calendar. Note, this object owns the resources, do NOT call ures_close()!
* There is an implicit key of 'format'
* data is located in: "calendar/key/format/subKey"
* for example, calendar/dayNames/format/abbreviated
* The ResourceBundle C++ API should NOT be used because it is too slow for a low level API.
*
* @param key Resource key to data
* @param subKey Resource key to data
* @param status Error Status
* @internal
*/
UResourceBundle* getByKey2(const char *key, const char *subKey, UErrorCode& status);
/**
* Load data for calendar. Note, this object owns the resources, do NOT call ures_close()!
* data is located in: "calendar/key/contextKey/subKey"
* for example, calendar/dayNames/standalone/narrow
* The ResourceBundle C++ API should NOT be used because it is too slow for a low level API.
*
* @param key Resource key to data
* @param contextKey Resource key to data
* @param subKey Resource key to data
* @param status Error Status
* @internal
*/
UResourceBundle* getByKey3(const char *key, const char *contextKey, const char *subKey, UErrorCode& status);
~CalendarData();
private:

View File

@ -848,7 +848,6 @@
<ClInclude Include="decNumber.h" />
<ClInclude Include="decNumberLocal.h" />
<ClInclude Include="digitlst.h" />
<ClInclude Include="dt_impl.h" />
<CustomBuild Include="unicode\dtfmtsym.h">
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy "%(FullPath)" ..\..\include\unicode
</Command>

View File

@ -715,9 +715,6 @@
<ClInclude Include="digitlst.h">
<Filter>formatting</Filter>
</ClInclude>
<ClInclude Include="dt_impl.h">
<Filter>formatting</Filter>
</ClInclude>
<ClInclude Include="dtitv_impl.h">
<Filter>formatting</Filter>
</ClInclude>

View File

@ -4094,7 +4094,7 @@ void DateFormatTest::TestMonthPatterns()
CharsToUnicodeString("2 s\\u00ECyu\\u00E8bis ren-chen"),
CharsToUnicodeString("2 w\\u01D4yu\\u00E8 ren-chen") } },
{ "fr@calendar=chinese", DateFormat::kShort, { UnicodeString("2/4/29"), UnicodeString("2/4bis/29"), UnicodeString("2/5/29") } },
{ "en@calendar=dangi", DateFormat::kLong, { UnicodeString("Third Monthbis 2, 2012(ren-chen)"), UnicodeString("Fourth Month 2, 2012(ren-chen)"), UnicodeString("Fifth Month 1, 2012(ren-chen)") } },
{ "en@calendar=dangi", DateFormat::kLong, { UnicodeString("Third Monthbis 2, 2012(29)"), UnicodeString("Fourth Month 2, 2012(29)"), UnicodeString("Fifth Month 1, 2012(29)") } },
{ "en@calendar=dangi", DateFormat::kShort, { UnicodeString("3bis/2/2012"), UnicodeString("4/2/2012"), UnicodeString("5/1/2012") } },
{ "en@calendar=dangi", -2, { UnicodeString("78x29-3bis-2"), UnicodeString("78x29-4-2"), UnicodeString("78x29-5-1") } },
{ "ko@calendar=dangi", DateFormat::kLong, { CharsToUnicodeString("\\uC784\\uC9C4\\uB144 \\uC7243\\uC6D4 2\\uC77C"),