mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-21 12:40:02 +00:00
X-SVN-Rev: 30355
This commit is contained in:
parent
3284177c54
commit
3e55b1ce7a
9 changed files with 73 additions and 81 deletions
|
@ -876,7 +876,7 @@ static UBool compareBinaryFiles(const char* defaultTZFileName, const char* TZFil
|
|||
if (tzInfo->defaultTZBuffer == NULL) {
|
||||
rewind(tzInfo->defaultTZFilePtr);
|
||||
tzInfo->defaultTZBuffer = (char*)uprv_malloc(sizeof(char) * tzInfo->defaultTZFileSize);
|
||||
fread(tzInfo->defaultTZBuffer, 1, tzInfo->defaultTZFileSize, tzInfo->defaultTZFilePtr);
|
||||
sizeFileRead = fread(tzInfo->defaultTZBuffer, 1, tzInfo->defaultTZFileSize, tzInfo->defaultTZFilePtr);
|
||||
}
|
||||
rewind(file);
|
||||
while(sizeFileLeft > 0) {
|
||||
|
|
|
@ -1534,19 +1534,8 @@ BreakIterator * RuleBasedBreakIterator::createBufferClone(void *stackBuffer,
|
|||
|
||||
//
|
||||
// Clone the source BI into the caller-supplied buffer.
|
||||
// TODO: using an overloaded operator new to directly initialize the
|
||||
// copy in the user's buffer would be better, but it doesn't seem
|
||||
// to get along with namespaces. Investigate why.
|
||||
//
|
||||
// The memcpy is only safe with an empty (default constructed)
|
||||
// break iterator. Use on others can screw up reference counts
|
||||
// to data. memcpy-ing objects is not really a good idea...
|
||||
//
|
||||
RuleBasedBreakIterator localIter; // Empty break iterator, source for memcpy
|
||||
RuleBasedBreakIterator *clone = (RuleBasedBreakIterator *)buf;
|
||||
uprv_memcpy(clone, &localIter, sizeof(RuleBasedBreakIterator)); // init C++ gorp, BreakIterator base class part
|
||||
clone->init(); // Init RuleBasedBreakIterator part, (user default constructor)
|
||||
*clone = *this; // clone = the real BI we want.
|
||||
RuleBasedBreakIterator *clone = new(buf) RuleBasedBreakIterator(*this);
|
||||
clone->fBufferClone = TRUE; // Flag to prevent deleting storage on close (From C code)
|
||||
|
||||
return clone;
|
||||
|
|
|
@ -234,10 +234,14 @@ void StringList::add(const UnicodeString *string, UErrorCode &status)
|
|||
|
||||
if (listSize >= listMax) {
|
||||
int32_t newMax = listMax + STRING_LIST_BUFFER_SIZE;
|
||||
|
||||
UnicodeString *newStrings = new UnicodeString[newMax];
|
||||
|
||||
uprv_memcpy(newStrings, strings, listSize * sizeof(UnicodeString));
|
||||
if (newStrings == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
for (int32_t i=0; i<listSize; ++i) {
|
||||
newStrings[i] = strings[i];
|
||||
}
|
||||
|
||||
#ifdef INSTRUMENT_STRING_LIST
|
||||
int32_t _h = listSize / STRING_LIST_BUFFER_SIZE;
|
||||
|
|
|
@ -419,10 +419,10 @@ int32_t PluralFormat::findSubMessage(const MessagePattern& pattern, int32_t part
|
|||
// We have already seen an "other" sub-message.
|
||||
// Do not match "other" again.
|
||||
haveKeywordMatch=TRUE;
|
||||
continue;
|
||||
// Skip keyword matching but do getLimitPartIndex().
|
||||
}
|
||||
}
|
||||
if(pattern.partSubstringMatches(*part, keyword)) {
|
||||
if(!haveKeywordMatch && pattern.partSubstringMatches(*part, keyword)) {
|
||||
// keyword matches
|
||||
msgStart=partIndex;
|
||||
// Do not match this keyword again.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2004-2010, International Business Machines
|
||||
* Copyright (C) 2004-2011, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
* file name: ucol_sit.cpp
|
||||
|
@ -239,7 +239,7 @@ _processVariableTop(CollatorSpec *spec, uint32_t value1, const char* string, UEr
|
|||
spec->variableTopString[i++] = readHexCodeUnit(&string, status);
|
||||
}
|
||||
spec->variableTopStringLen = i;
|
||||
if(i == locElementCapacity && (*string != 0 || *string != '_')) {
|
||||
if(i == locElementCapacity && *string != 0 && *string != '_') {
|
||||
*status = U_BUFFER_OVERFLOW_ERROR;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -165,7 +165,7 @@ case $platform in
|
|||
THE_COMP="Sun's CC"
|
||||
CC=`which cc`; export CC
|
||||
CXX=`which CC`; export CXX
|
||||
LDFLAGS="-lCrun";export LDFLAGS
|
||||
LDFLAGS="${LDFLAGS} -lCrun";export LDFLAGS
|
||||
RELEASE_CFLAGS=-xO3
|
||||
RELEASE_CXXFLAGS=-O3
|
||||
;;
|
||||
|
|
|
@ -895,7 +895,7 @@ roundtripBOCU1(UConverter *bocu1, int32_t number, const UChar *text, int32_t len
|
|||
bocu1ICULength=ucnv_fromUChars(bocu1, bocu1ICU, DEFAULT_BUFFER_SIZE, text, length, &errorCode);
|
||||
if(U_FAILURE(errorCode)) {
|
||||
log_err("ucnv_fromUChars(BOCU-1, text(%d)[%d]) failed: %s\n", number, length, u_errorName(errorCode));
|
||||
goto cleanup;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if(bocu1RefLength!=bocu1ICULength || 0!=uprv_memcmp(bocu1Ref, bocu1ICU, bocu1RefLength)) {
|
||||
|
|
|
@ -955,76 +955,75 @@ inline UBool checkInScripts(UScriptCode script[], int scriptcount,
|
|||
* Add by Richard
|
||||
*/
|
||||
int getScriptElementsFromExemplars(ScriptElement scriptelem[], const char* locale) {
|
||||
UErrorCode error = U_ZERO_ERROR;
|
||||
UChar32 codepoint = 0;
|
||||
UErrorCode error = U_ZERO_ERROR;
|
||||
UChar32 codepoint = 0;
|
||||
|
||||
UResourceBundle* ures = ures_open(NULL, locale, &error);
|
||||
if (U_FAILURE(error)) {
|
||||
fprintf(stdout, "Can not find resource bundle for locale: %s\n", locale);
|
||||
UResourceBundle* ures = ures_open(NULL, locale, &error);
|
||||
if (U_FAILURE(error)) {
|
||||
fprintf(stdout, "Can not find resource bundle for locale: %s\n", locale);
|
||||
return -1;
|
||||
}
|
||||
int32_t length;
|
||||
const UChar* exemplarChars = ures_getStringByKey(ures, "ExemplarCharacters", &length, &error);
|
||||
|
||||
if (U_FAILURE(error)) {
|
||||
fprintf(stdout, "Can not find ExemplarCharacters in resource bundle\n");
|
||||
}
|
||||
int32_t length;
|
||||
const UChar* exemplarChars = ures_getStringByKey(ures, "ExemplarCharacters", &length, &error);
|
||||
|
||||
if (U_FAILURE(error)) {
|
||||
fprintf(stdout, "Can not find ExemplarCharacters in resource bundle\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
UChar* upperChars = new UChar[length*2];
|
||||
if (upperChars == 0) {
|
||||
fprintf(stdout, "Memory error\n");
|
||||
UChar* upperChars = new UChar[length * 2];
|
||||
if (upperChars == 0) {
|
||||
fprintf(stdout, "Memory error\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t destLength = u_strToUpper(upperChars, length*2, exemplarChars, -1, locale, &error);
|
||||
if (U_FAILURE(error)) {
|
||||
fprintf(stdout, "Error when u_strToUpper() \n");
|
||||
int32_t destLength = u_strToUpper(upperChars, length * 2, exemplarChars, -1, locale, &error);
|
||||
if (U_FAILURE(error)) {
|
||||
fprintf(stdout, "Error when u_strToUpper() \n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
UChar* pattern = new UChar[length + destLength + 10];
|
||||
UChar left[2] = {0x005b, 0x0};
|
||||
UChar right[2] = {0x005d, 0x0};
|
||||
pattern = u_strcpy(pattern, left);
|
||||
pattern = u_strcat(pattern, exemplarChars);
|
||||
pattern = u_strcat(pattern, upperChars);
|
||||
pattern = u_strcat(pattern, right);
|
||||
UChar* pattern = new UChar[length + destLength + 10];
|
||||
UChar left[2] = {0x005b, 0x0};
|
||||
UChar right[2] = {0x005d, 0x0};
|
||||
pattern = u_strcpy(pattern, left);
|
||||
pattern = u_strcat(pattern, exemplarChars);
|
||||
pattern = u_strcat(pattern, upperChars);
|
||||
pattern = u_strcat(pattern, right);
|
||||
|
||||
UnicodeSet * uniset = new UnicodeSet(UnicodeString(pattern), error);
|
||||
if (U_FAILURE(error)) {
|
||||
fprintf(stdout, "Can not open USet \n");
|
||||
UnicodeSet * uniset = new UnicodeSet(UnicodeString(pattern), error);
|
||||
if (U_FAILURE(error)) {
|
||||
fprintf(stdout, "Can not open USet \n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
UnicodeSetIterator* usetiter = new UnicodeSetIterator(*uniset);
|
||||
}
|
||||
|
||||
int32_t count = 0;
|
||||
UnicodeSetIterator* usetiter = new UnicodeSetIterator(*uniset);
|
||||
|
||||
while (usetiter -> next()) {
|
||||
if (usetiter -> isString()) {
|
||||
UnicodeString strItem = usetiter -> getString();
|
||||
int32_t count = 0;
|
||||
|
||||
scriptelem[count].count = 0;
|
||||
for (int i = 0; i < strItem.length(); i++) {
|
||||
codepoint = strItem.char32At(i);
|
||||
UTF16_APPEND_CHAR_UNSAFE(scriptelem[count].ch,
|
||||
scriptelem[count].count, codepoint);
|
||||
scriptelem[count].tailored = FALSE;
|
||||
}
|
||||
} else {
|
||||
codepoint = usetiter -> getCodepoint();
|
||||
scriptelem[count].count = 0;
|
||||
UTF16_APPEND_CHAR_UNSAFE(scriptelem[count].ch,
|
||||
scriptelem[count].count, codepoint);
|
||||
scriptelem[count].tailored = FALSE;
|
||||
}
|
||||
while (usetiter -> next()) {
|
||||
if (usetiter -> isString()) {
|
||||
UnicodeString strItem = usetiter -> getString();
|
||||
|
||||
count++;
|
||||
}
|
||||
scriptelem[count].count = 0;
|
||||
for (int i = 0; i < strItem.length(); i++) {
|
||||
codepoint = strItem.char32At(i);
|
||||
UTF16_APPEND_CHAR_UNSAFE(scriptelem[count].ch, scriptelem[count].count, codepoint);
|
||||
scriptelem[count].tailored = FALSE;
|
||||
}
|
||||
} else {
|
||||
codepoint = usetiter -> getCodepoint();
|
||||
scriptelem[count].count = 0;
|
||||
UTF16_APPEND_CHAR_UNSAFE(scriptelem[count].ch, scriptelem[count].count, codepoint);
|
||||
scriptelem[count].tailored = FALSE;
|
||||
}
|
||||
delete []pattern;
|
||||
|
||||
return count;
|
||||
count++;
|
||||
}
|
||||
delete []pattern;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1513,11 +1512,11 @@ void serializeScripts() {
|
|||
break;
|
||||
}
|
||||
outputHTMLHeader(locale, scriptcode, scriptcount);
|
||||
fprintf(stdout, "%s\n", locale);
|
||||
|
||||
fprintf(stdout, "%s\n", locale);
|
||||
|
||||
if(options[12].doesOccur) {
|
||||
// use whole scripts
|
||||
serializeScripts(scriptcode, scriptcount);
|
||||
serializeScripts(scriptcode, scriptcount);
|
||||
} else {
|
||||
// use exemplar chars
|
||||
serializeScripts(scriptcode, scriptcount, locale);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2008-2010, International Business Machines
|
||||
* Copyright (C) 2008-2011, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -18,7 +18,7 @@
|
|||
#include "putilimp.h"
|
||||
#include "pkg_gencmn.h"
|
||||
|
||||
#define STRING_STORE_SIZE 100000
|
||||
#define STRING_STORE_SIZE 200000
|
||||
|
||||
#define COMMON_DATA_NAME U_ICUDATA_NAME
|
||||
#define DATA_TYPE "dat"
|
||||
|
|
Loading…
Add table
Reference in a new issue