mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-11 08:01:32 +00:00
ICU-6402 fixes for IBM i.
X-SVN-Rev: 24317
This commit is contained in:
parent
0f3bf04d8c
commit
d3d779e429
10 changed files with 124 additions and 18 deletions
|
@ -36,8 +36,91 @@
|
|||
|
||||
#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
|
||||
|
||||
#if U_CHARSET_FAMILY==U_EBCDIC_FAMILY
|
||||
/**
|
||||
* If we are on EBCDIC, use an iterator which will
|
||||
* traverse the bundles in ASCII order.
|
||||
*/
|
||||
#define U_USE_ASCII_BUNDLE_ITERATOR
|
||||
#define U_SORT_ASCII_BUNDLE_ITERATOR
|
||||
#endif
|
||||
|
||||
#if defined(U_USE_ASCII_BUNDLE_ITERATOR)
|
||||
|
||||
#include "unicode/ustring.h"
|
||||
#include "uarrsort.h"
|
||||
|
||||
struct UResAEntry {
|
||||
UChar *key;
|
||||
UResourceBundle *item;
|
||||
};
|
||||
|
||||
struct UResourceBundleAIterator {
|
||||
UResourceBundle *bund;
|
||||
UResAEntry *entries;
|
||||
int32_t num;
|
||||
int32_t cursor;
|
||||
};
|
||||
|
||||
static int32_t U_CALLCONV
|
||||
ures_a_codepointSort(const void *context, const void *left, const void *right) {
|
||||
//CompareContext *cmp=(CompareContext *)context;
|
||||
return u_strcmp(((const UResAEntry *)left)->key,
|
||||
((const UResAEntry *)right)->key);
|
||||
}
|
||||
|
||||
|
||||
static void ures_a_open(UResourceBundleAIterator *aiter, UResourceBundle *bund, UErrorCode *status) {
|
||||
if(U_FAILURE(*status)) {
|
||||
return;
|
||||
}
|
||||
aiter->bund = bund;
|
||||
aiter->num = ures_getSize(aiter->bund);
|
||||
aiter->cursor = 0;
|
||||
#if !defined(U_SORT_ASCII_BUNDLE_ITERATOR)
|
||||
aiter->entries = NULL;
|
||||
#else
|
||||
aiter->entries = (UResAEntry*)uprv_malloc(sizeof(UResAEntry)*aiter->num);
|
||||
for(int i=0;i<aiter->num;i++) {
|
||||
aiter->entries[i].item = ures_getByIndex(aiter->bund, i, NULL, status);
|
||||
const char *akey = ures_getKey(aiter->entries[i].item);
|
||||
int32_t len = uprv_strlen(akey)+1;
|
||||
aiter->entries[i].key = (UChar*)uprv_malloc(len*sizeof(UChar));
|
||||
u_charsToUChars(akey, aiter->entries[i].key, len);
|
||||
}
|
||||
uprv_sortArray(aiter->entries, aiter->num, sizeof(UResAEntry), ures_a_codepointSort, NULL, TRUE, status);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void ures_a_close(UResourceBundleAIterator *aiter) {
|
||||
#if defined(U_SORT_ASCII_BUNDLE_ITERATOR)
|
||||
for(int i=0;i<aiter->num;i++) {
|
||||
uprv_free(aiter->entries[i].key);
|
||||
ures_close(aiter->entries[i].item);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static const UChar *ures_a_getNextString(UResourceBundleAIterator *aiter, int32_t *len, const char **key, UErrorCode *err) {
|
||||
#if !defined(U_SORT_ASCII_BUNDLE_ITERATOR)
|
||||
return ures_getNextString(aiter->bund, len, key, err);
|
||||
#else
|
||||
if(U_FAILURE(*err)) return NULL;
|
||||
UResourceBundle *item = aiter->entries[aiter->cursor].item;
|
||||
const UChar* ret = ures_getString(item, len, err);
|
||||
*key = ures_getKey(item);
|
||||
aiter->cursor++;
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// class DateTimePatternGenerator
|
||||
// *****************************************************************************
|
||||
|
@ -108,7 +191,7 @@ static const char* const CLDR_FIELD_APPEND[] = {
|
|||
static const char* const CLDR_FIELD_NAME[] = {
|
||||
"era", "year", "quarter", "month", "week", "*", "weekday", "day", "*", "*", "dayperiod",
|
||||
"hour", "minute", "second", "*", "zone"
|
||||
};
|
||||
};
|
||||
|
||||
static const char* const Resource_Fields[] = {
|
||||
"day", "dayperiod", "era", "hour", "minute", "month", "second", "week",
|
||||
|
@ -472,7 +555,7 @@ DateTimePatternGenerator::addCLDRData(const Locale& locale) {
|
|||
patBundle = ures_getByKeyWithFallback(fBundle, Resource_Fields[i], NULL, &err);
|
||||
fieldBundle = ures_getByKeyWithFallback(patBundle, "dn", NULL, &err);
|
||||
rbPattern = ures_getNextUnicodeString(fieldBundle, &key, &err);
|
||||
ures_close(fieldBundle);
|
||||
ures_close(fieldBundle);
|
||||
ures_close(patBundle);
|
||||
if (rbPattern.length()==0 ) {
|
||||
continue;
|
||||
|
@ -492,13 +575,24 @@ DateTimePatternGenerator::addCLDRData(const Locale& locale) {
|
|||
int32_t len;
|
||||
const UChar *retPattern;
|
||||
key=NULL;
|
||||
#if defined(U_USE_ASCII_BUNDLE_ITERATOR)
|
||||
UResourceBundleAIterator aiter;
|
||||
ures_a_open(&aiter, patBundle, &err);
|
||||
#endif
|
||||
for(i=0; i<numberKeys; ++i) {
|
||||
#if defined(U_USE_ASCII_BUNDLE_ITERATOR)
|
||||
retPattern=ures_a_getNextString(&aiter, &len, &key, &err);
|
||||
#else
|
||||
retPattern=ures_getNextString(patBundle, &len, &key, &err);
|
||||
#endif
|
||||
UnicodeString format=UnicodeString(retPattern);
|
||||
UnicodeString retKey=UnicodeString(key, -1, US_INV);
|
||||
setAvailableFormat(retKey, err);
|
||||
conflictingStatus = addPattern(format, FALSE, conflictingPattern, err);
|
||||
}
|
||||
#if defined(U_USE_ASCII_BUNDLE_ITERATOR)
|
||||
ures_a_close(&aiter);
|
||||
#endif
|
||||
}
|
||||
ures_close(patBundle);
|
||||
ures_close(gregorianBundle);
|
||||
|
@ -520,9 +614,16 @@ DateTimePatternGenerator::addCLDRData(const Locale& locale) {
|
|||
int32_t len;
|
||||
const UChar *retPattern;
|
||||
key=NULL;
|
||||
|
||||
#if defined(U_USE_ASCII_BUNDLE_ITERATOR)
|
||||
UResourceBundleAIterator aiter;
|
||||
ures_a_open(&aiter, patBundle, &err);
|
||||
#endif
|
||||
for(i=0; i<numberKeys; ++i) {
|
||||
#if defined(U_USE_ASCII_BUNDLE_ITERATOR)
|
||||
retPattern=ures_a_getNextString(&aiter, &len, &key, &err);
|
||||
#else
|
||||
retPattern=ures_getNextString(patBundle, &len, &key, &err);
|
||||
#endif
|
||||
UnicodeString format=UnicodeString(retPattern);
|
||||
UnicodeString retKey=UnicodeString(key, -1, US_INV);
|
||||
if ( !isAvailableFormatSet(retKey) ) {
|
||||
|
@ -530,6 +631,9 @@ DateTimePatternGenerator::addCLDRData(const Locale& locale) {
|
|||
conflictingStatus = addPattern(format, FALSE, conflictingPattern, err);
|
||||
}
|
||||
}
|
||||
#if defined(U_USE_ASCII_BUNDLE_ITERATOR)
|
||||
ures_a_close(&aiter);
|
||||
#endif
|
||||
}
|
||||
ures_close(patBundle);
|
||||
ures_close(gregorianBundle);
|
||||
|
|
|
@ -71,8 +71,8 @@ void IntlTestDateTimePatternGeneratorAPI::testAPI(/*char *par*/)
|
|||
UnicodeString("11:58 PM"),
|
||||
UnicodeString("23:58"),
|
||||
UnicodeString("58:59"),
|
||||
UnicodeString("1999-1"), // zh_Hans_CN
|
||||
UnicodeString("1999-01"),
|
||||
UnicodeString("1999-1", -1, US_INV), // zh_Hans_CN
|
||||
UnicodeString("1999-01", -1, US_INV),
|
||||
CharsToUnicodeString("1999\\u5E741\\u670813\\u65E5"),
|
||||
CharsToUnicodeString("1999\\u5E7401\\u670813\\u65E5"),
|
||||
UnicodeString("1-13"),
|
||||
|
@ -240,13 +240,13 @@ void IntlTestDateTimePatternGeneratorAPI::testAPI(/*char *par*/)
|
|||
UnicodeString dateReturned, expectedResult;
|
||||
dateReturned.remove();
|
||||
dateReturned = format->format(sampleDate, dateReturned, status);
|
||||
expectedResult=UnicodeString("14. Okt 8:58");
|
||||
expectedResult=UnicodeString("14. Okt 8:58", -1, US_INV);
|
||||
if ( dateReturned != expectedResult ) {
|
||||
errln("ERROR: Simple test in getBestPattern with Locale::getGermany()).");
|
||||
}
|
||||
// add new pattern
|
||||
status = U_ZERO_ERROR;
|
||||
conflictingStatus = gen->addPattern(UnicodeString("d'. von' MMMM"), true, conflictingPattern, status);
|
||||
conflictingStatus = gen->addPattern(UnicodeString("d'. von' MMMM", -1, US_INV), true, conflictingPattern, status);
|
||||
if (U_FAILURE(status)) {
|
||||
errln("ERROR: Could not addPattern - d\'. von\' MMMM");
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ void IntlTestDateTimePatternGeneratorAPI::testAPI(/*char *par*/)
|
|||
format->applyPattern(gen->getBestPattern(UnicodeString("MMMMddHmm"), status));
|
||||
dateReturned.remove();
|
||||
dateReturned = format->format(sampleDate, dateReturned, status);
|
||||
expectedResult=UnicodeString("14. von Oktober 8:58");
|
||||
expectedResult=UnicodeString("14. von Oktober 8:58", -1, US_INV);
|
||||
if ( dateReturned != expectedResult ) {
|
||||
errln("ERROR: Simple test addPattern failed!: d\'. von\' MMMM ");
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ void IntlTestDateTimePatternGeneratorAPI::testAPI(/*char *par*/)
|
|||
}
|
||||
{ // Trac# 6104
|
||||
Locale loc("zh");
|
||||
UnicodeString expR = UnicodeString("1999-01");
|
||||
UnicodeString expR = UnicodeString("1999-01", -1, US_INV);
|
||||
UDate testDate1= LocaleTest::date(99, 0, 13, 23, 58, 59);
|
||||
DateTimePatternGenerator *patGen=DateTimePatternGenerator::createInstance(loc, status);
|
||||
if(U_FAILURE(status)) {
|
||||
|
|
|
@ -448,11 +448,11 @@ PluralFormatTest::pluralFormatLocaleTest(/*char *par*/)
|
|||
}
|
||||
else {
|
||||
status = U_ZERO_ERROR;
|
||||
UnicodeString plResult = plFmt.format(0, status); // retrun ONE
|
||||
UnicodeString plResult = plFmt.format(0.0, status); // retrun ONE
|
||||
plResult = plFmt.format(0.5, status); // retrun ONE
|
||||
plResult = plFmt.format(1, status); // retrun ONE
|
||||
plResult = plFmt.format(1.0, status); // retrun ONE
|
||||
plResult = plFmt.format(1.9, status); // retrun ONE
|
||||
plResult = plFmt.format(2, status); // retrun OTHER
|
||||
plResult = plFmt.format(2.0, status); // retrun OTHER
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1996,6 +1996,8 @@ void RBBITest::runUnicodeTestData(const char *fileName, RuleBasedBreakIterator *
|
|||
}
|
||||
strcpy(testFileName, testDataDirectory);
|
||||
strcat(testFileName, fileName);
|
||||
|
||||
logln("Opening data file %s\n", fileName);
|
||||
|
||||
int len;
|
||||
UChar *testFile = ReadAndConvertFile(testFileName, len, "UTF-8", status);
|
||||
|
|
|
@ -874,7 +874,7 @@ void RegexTest::API_Match() {
|
|||
//
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UnicodeString testString(1000000, 0x41, 1000000); // Length 1,000,000, filled with 'A'
|
||||
UnicodeString testString(600000, 0x41, 600000); // Length 600,000, filled with 'A'
|
||||
|
||||
// Adding the capturing parentheses to the pattern "(A)+A$" inhibits optimizations
|
||||
// of the '+', and makes the stack frames larger.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# GraphemeBreakTest-5.1.0.txt
|
||||
# GraphemeBreakTest-5.1.0.txt
|
||||
# Date: 2008-03-11, 02:19:22 GMT [MD]
|
||||
#
|
||||
# Unicode Character Database
|
||||
|
|
2
icu4c/source/test/testdata/LineBreakTest.txt
vendored
2
icu4c/source/test/testdata/LineBreakTest.txt
vendored
|
@ -1,4 +1,4 @@
|
|||
# LineBreakTest-5.1.0.txt
|
||||
# LineBreakTest-5.1.0.txt
|
||||
# Date: 2008-03-11, 02:19:24 GMT [MD]
|
||||
#
|
||||
# Unicode Character Database
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# SentenceBreakTest-5.1.0.txt
|
||||
# SentenceBreakTest-5.1.0.txt
|
||||
# Date: 2008-03-11, 02:19:26 GMT [MD]
|
||||
#
|
||||
# Unicode Character Database
|
||||
|
|
2
icu4c/source/test/testdata/WordBreakTest.txt
vendored
2
icu4c/source/test/testdata/WordBreakTest.txt
vendored
|
@ -1,4 +1,4 @@
|
|||
# WordBreakTest-5.1.0.txt
|
||||
# WordBreakTest-5.1.0.txt
|
||||
# Date: 2008-03-11, 02:19:28 GMT [MD]
|
||||
#
|
||||
# Unicode Character Database
|
||||
|
|
2
icu4c/source/test/testdata/rbbitst.txt
vendored
2
icu4c/source/test/testdata/rbbitst.txt
vendored
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2001-2008 International Business Machines
|
||||
# Copyright (c) 2001-2008 International Business Machines
|
||||
# Corporation and others. All Rights Reserved.
|
||||
#
|
||||
# RBBI Test Data
|
||||
|
|
Loading…
Add table
Reference in a new issue