| Index: source/i18n/gregoimp.cpp
|
| diff --git a/source/i18n/gregoimp.cpp b/source/i18n/gregoimp.cpp
|
| index 08a3fbcef4ccf5d6bd25302990b5a9e2e67de00d..1b313602d61f13fa79dfa40e9f1a3eed754c55a8 100644
|
| --- a/source/i18n/gregoimp.cpp
|
| +++ b/source/i18n/gregoimp.cpp
|
| @@ -1,3 +1,5 @@
|
| +// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
| +// License & terms of use: http://www.unicode.org/copyright.html
|
| /*
|
| **********************************************************************
|
| * Copyright (c) 2003-2008, International Business Machines
|
| @@ -18,10 +20,6 @@
|
| #include "cstring.h"
|
| #include "uassert.h"
|
|
|
| -#if defined(U_DEBUG_CALDATA)
|
| -#include <stdio.h>
|
| -#endif
|
| -
|
| U_NAMESPACE_BEGIN
|
|
|
| int32_t ClockMath::floorDivide(int32_t numerator, int32_t denominator) {
|
| @@ -157,171 +155,6 @@ int32_t Grego::dayOfWeekInMonth(int32_t year, int32_t month, int32_t dom) {
|
| return weekInMonth;
|
| }
|
|
|
| -/* ---- CalendarData ------ */
|
| -
|
| -#define U_CALENDAR_KEY "calendar"
|
| -#define U_GREGORIAN_KEY "gregorian"
|
| -#define U_FORMAT_KEY "format"
|
| -#define U_DEFAULT_KEY "default"
|
| -#define U_CALENDAR_DATA ((char*)0)
|
| -
|
| -
|
| -// CalendarData::CalendarData(const Locale& loc, UErrorCode& status)
|
| -// : fFillin(NULL), fBundle(NULL), fFallback(NULL) {
|
| -// initData(loc.getBaseName(), (char*) "???", status);
|
| -// }
|
| -
|
| -CalendarData::CalendarData(const Locale& loc, const char *type, UErrorCode& status)
|
| - : fFillin(NULL), fOtherFillin(NULL), fBundle(NULL), fFallback(NULL) {
|
| - initData(loc.getBaseName(), type, status);
|
| -}
|
| -
|
| -void CalendarData::initData(const char *locale, const char *type, UErrorCode& status) {
|
| - fOtherFillin = ures_open(U_CALENDAR_DATA, locale, &status);
|
| - fFillin = ures_getByKey(fOtherFillin, U_CALENDAR_KEY, fFillin, &status);
|
| -
|
| - if((type != NULL) &&
|
| - (*type != '\0') &&
|
| - (uprv_strcmp(type, U_GREGORIAN_KEY)))
|
| - {
|
| - fBundle = ures_getByKeyWithFallback(fFillin, type, NULL, &status);
|
| - fFallback = ures_getByKeyWithFallback(fFillin, U_GREGORIAN_KEY, NULL, &status);
|
| -
|
| -#if defined (U_DEBUG_CALDATA)
|
| - fprintf(stderr, "%p: CalendarData(%s, %s, %s) -> main(%p, %s)=%s, fallback(%p, %s)=%s\n",
|
| - this, locale, type, u_errorName(status), fBundle, type, fBundle?ures_getLocale(fBundle, &status):"",
|
| - fFallback, U_GREGORIAN_KEY, fFallback?ures_getLocale(fFallback, &status):"");
|
| -#endif
|
| -
|
| - } else {
|
| - fBundle = ures_getByKeyWithFallback(fFillin, U_GREGORIAN_KEY, NULL, &status);
|
| -#if defined (U_DEBUG_CALDATA)
|
| - fprintf(stderr, "%p: CalendarData(%s, %s, %s) -> main(%p, %s)=%s, fallback = NULL\n",
|
| - this, locale, type, u_errorName(status), fBundle, U_GREGORIAN_KEY, fBundle?ures_getLocale(fBundle, &status):"" );
|
| -#endif
|
| - }
|
| -}
|
| -
|
| -CalendarData::~CalendarData() {
|
| - ures_close(fFillin);
|
| - ures_close(fBundle);
|
| - ures_close(fFallback);
|
| - ures_close(fOtherFillin);
|
| -}
|
| -
|
| -UResourceBundle*
|
| -CalendarData::getByKey(const char *key, UErrorCode& status) {
|
| - if(U_FAILURE(status)) {
|
| - return NULL;
|
| - }
|
| -
|
| - if(fBundle) {
|
| - fFillin = ures_getByKeyWithFallback(fBundle, key, fFillin, &status);
|
| -#if defined (U_DEBUG_CALDATA)
|
| - fprintf(stderr, "%p: get %s -> %s - from MAIN %s\n",this, key, 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);
|
| -#if defined (U_DEBUG_CALDATA)
|
| - fprintf(stderr, "%p: get %s -> %s - from FALLBACK %s\n",this, key, u_errorName(status), ures_getLocale(fFillin, &status));
|
| -#endif
|
| - }
|
| - 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
|
|
|