ICU-6176 Fix some Coverity warnings
X-SVN-Rev: 23414
This commit is contained in:
parent
029ac2db29
commit
928d6152bc
@ -633,15 +633,14 @@ RangeDescriptor::~RangeDescriptor() {
|
||||
void RangeDescriptor::split(UChar32 where, UErrorCode &status) {
|
||||
U_ASSERT(where>fStartChar && where<=fEndChar);
|
||||
RangeDescriptor *nr = new RangeDescriptor(*this, status);
|
||||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
}
|
||||
/* test for NULL */
|
||||
if(nr == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
if (U_FAILURE(status)) {
|
||||
delete nr;
|
||||
return;
|
||||
}
|
||||
// RangeDescriptor copy constructor copies all fields.
|
||||
// Only need to update those that are different after the split.
|
||||
nr->fStartChar = where;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2001-2007, International Business Machines Corporation. *
|
||||
* Copyright (C) 2001-2008, International Business Machines Corporation. *
|
||||
* All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -450,6 +450,9 @@ ICUService::getKey(ICUServiceKey& key, UnicodeString* actualReturn, const ICUSer
|
||||
|
||||
if (serviceCache == NULL) {
|
||||
ncthis->serviceCache = new Hashtable(status);
|
||||
if (ncthis->serviceCache == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (U_FAILURE(status)) {
|
||||
delete serviceCache;
|
||||
return NULL;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2007, International Business Machines Corporation *
|
||||
* Copyright (C) 2006-2008, International Business Machines Corporation *
|
||||
* and others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -806,6 +806,7 @@ compactOneNode(const TernaryNode *node, UBool parentEndsWord, UStack &nodes, UEr
|
||||
new BuildCompactTrieHorizontalNode(parentEndsWord, nodes, status);
|
||||
if (hResult == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
if (U_SUCCESS(status)) {
|
||||
walkHorizontal(node, hResult, nodes, status);
|
||||
|
@ -2856,7 +2856,7 @@ getTrail:
|
||||
if(cs0 > 0) {
|
||||
uint32_t value;
|
||||
int32_t len2;
|
||||
if(cs0 > CNS_11643_0) {
|
||||
if(cs0 >= CNS_11643_0) {
|
||||
len2 = MBCS_FROM_UCHAR32_ISO2022(
|
||||
converterData->myConverterArray[CNS_11643],
|
||||
sourceChar,
|
||||
@ -3118,7 +3118,7 @@ escape:
|
||||
getTrailByte:
|
||||
trailByte = *mySource++;
|
||||
tempState = (StateEnum)pToU2022State->cs[pToU2022State->g];
|
||||
if(tempState > CNS_11643_0) {
|
||||
if(tempState >= CNS_11643_0) {
|
||||
cnv = myData->myConverterArray[CNS_11643];
|
||||
tempBuf[0] = (char) (0x80+(tempState-CNS_11643_0));
|
||||
tempBuf[1] = (char) (mySourceChar);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 2000-2007, International Business Machines
|
||||
* Copyright (C) 2000-2008, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
* file name: ucnvhz.c
|
||||
@ -145,10 +145,12 @@ UConverter_toUnicode_HZ_OFFSETS_LOGIC(UConverterToUnicodeArgs *args,
|
||||
UConverterDataHZ* myData=(UConverterDataHZ*)(args->converter->extraInfo);
|
||||
tempBuf[0]=0;
|
||||
tempBuf[1]=0;
|
||||
if ((args->converter == NULL) || (args->targetLimit < args->target) || (mySourceLimit < args->source)){
|
||||
|
||||
/* Calling code already handles this situation. */
|
||||
/*if ((args->converter == NULL) || (args->targetLimit < args->target) || (mySourceLimit < args->source)){
|
||||
*err = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
while(mySource< mySourceLimit){
|
||||
|
||||
@ -278,10 +280,11 @@ UConverter_fromUnicode_HZ_OFFSETS_LOGIC (UConverterFromUnicodeArgs * args,
|
||||
int len =0;
|
||||
const char* escSeq=NULL;
|
||||
|
||||
if ((args->converter == NULL) || (args->targetLimit < myTarget) || (args->sourceLimit < args->source)){
|
||||
/* Calling code already handles this situation. */
|
||||
/*if ((args->converter == NULL) || (args->targetLimit < myTarget) || (args->sourceLimit < args->source)){
|
||||
*err = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
if(args->converter->fromUChar32!=0 && myTargetIndex < targetLength) {
|
||||
goto getTrail;
|
||||
}
|
||||
|
@ -697,219 +697,223 @@ static UResourceBundle *init_resb_result(const ResourceData *rdata, Resource r,
|
||||
if(status == NULL || U_FAILURE(*status)) {
|
||||
return resB;
|
||||
}
|
||||
if (parent == NULL) {
|
||||
*status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
if(RES_GET_TYPE(r) == URES_ALIAS) { /* This is an alias, need to exchange with real data */
|
||||
if(noAlias < URES_MAX_ALIAS_LEVEL) {
|
||||
int32_t len = 0;
|
||||
const UChar *alias = res_getAlias(rdata, r, &len);
|
||||
if(len > 0) {
|
||||
/* we have an alias, now let's cut it up */
|
||||
char stackAlias[200];
|
||||
char *chAlias = NULL, *path = NULL, *locale = NULL, *keyPath = NULL;
|
||||
int32_t capacity;
|
||||
if(noAlias < URES_MAX_ALIAS_LEVEL) {
|
||||
int32_t len = 0;
|
||||
const UChar *alias = res_getAlias(rdata, r, &len);
|
||||
if(len > 0) {
|
||||
/* we have an alias, now let's cut it up */
|
||||
char stackAlias[200];
|
||||
char *chAlias = NULL, *path = NULL, *locale = NULL, *keyPath = NULL;
|
||||
int32_t capacity;
|
||||
|
||||
/*
|
||||
* Allocate enough space for both the char * version
|
||||
* of the alias and parent->fResPath.
|
||||
*
|
||||
* We do this so that res_findResource() can modify the path,
|
||||
* which allows us to remove redundant _res_findResource() variants
|
||||
* in uresdata.c.
|
||||
* res_findResource() now NUL-terminates each segment so that table keys
|
||||
* can always be compared with strcmp() instead of strncmp().
|
||||
* Saves code there and simplifies testing and code coverage.
|
||||
*
|
||||
* markus 2003oct17
|
||||
*/
|
||||
++len; /* count the terminating NUL */
|
||||
if(parent != NULL && parent->fResPath != NULL) {
|
||||
capacity = (int32_t)uprv_strlen(parent->fResPath) + 1;
|
||||
} else {
|
||||
capacity = 0;
|
||||
}
|
||||
if(capacity < len) {
|
||||
capacity = len;
|
||||
}
|
||||
if(capacity <= sizeof(stackAlias)) {
|
||||
capacity = sizeof(stackAlias);
|
||||
chAlias = stackAlias;
|
||||
} else {
|
||||
chAlias = (char *)uprv_malloc(capacity);
|
||||
/* test for NULL */
|
||||
if(chAlias == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
u_UCharsToChars(alias, chAlias, len);
|
||||
|
||||
if(*chAlias == RES_PATH_SEPARATOR) {
|
||||
/* there is a path included */
|
||||
locale = uprv_strchr(chAlias+1, RES_PATH_SEPARATOR);
|
||||
if(locale == NULL) {
|
||||
locale = uprv_strchr(chAlias, 0); /* avoid locale == NULL to make code below work */
|
||||
} else {
|
||||
*locale = 0;
|
||||
locale++;
|
||||
}
|
||||
path = chAlias+1;
|
||||
if(uprv_strcmp(path, "LOCALE") == 0) {
|
||||
/* this is an XPath alias, starting with "/LOCALE/" */
|
||||
/* it contains the path to a resource which should be looked up */
|
||||
/* starting in the requested locale */
|
||||
keyPath = locale;
|
||||
locale = parent->fTopLevelData->fName; /* this is the requested locale's name */
|
||||
path = realData->fPath; /* we will be looking in the same package */
|
||||
} else {
|
||||
if(uprv_strcmp(path, "ICUDATA") == 0) { /* want ICU data */
|
||||
path = NULL;
|
||||
}
|
||||
keyPath = uprv_strchr(locale, RES_PATH_SEPARATOR);
|
||||
if(keyPath) {
|
||||
*keyPath = 0;
|
||||
keyPath++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* no path, start with a locale */
|
||||
locale = chAlias;
|
||||
keyPath = uprv_strchr(locale, RES_PATH_SEPARATOR);
|
||||
if(keyPath) {
|
||||
*keyPath = 0;
|
||||
keyPath++;
|
||||
}
|
||||
path = realData->fPath;
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
/* got almost everything, let's try to open */
|
||||
/* first, open the bundle with real data */
|
||||
UResourceBundle *result = resB;
|
||||
const char* temp = NULL;
|
||||
UErrorCode intStatus = U_ZERO_ERROR;
|
||||
UResourceBundle *mainRes = ures_openDirect(path, locale, &intStatus);
|
||||
if(U_SUCCESS(intStatus)) {
|
||||
if(keyPath == NULL) {
|
||||
/* no key path. This means that we are going to
|
||||
* to use the corresponding resource from
|
||||
* another bundle
|
||||
*/
|
||||
/* first, we are going to get a corresponding parent
|
||||
* resource to the one we are searching.
|
||||
*/
|
||||
char *aKey = parent->fResPath;
|
||||
if(aKey) {
|
||||
uprv_strcpy(chAlias, aKey); /* allocated large enough above */
|
||||
aKey = chAlias;
|
||||
r = res_findResource(&(mainRes->fResData), mainRes->fRes, &aKey, &temp);
|
||||
/*
|
||||
* Allocate enough space for both the char * version
|
||||
* of the alias and parent->fResPath.
|
||||
*
|
||||
* We do this so that res_findResource() can modify the path,
|
||||
* which allows us to remove redundant _res_findResource() variants
|
||||
* in uresdata.c.
|
||||
* res_findResource() now NUL-terminates each segment so that table keys
|
||||
* can always be compared with strcmp() instead of strncmp().
|
||||
* Saves code there and simplifies testing and code coverage.
|
||||
*
|
||||
* markus 2003oct17
|
||||
*/
|
||||
++len; /* count the terminating NUL */
|
||||
if(parent->fResPath != NULL) {
|
||||
capacity = (int32_t)uprv_strlen(parent->fResPath) + 1;
|
||||
} else {
|
||||
r = mainRes->fRes;
|
||||
capacity = 0;
|
||||
}
|
||||
if(key) {
|
||||
/* we need to make keyPath from parent's fResPath and
|
||||
* current key, if there is a key associated
|
||||
*/
|
||||
len = (int32_t)(uprv_strlen(key) + 1);
|
||||
if(len > capacity) {
|
||||
if(capacity < len) {
|
||||
capacity = len;
|
||||
if(chAlias == stackAlias) {
|
||||
chAlias = (char *)uprv_malloc(capacity);
|
||||
} else {
|
||||
chAlias = (char *)uprv_realloc(chAlias, capacity);
|
||||
}
|
||||
if(chAlias == NULL) {
|
||||
ures_close(mainRes);
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
uprv_memcpy(chAlias, key, len);
|
||||
aKey = chAlias;
|
||||
r = res_findResource(&(mainRes->fResData), r, &aKey, &temp);
|
||||
} else if(index != -1) {
|
||||
/* if there is no key, but there is an index, try to get by the index */
|
||||
/* here we have either a table or an array, so get the element */
|
||||
if(RES_GET_TYPE(r) == URES_TABLE || RES_GET_TYPE(r) == URES_TABLE32) {
|
||||
r = res_getTableItemByIndex(&(mainRes->fResData), r, index, (const char **)&aKey);
|
||||
} else { /* array */
|
||||
r = res_getArrayItem(&(mainRes->fResData), r, index);
|
||||
}
|
||||
}
|
||||
if(r != RES_BOGUS) {
|
||||
result = init_resb_result(&(mainRes->fResData), r, temp, -1, mainRes->fData, mainRes, noAlias+1, resB, status);
|
||||
if(capacity <= sizeof(stackAlias)) {
|
||||
capacity = sizeof(stackAlias);
|
||||
chAlias = stackAlias;
|
||||
} else {
|
||||
*status = U_MISSING_RESOURCE_ERROR;
|
||||
result = resB;
|
||||
}
|
||||
} else {
|
||||
/* this one is a bit trickier.
|
||||
* we start finding keys, but after we resolve one alias, the path might continue.
|
||||
* Consider:
|
||||
* aliastest:alias { "testtypes/anotheralias/Sequence" }
|
||||
* anotheralias:alias { "/ICUDATA/sh/CollationElements" }
|
||||
* aliastest resource should finally have the sequence, not collation elements.
|
||||
*/
|
||||
UResourceDataEntry *dataEntry = mainRes->fData;
|
||||
char stackPath[URES_MAX_BUFFER_SIZE];
|
||||
char *pathBuf = stackPath, *myPath = pathBuf;
|
||||
if(uprv_strlen(keyPath) > URES_MAX_BUFFER_SIZE) {
|
||||
pathBuf = (char *)uprv_malloc((uprv_strlen(keyPath)+1)*sizeof(char));
|
||||
if(pathBuf == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
uprv_strcpy(pathBuf, keyPath);
|
||||
result = mainRes;
|
||||
/* now we have fallback following here */
|
||||
do {
|
||||
r = dataEntry->fData.rootRes;
|
||||
/* this loop handles 'found' resources over several levels */
|
||||
while(*myPath && U_SUCCESS(*status)) {
|
||||
r = res_findResource(&(dataEntry->fData), r, &myPath, &temp);
|
||||
if(r != RES_BOGUS) { /* found a resource, but it might be an indirection */
|
||||
resB = init_resb_result(&(dataEntry->fData), r, temp, -1, dataEntry, result, noAlias+1, resB, status);
|
||||
result = resB;
|
||||
if(result) {
|
||||
r = result->fRes; /* switch to a new resource, possibly a new tree */
|
||||
dataEntry = result->fData;
|
||||
}
|
||||
} else { /* no resource found, we don't really want to look anymore on this level */
|
||||
break;
|
||||
chAlias = (char *)uprv_malloc(capacity);
|
||||
/* test for NULL */
|
||||
if(chAlias == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
dataEntry = dataEntry->fParent;
|
||||
uprv_strcpy(pathBuf, keyPath);
|
||||
myPath = pathBuf;
|
||||
} while(r == RES_BOGUS && dataEntry != NULL);
|
||||
if(r == RES_BOGUS) {
|
||||
*status = U_MISSING_RESOURCE_ERROR;
|
||||
result = resB;
|
||||
}
|
||||
if(pathBuf != stackPath) {
|
||||
uprv_free(pathBuf);
|
||||
u_UCharsToChars(alias, chAlias, len);
|
||||
|
||||
if(*chAlias == RES_PATH_SEPARATOR) {
|
||||
/* there is a path included */
|
||||
locale = uprv_strchr(chAlias+1, RES_PATH_SEPARATOR);
|
||||
if(locale == NULL) {
|
||||
locale = uprv_strchr(chAlias, 0); /* avoid locale == NULL to make code below work */
|
||||
} else {
|
||||
*locale = 0;
|
||||
locale++;
|
||||
}
|
||||
path = chAlias+1;
|
||||
if(uprv_strcmp(path, "LOCALE") == 0) {
|
||||
/* this is an XPath alias, starting with "/LOCALE/" */
|
||||
/* it contains the path to a resource which should be looked up */
|
||||
/* starting in the requested locale */
|
||||
keyPath = locale;
|
||||
locale = parent->fTopLevelData->fName; /* this is the requested locale's name */
|
||||
path = realData->fPath; /* we will be looking in the same package */
|
||||
} else {
|
||||
if(uprv_strcmp(path, "ICUDATA") == 0) { /* want ICU data */
|
||||
path = NULL;
|
||||
}
|
||||
keyPath = uprv_strchr(locale, RES_PATH_SEPARATOR);
|
||||
if(keyPath) {
|
||||
*keyPath = 0;
|
||||
keyPath++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* no path, start with a locale */
|
||||
locale = chAlias;
|
||||
keyPath = uprv_strchr(locale, RES_PATH_SEPARATOR);
|
||||
if(keyPath) {
|
||||
*keyPath = 0;
|
||||
keyPath++;
|
||||
}
|
||||
path = realData->fPath;
|
||||
}
|
||||
}
|
||||
} else { /* we failed to open the resource we're aliasing to */
|
||||
*status = intStatus;
|
||||
|
||||
|
||||
{
|
||||
/* got almost everything, let's try to open */
|
||||
/* first, open the bundle with real data */
|
||||
UResourceBundle *result = resB;
|
||||
const char* temp = NULL;
|
||||
UErrorCode intStatus = U_ZERO_ERROR;
|
||||
UResourceBundle *mainRes = ures_openDirect(path, locale, &intStatus);
|
||||
if(U_SUCCESS(intStatus)) {
|
||||
if(keyPath == NULL) {
|
||||
/* no key path. This means that we are going to
|
||||
* to use the corresponding resource from
|
||||
* another bundle
|
||||
*/
|
||||
/* first, we are going to get a corresponding parent
|
||||
* resource to the one we are searching.
|
||||
*/
|
||||
char *aKey = parent->fResPath;
|
||||
if(aKey) {
|
||||
uprv_strcpy(chAlias, aKey); /* allocated large enough above */
|
||||
aKey = chAlias;
|
||||
r = res_findResource(&(mainRes->fResData), mainRes->fRes, &aKey, &temp);
|
||||
} else {
|
||||
r = mainRes->fRes;
|
||||
}
|
||||
if(key) {
|
||||
/* we need to make keyPath from parent's fResPath and
|
||||
* current key, if there is a key associated
|
||||
*/
|
||||
len = (int32_t)(uprv_strlen(key) + 1);
|
||||
if(len > capacity) {
|
||||
capacity = len;
|
||||
if(chAlias == stackAlias) {
|
||||
chAlias = (char *)uprv_malloc(capacity);
|
||||
} else {
|
||||
chAlias = (char *)uprv_realloc(chAlias, capacity);
|
||||
}
|
||||
if(chAlias == NULL) {
|
||||
ures_close(mainRes);
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
uprv_memcpy(chAlias, key, len);
|
||||
aKey = chAlias;
|
||||
r = res_findResource(&(mainRes->fResData), r, &aKey, &temp);
|
||||
} else if(index != -1) {
|
||||
/* if there is no key, but there is an index, try to get by the index */
|
||||
/* here we have either a table or an array, so get the element */
|
||||
if(RES_GET_TYPE(r) == URES_TABLE || RES_GET_TYPE(r) == URES_TABLE32) {
|
||||
r = res_getTableItemByIndex(&(mainRes->fResData), r, index, (const char **)&aKey);
|
||||
} else { /* array */
|
||||
r = res_getArrayItem(&(mainRes->fResData), r, index);
|
||||
}
|
||||
}
|
||||
if(r != RES_BOGUS) {
|
||||
result = init_resb_result(&(mainRes->fResData), r, temp, -1, mainRes->fData, mainRes, noAlias+1, resB, status);
|
||||
} else {
|
||||
*status = U_MISSING_RESOURCE_ERROR;
|
||||
result = resB;
|
||||
}
|
||||
} else {
|
||||
/* this one is a bit trickier.
|
||||
* we start finding keys, but after we resolve one alias, the path might continue.
|
||||
* Consider:
|
||||
* aliastest:alias { "testtypes/anotheralias/Sequence" }
|
||||
* anotheralias:alias { "/ICUDATA/sh/CollationElements" }
|
||||
* aliastest resource should finally have the sequence, not collation elements.
|
||||
*/
|
||||
UResourceDataEntry *dataEntry = mainRes->fData;
|
||||
char stackPath[URES_MAX_BUFFER_SIZE];
|
||||
char *pathBuf = stackPath, *myPath = pathBuf;
|
||||
if(uprv_strlen(keyPath) > URES_MAX_BUFFER_SIZE) {
|
||||
pathBuf = (char *)uprv_malloc((uprv_strlen(keyPath)+1)*sizeof(char));
|
||||
if(pathBuf == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
uprv_strcpy(pathBuf, keyPath);
|
||||
result = mainRes;
|
||||
/* now we have fallback following here */
|
||||
do {
|
||||
r = dataEntry->fData.rootRes;
|
||||
/* this loop handles 'found' resources over several levels */
|
||||
while(*myPath && U_SUCCESS(*status)) {
|
||||
r = res_findResource(&(dataEntry->fData), r, &myPath, &temp);
|
||||
if(r != RES_BOGUS) { /* found a resource, but it might be an indirection */
|
||||
resB = init_resb_result(&(dataEntry->fData), r, temp, -1, dataEntry, result, noAlias+1, resB, status);
|
||||
result = resB;
|
||||
if(result) {
|
||||
r = result->fRes; /* switch to a new resource, possibly a new tree */
|
||||
dataEntry = result->fData;
|
||||
}
|
||||
} else { /* no resource found, we don't really want to look anymore on this level */
|
||||
break;
|
||||
}
|
||||
}
|
||||
dataEntry = dataEntry->fParent;
|
||||
uprv_strcpy(pathBuf, keyPath);
|
||||
myPath = pathBuf;
|
||||
} while(r == RES_BOGUS && dataEntry != NULL);
|
||||
if(r == RES_BOGUS) {
|
||||
*status = U_MISSING_RESOURCE_ERROR;
|
||||
result = resB;
|
||||
}
|
||||
if(pathBuf != stackPath) {
|
||||
uprv_free(pathBuf);
|
||||
}
|
||||
}
|
||||
} else { /* we failed to open the resource we're aliasing to */
|
||||
*status = intStatus;
|
||||
}
|
||||
if(chAlias != stackAlias) {
|
||||
uprv_free(chAlias);
|
||||
}
|
||||
if(mainRes != result) {
|
||||
ures_close(mainRes);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
} else {
|
||||
/* bad alias, should be an error */
|
||||
*status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return resB;
|
||||
}
|
||||
if(chAlias != stackAlias) {
|
||||
uprv_free(chAlias);
|
||||
}
|
||||
if(mainRes != result) {
|
||||
ures_close(mainRes);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
} else {
|
||||
/* bad alias, should be an error */
|
||||
*status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return resB;
|
||||
*status = U_TOO_MANY_ALIASES_ERROR;
|
||||
return resB;
|
||||
}
|
||||
} else {
|
||||
*status = U_TOO_MANY_ALIASES_ERROR;
|
||||
return resB;
|
||||
}
|
||||
}
|
||||
if(resB == NULL) {
|
||||
resB = (UResourceBundle *)uprv_malloc(sizeof(UResourceBundle));
|
||||
@ -929,14 +933,14 @@ static UResourceBundle *init_resb_result(const ResourceData *rdata, Resource r,
|
||||
uprv_free(resB->fVersion);
|
||||
}
|
||||
/*
|
||||
weiv: if stack object was passed in, it doesn't really need to be reinited,
|
||||
since the purpose of initing is to remove stack junk. However, at this point
|
||||
we would not do anything to an allocated object, so stack object should be
|
||||
treated the same
|
||||
weiv: if stack object was passed in, it doesn't really need to be reinited,
|
||||
since the purpose of initing is to remove stack junk. However, at this point
|
||||
we would not do anything to an allocated object, so stack object should be
|
||||
treated the same
|
||||
*/
|
||||
/*
|
||||
if(ures_isStackObject(resB) != FALSE) {
|
||||
ures_initStackObject(resB);
|
||||
ures_initStackObject(resB);
|
||||
}
|
||||
*/
|
||||
if(parent != resB) {
|
||||
@ -957,14 +961,14 @@ static UResourceBundle *init_resb_result(const ResourceData *rdata, Resource r,
|
||||
if(key != NULL) {
|
||||
ures_appendResPath(resB, key, (int32_t)uprv_strlen(key));
|
||||
if(resB->fResPath[resB->fResPathLen-1] != RES_PATH_SEPARATOR) {
|
||||
ures_appendResPath(resB, RES_PATH_SEPARATOR_S, 1);
|
||||
ures_appendResPath(resB, RES_PATH_SEPARATOR_S, 1);
|
||||
}
|
||||
} else if(index >= 0) {
|
||||
char buf[256];
|
||||
int32_t len = T_CString_integerToString(buf, index, 10);
|
||||
ures_appendResPath(resB, buf, len);
|
||||
if(resB->fResPath[resB->fResPathLen-1] != RES_PATH_SEPARATOR) {
|
||||
ures_appendResPath(resB, RES_PATH_SEPARATOR_S, 1);
|
||||
ures_appendResPath(resB, RES_PATH_SEPARATOR_S, 1);
|
||||
}
|
||||
}
|
||||
/* Make sure that Purify doesn't complain about uninitialized memory copies. */
|
||||
|
@ -572,6 +572,7 @@ utext_setup(UText *ut, int32_t extraSpace, UErrorCode *status) {
|
||||
ut = (UText *)uprv_malloc(spaceRequired);
|
||||
if (ut == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
} else {
|
||||
*ut = emptyText;
|
||||
ut->flags |= UTEXT_HEAP_ALLOCATED;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2006, International Business Machines
|
||||
* Copyright (C) 1999-2008, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
******************************************************************************/
|
||||
@ -259,7 +259,7 @@ static int printConverters(const char *pname, const char *lookfor,
|
||||
}
|
||||
if (U_FAILURE(err)) {
|
||||
u_wmsg(stderr, "cantGetTag", u_wmsg_errorName(err));
|
||||
return -1;
|
||||
goto error_cleanup;
|
||||
}
|
||||
}
|
||||
if (canon) {
|
||||
@ -291,7 +291,7 @@ static int printConverters(const char *pname, const char *lookfor,
|
||||
putchar('\t');
|
||||
u_wmsg(stderr, "cantGetAliases", str.getTerminatedBuffer(),
|
||||
u_wmsg_errorName(err));
|
||||
return -1;
|
||||
goto error_cleanup;
|
||||
} else {
|
||||
uint16_t a, s, t;
|
||||
|
||||
@ -305,7 +305,7 @@ static int printConverters(const char *pname, const char *lookfor,
|
||||
putchar('\t');
|
||||
u_wmsg(stderr, "cantGetAliases", str.getTerminatedBuffer(),
|
||||
u_wmsg_errorName(err));
|
||||
return -1;
|
||||
goto error_cleanup;
|
||||
}
|
||||
|
||||
/* Print the current alias so that it looks right. */
|
||||
@ -363,6 +363,9 @@ static int printConverters(const char *pname, const char *lookfor,
|
||||
/* Success. */
|
||||
|
||||
return 0;
|
||||
error_cleanup:
|
||||
uprv_free(stds);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Print all available transliterators. If canon is non zero, print
|
||||
|
@ -129,6 +129,7 @@ void CharsetDetector::setRecognizers(UErrorCode &status)
|
||||
|
||||
if (recognizers == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
} else {
|
||||
for (r = 0; r < rCount; r += 1) {
|
||||
recognizers[r] = tempArray[r];
|
||||
|
@ -894,13 +894,13 @@ DateTimePatternGenerator::isAvailableFormatSet(const UnicodeString &key) const {
|
||||
void
|
||||
DateTimePatternGenerator::copyHashtable(Hashtable *other) {
|
||||
|
||||
if (fAvailableFormatKeyHash !=NULL) {
|
||||
delete fAvailableFormatKeyHash;
|
||||
}
|
||||
if (other == NULL) {
|
||||
fAvailableFormatKeyHash = NULL;
|
||||
return;
|
||||
}
|
||||
if (fAvailableFormatKeyHash != NULL) {
|
||||
delete fAvailableFormatKeyHash;
|
||||
fAvailableFormatKeyHash = NULL;
|
||||
}
|
||||
initHashtable(fStatus);
|
||||
if(U_FAILURE(fStatus)){
|
||||
return;
|
||||
|
@ -1306,11 +1306,10 @@ RuleBasedNumberFormat::init(const UnicodeString& rules, LocalizationInfo* locali
|
||||
// because we have to know the names and locations of all the rule
|
||||
// sets before we can actually set everything up
|
||||
if(!numRuleSets) {
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return;
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return;
|
||||
}
|
||||
UnicodeString* ruleSetDescriptions = new UnicodeString[numRuleSets];
|
||||
/* test for NULL */
|
||||
if (ruleSetDescriptions == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
@ -1322,20 +1321,18 @@ RuleBasedNumberFormat::init(const UnicodeString& rules, LocalizationInfo* locali
|
||||
for (int32_t p = description.indexOf(gSemiPercent); p != -1; p = description.indexOf(gSemiPercent, start)) {
|
||||
ruleSetDescriptions[curRuleSet].setTo(description, start, p + 1 - start);
|
||||
ruleSets[curRuleSet] = new NFRuleSet(ruleSetDescriptions, curRuleSet, status);
|
||||
/* test for NULL */
|
||||
if (ruleSets[curRuleSet] == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
goto cleanup;
|
||||
}
|
||||
++curRuleSet;
|
||||
start = p + 1;
|
||||
}
|
||||
ruleSetDescriptions[curRuleSet].setTo(description, start, description.length() - start);
|
||||
ruleSets[curRuleSet] = new NFRuleSet(ruleSetDescriptions, curRuleSet, status);
|
||||
/* test for NULL */
|
||||
if (ruleSets[curRuleSet] == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1359,8 +1356,6 @@ RuleBasedNumberFormat::init(const UnicodeString& rules, LocalizationInfo* locali
|
||||
}
|
||||
}
|
||||
|
||||
delete[] ruleSetDescriptions;
|
||||
|
||||
// Now that the rules are initialized, the 'real' default rule
|
||||
// set can be adjusted by the localization data.
|
||||
|
||||
@ -1384,6 +1379,9 @@ RuleBasedNumberFormat::init(const UnicodeString& rules, LocalizationInfo* locali
|
||||
} else {
|
||||
defaultRuleSet = getDefaultRuleSet();
|
||||
}
|
||||
|
||||
cleanup:
|
||||
delete[] ruleSetDescriptions;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2007, International Business Machines Corporation and *
|
||||
* Copyright (C) 2007-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -293,6 +293,7 @@ RuleBasedTimeZone::complete(UErrorCode& status) {
|
||||
}
|
||||
Transition *final1 = (Transition*)uprv_malloc(sizeof(Transition));
|
||||
if (final1 == NULL) {
|
||||
uprv_free(final0);
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -522,8 +522,8 @@ ucol_safeClone(const UCollator *coll, void *stackBuffer, int32_t * pBufferSize,
|
||||
stackBufferChars = (char *)uprv_malloc(bufferSizeNeeded);
|
||||
// Null pointer check.
|
||||
if (stackBufferChars == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
colAllocated = TRUE;
|
||||
if (U_SUCCESS(*status)) {
|
||||
@ -540,8 +540,8 @@ ucol_safeClone(const UCollator *coll, void *stackBuffer, int32_t * pBufferSize,
|
||||
image = (uint8_t *)uprv_malloc(imageSize);
|
||||
// Null pointer check
|
||||
if (image == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
ucol_cloneBinary(coll, image, imageSize, status);
|
||||
imageAllocated = TRUE;
|
||||
@ -1663,8 +1663,8 @@ void collPrevIterNormalize(collIterate *data)
|
||||
data->writableBuffer = (UChar *)uprv_malloc((normLen + 1) *
|
||||
sizeof(UChar));
|
||||
if(data->writableBuffer == NULL) { // something is wrong here, return
|
||||
data->writableBufSize = 0; // Reset writableBufSize
|
||||
return;
|
||||
data->writableBufSize = 0; // Reset writableBufSize
|
||||
return;
|
||||
}
|
||||
data->flags |= UCOL_ITER_ALLOCATED;
|
||||
/* to handle the zero termination */
|
||||
@ -2150,7 +2150,7 @@ inline void normalizeNextContraction(collIterate *data)
|
||||
data->writableBufSize = size;
|
||||
data->flags |= UCOL_ITER_ALLOCATED;
|
||||
} else {
|
||||
return; // Avoid writing past bound of buffer->writableBuffer.
|
||||
return; // Avoid writing past bound of buffer->writableBuffer.
|
||||
}
|
||||
}
|
||||
|
||||
@ -2243,7 +2243,7 @@ inline UChar getNextNormalizedChar(collIterate *data)
|
||||
*(data->fcdPosition)) + 1;
|
||||
// Check if data->pos received a null pointer
|
||||
if (data->pos == NULL) {
|
||||
return (UChar)-1; // Return to indicate error.
|
||||
return (UChar)-1; // Return to indicate error.
|
||||
}
|
||||
return *(data->fcdPosition ++);
|
||||
}
|
||||
@ -2292,7 +2292,7 @@ inline UChar getNextNormalizedChar(collIterate *data)
|
||||
data->pos - 1, length);
|
||||
// Check if data->pos received a null pointer
|
||||
if (data->pos == NULL) {
|
||||
return (UChar)-1; // Return to indicate error.
|
||||
return (UChar)-1; // Return to indicate error.
|
||||
}
|
||||
return *(data->pos ++);
|
||||
}
|
||||
@ -2306,7 +2306,7 @@ inline UChar getNextNormalizedChar(collIterate *data)
|
||||
data->pos = insertBufferEnd(data, pEndWritableBuffer, ch) + 1;
|
||||
// Check if data->pos received a null pointer
|
||||
if (data->pos == NULL) {
|
||||
return (UChar)-1; // Return to indicate error.
|
||||
return (UChar)-1; // Return to indicate error.
|
||||
}
|
||||
}
|
||||
|
||||
@ -2352,8 +2352,8 @@ inline void setDiscontiguosAttribute(collIterate *source, UChar *buffer,
|
||||
source->writableBuffer =
|
||||
(UChar *)uprv_malloc((length + 1) * sizeof(UChar));
|
||||
if(source->writableBuffer == NULL) {
|
||||
source->writableBufSize = 0; // Reset size
|
||||
return;
|
||||
source->writableBufSize = 0; // Reset size
|
||||
return;
|
||||
}
|
||||
source->writableBufSize = length;
|
||||
}
|
||||
@ -2552,8 +2552,6 @@ inline UChar * insertBufferFront(collIterate *data, UChar *pNull, UChar ch)
|
||||
static
|
||||
inline void normalizePrevContraction(collIterate *data, UErrorCode *status)
|
||||
{
|
||||
UChar *buffer = data->writableBuffer;
|
||||
uint32_t buffersize = data->writableBufSize;
|
||||
uint32_t nulltermsize;
|
||||
UErrorCode localstatus = U_ZERO_ERROR;
|
||||
UChar *pEnd = data->pos + 1; /* End normalize + 1 */
|
||||
@ -2566,12 +2564,12 @@ inline void normalizePrevContraction(collIterate *data, UErrorCode *status)
|
||||
normalization buffer not used yet, we'll pull down the next
|
||||
character into the end of the buffer
|
||||
*/
|
||||
*(buffer + (buffersize - 1)) = *(data->pos + 1);
|
||||
nulltermsize = buffersize - 1;
|
||||
*(data->writableBuffer + (data->writableBufSize - 1)) = *(data->pos + 1);
|
||||
nulltermsize = data->writableBufSize - 1;
|
||||
}
|
||||
else {
|
||||
nulltermsize = buffersize;
|
||||
UChar *temp = buffer + (nulltermsize - 1);
|
||||
nulltermsize = data->writableBufSize;
|
||||
UChar *temp = data->writableBuffer + (nulltermsize - 1);
|
||||
while (*(temp --) != 0) {
|
||||
nulltermsize --;
|
||||
}
|
||||
@ -2585,19 +2583,19 @@ inline void normalizePrevContraction(collIterate *data, UErrorCode *status)
|
||||
pStart = data->fcdPosition + 1;
|
||||
}
|
||||
|
||||
normLen = unorm_normalize(pStart, pEnd - pStart, UNORM_NFD, 0, buffer, 0,
|
||||
normLen = unorm_normalize(pStart, pEnd - pStart, UNORM_NFD, 0, data->writableBuffer, 0,
|
||||
&localstatus);
|
||||
|
||||
if (nulltermsize <= normLen) {
|
||||
uint32_t size = buffersize - nulltermsize + normLen + 1;
|
||||
uint32_t size = data->writableBufSize - nulltermsize + normLen + 1;
|
||||
UChar *temp = (UChar *)uprv_malloc(size * sizeof(UChar));
|
||||
if (temp == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
nulltermsize = normLen + 1;
|
||||
uprv_memcpy(temp + normLen, buffer,
|
||||
sizeof(UChar) * (buffersize - nulltermsize));
|
||||
uprv_memcpy(temp + normLen, data->writableBuffer,
|
||||
sizeof(UChar) * (data->writableBufSize - nulltermsize));
|
||||
freeHeapWritableBuffer(data);
|
||||
data->writableBuffer = temp;
|
||||
data->writableBufSize = size;
|
||||
@ -2607,7 +2605,7 @@ inline void normalizePrevContraction(collIterate *data, UErrorCode *status)
|
||||
this puts the null termination infront of the normalized string instead
|
||||
of the end
|
||||
*/
|
||||
pStartNorm = buffer + (nulltermsize - normLen);
|
||||
pStartNorm = data->writableBuffer + (nulltermsize - normLen);
|
||||
*(pStartNorm - 1) = 0;
|
||||
unorm_normalize(pStart, pEnd - pStart, UNORM_NFD, 0, pStartNorm, normLen,
|
||||
status);
|
||||
@ -3061,8 +3059,8 @@ uint32_t ucol_prv_getSpecialCE(const UCollator *coll, UChar ch, uint32_t CE, col
|
||||
numTempBuf = (uint8_t *)uprv_malloc(sizeof(uint8_t) * numTempBufSize);
|
||||
// Null pointer check
|
||||
if (numTempBuf == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
uprv_memcpy(numTempBuf, stackNumTempBuf, UCOL_MAX_BUFFER);
|
||||
} else {
|
||||
@ -3714,8 +3712,8 @@ uint32_t ucol_prv_getSpecialPrevCE(const UCollator *coll, UChar ch, uint32_t CE,
|
||||
numTempBuf = (uint8_t *)uprv_malloc(sizeof(uint8_t) * numTempBufSize);
|
||||
// Null pointer check
|
||||
if (numTempBuf == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
uprv_memcpy(numTempBuf, stackNumTempBuf, UCOL_MAX_BUFFER);
|
||||
}else {
|
||||
@ -4363,15 +4361,17 @@ int32_t ucol_getSortKeySize(const UCollator *coll, collIterate *s, int32_t curre
|
||||
} else {
|
||||
fSecs[fSecsLen++] = secondary;
|
||||
if(fSecsLen == fSecsMaxLen) {
|
||||
uint8_t *fSecsTemp;
|
||||
if(fSecs == fSecsBuff) {
|
||||
fSecs = (uint8_t *)uprv_malloc(2*fSecsLen);
|
||||
fSecsTemp = (uint8_t *)uprv_malloc(2*fSecsLen);
|
||||
} else {
|
||||
fSecs = (uint8_t *)uprv_realloc(fSecs, 2*fSecsLen);
|
||||
fSecsTemp = (uint8_t *)uprv_realloc(fSecs, 2*fSecsLen);
|
||||
}
|
||||
if(fSecs == NULL) {
|
||||
if(fSecsTemp == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
fSecs = fSecsTemp;
|
||||
fSecsMaxLen *= 2;
|
||||
}
|
||||
if(notIsContinuation) {
|
||||
@ -4579,7 +4579,7 @@ ucol_calcSortKey(const UCollator *coll,
|
||||
uint8_t *primaries = *result, *secondaries = second, *tertiaries = tert, *cases = caseB, *quads = quad;
|
||||
|
||||
if(U_FAILURE(*status)) {
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(primaries == NULL && allocateSKBuffer == TRUE) {
|
||||
@ -4671,11 +4671,11 @@ ucol_calcSortKey(const UCollator *coll,
|
||||
}
|
||||
|
||||
if(resultLength == 0 || primaries == NULL) {
|
||||
int32_t keyLen = ucol_getSortKeySize(coll, &s, sortKeySize, strength, len);
|
||||
if(normSource != normBuffer) {
|
||||
uprv_free(normSource);
|
||||
}
|
||||
return keyLen;
|
||||
int32_t keyLen = ucol_getSortKeySize(coll, &s, sortKeySize, strength, len);
|
||||
if(normSource != normBuffer) {
|
||||
uprv_free(normSource);
|
||||
}
|
||||
return keyLen;
|
||||
}
|
||||
uint8_t *primarySafeEnd = primaries + resultLength - 1;
|
||||
if(strength > UCOL_PRIMARY) {
|
||||
@ -5157,6 +5157,20 @@ ucol_calcSortKey(const UCollator *coll,
|
||||
*(primaries++) = '\0';
|
||||
}
|
||||
|
||||
if(allocateSKBuffer == TRUE) {
|
||||
*result = (uint8_t*)uprv_malloc(sortKeySize);
|
||||
/* test for NULL */
|
||||
if (*result == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
goto cleanup;
|
||||
}
|
||||
uprv_memcpy(*result, primStart, sortKeySize);
|
||||
if(primStart != prim) {
|
||||
uprv_free(primStart);
|
||||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if(terStart != tert) {
|
||||
uprv_free(terStart);
|
||||
uprv_free(secStart);
|
||||
@ -5168,19 +5182,9 @@ ucol_calcSortKey(const UCollator *coll,
|
||||
uprv_free(normSource);
|
||||
}
|
||||
|
||||
if(allocateSKBuffer == TRUE) {
|
||||
*result = (uint8_t*)uprv_malloc(sortKeySize);
|
||||
/* test for NULL */
|
||||
if (*result == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return sortKeySize;
|
||||
}
|
||||
uprv_memcpy(*result, primStart, sortKeySize);
|
||||
if(primStart != prim) {
|
||||
uprv_free(primStart);
|
||||
}
|
||||
if (U_FAILURE(*status) && *status != U_BUFFER_OVERFLOW_ERROR) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return sortKeySize;
|
||||
}
|
||||
|
||||
@ -6572,8 +6576,8 @@ ucol_setUpLatinOne(UCollator *coll, UErrorCode *status) {
|
||||
UCollationElements *it = ucol_openElements(coll, &ch, 1, status);
|
||||
// Check for null pointer
|
||||
if (it == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return FALSE;
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return FALSE;
|
||||
}
|
||||
uprv_memset(coll->latinOneCEs, 0, sizeof(uint32_t)*coll->latinOneTableLen*3);
|
||||
|
||||
|
@ -252,7 +252,7 @@ uprv_uca_cloneTempTable(tempUCATable *t, UErrorCode *status) {
|
||||
/* test for NULL */
|
||||
if (r->expansions == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
goto cleanup;
|
||||
}
|
||||
r->expansions->position = t->expansions->position;
|
||||
r->expansions->size = t->expansions->size;
|
||||
@ -261,7 +261,7 @@ uprv_uca_cloneTempTable(tempUCATable *t, UErrorCode *status) {
|
||||
/* test for NULL */
|
||||
if (r->expansions->CEs == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
goto cleanup;
|
||||
}
|
||||
uprv_memcpy(r->expansions->CEs, t->expansions->CEs, sizeof(uint32_t)*t->expansions->position);
|
||||
} else {
|
||||
@ -273,8 +273,8 @@ uprv_uca_cloneTempTable(tempUCATable *t, UErrorCode *status) {
|
||||
r->contractions = uprv_cnttab_clone(t->contractions, status);
|
||||
// Check for cloning failure.
|
||||
if (r->contractions == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
goto cleanup;
|
||||
}
|
||||
r->contractions->mapping = r->mapping;
|
||||
}
|
||||
@ -284,7 +284,7 @@ uprv_uca_cloneTempTable(tempUCATable *t, UErrorCode *status) {
|
||||
/* test for NULL */
|
||||
if (r->maxExpansions == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
goto cleanup;
|
||||
}
|
||||
r->maxExpansions->size = t->maxExpansions->size;
|
||||
r->maxExpansions->position = t->maxExpansions->position;
|
||||
@ -293,7 +293,7 @@ uprv_uca_cloneTempTable(tempUCATable *t, UErrorCode *status) {
|
||||
/* test for NULL */
|
||||
if (r->maxExpansions->endExpansionCE == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
goto cleanup;
|
||||
}
|
||||
uprv_memset(r->maxExpansions->endExpansionCE, 0xDB, sizeof(uint32_t)*t->maxExpansions->size);
|
||||
uprv_memcpy(r->maxExpansions->endExpansionCE, t->maxExpansions->endExpansionCE, t->maxExpansions->position*sizeof(uint32_t));
|
||||
@ -305,7 +305,7 @@ uprv_uca_cloneTempTable(tempUCATable *t, UErrorCode *status) {
|
||||
/* test for NULL */
|
||||
if (r->maxExpansions->expansionCESize == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
goto cleanup;
|
||||
}
|
||||
uprv_memset(r->maxExpansions->expansionCESize, 0xDB, sizeof(uint8_t)*t->maxExpansions->size);
|
||||
uprv_memcpy(r->maxExpansions->expansionCESize, t->maxExpansions->expansionCESize, t->maxExpansions->position*sizeof(uint8_t));
|
||||
@ -319,7 +319,7 @@ uprv_uca_cloneTempTable(tempUCATable *t, UErrorCode *status) {
|
||||
/* test for NULL */
|
||||
if (r->maxJamoExpansions == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
goto cleanup;
|
||||
}
|
||||
r->maxJamoExpansions->size = t->maxJamoExpansions->size;
|
||||
r->maxJamoExpansions->position = t->maxJamoExpansions->position;
|
||||
@ -331,14 +331,14 @@ uprv_uca_cloneTempTable(tempUCATable *t, UErrorCode *status) {
|
||||
/* test for NULL */
|
||||
if (r->maxJamoExpansions->endExpansionCE == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
goto cleanup;
|
||||
}
|
||||
uprv_memcpy(r->maxJamoExpansions->endExpansionCE, t->maxJamoExpansions->endExpansionCE, t->maxJamoExpansions->position*sizeof(uint32_t));
|
||||
r->maxJamoExpansions->isV = (UBool *)uprv_malloc(sizeof(UBool)*t->maxJamoExpansions->size);
|
||||
/* test for NULL */
|
||||
if (r->maxJamoExpansions->isV == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
goto cleanup;
|
||||
}
|
||||
uprv_memcpy(r->maxJamoExpansions->isV, t->maxJamoExpansions->isV, t->maxJamoExpansions->position*sizeof(UBool));
|
||||
} else {
|
||||
@ -352,7 +352,7 @@ uprv_uca_cloneTempTable(tempUCATable *t, UErrorCode *status) {
|
||||
/* test for NULL */
|
||||
if (r->unsafeCP == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
goto cleanup;
|
||||
}
|
||||
uprv_memcpy(r->unsafeCP, t->unsafeCP, UCOL_UNSAFECP_TABLE_SIZE);
|
||||
}
|
||||
@ -362,7 +362,7 @@ uprv_uca_cloneTempTable(tempUCATable *t, UErrorCode *status) {
|
||||
/* test for NULL */
|
||||
if (r->contrEndCP == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
goto cleanup;
|
||||
}
|
||||
uprv_memcpy(r->contrEndCP, t->contrEndCP, UCOL_UNSAFECP_TABLE_SIZE);
|
||||
}
|
||||
@ -372,6 +372,9 @@ uprv_uca_cloneTempTable(tempUCATable *t, UErrorCode *status) {
|
||||
r->options = t->options;
|
||||
|
||||
return r;
|
||||
cleanup:
|
||||
uprv_uca_closeTempTable(t);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -481,30 +484,30 @@ static int uprv_uca_setMaxExpansion(uint32_t endexpansion,
|
||||
uint32_t *start = pendexpansionce;
|
||||
uint32_t *limit = pendexpansionce + pos;
|
||||
|
||||
/* using binary search to determine if last expansion element is
|
||||
/* using binary search to determine if last expansion element is
|
||||
already in the array */
|
||||
uint32_t *mid;
|
||||
uint32_t *mid;
|
||||
int result = -1;
|
||||
while (start < limit - 1) {
|
||||
mid = start + ((limit - start) >> 1);
|
||||
if (endexpansion <= *mid) {
|
||||
limit = mid;
|
||||
}
|
||||
else {
|
||||
start = mid;
|
||||
}
|
||||
}
|
||||
while (start < limit - 1) {
|
||||
mid = start + ((limit - start) >> 1);
|
||||
if (endexpansion <= *mid) {
|
||||
limit = mid;
|
||||
}
|
||||
else {
|
||||
start = mid;
|
||||
}
|
||||
}
|
||||
|
||||
if (*start == endexpansion) {
|
||||
result = start - pendexpansionce;
|
||||
}
|
||||
else
|
||||
if (*limit == endexpansion) {
|
||||
result = limit - pendexpansionce;
|
||||
}
|
||||
if (*start == endexpansion) {
|
||||
result = start - pendexpansionce;
|
||||
}
|
||||
else
|
||||
if (*limit == endexpansion) {
|
||||
result = limit - pendexpansionce;
|
||||
}
|
||||
|
||||
if (result > -1) {
|
||||
/* found the ce in expansion, we'll just modify the size if it is
|
||||
/* found the ce in expansion, we'll just modify the size if it is
|
||||
smaller */
|
||||
uint8_t *currentsize = pexpansionsize + result;
|
||||
if (*currentsize < expansionsize) {
|
||||
@ -512,7 +515,7 @@ static int uprv_uca_setMaxExpansion(uint32_t endexpansion,
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* we'll need to squeeze the value into the array.
|
||||
/* we'll need to squeeze the value into the array.
|
||||
initial implementation. */
|
||||
/* shifting the subarray down by 1 */
|
||||
int shiftsize = (pendexpansionce + pos) - start;
|
||||
|
@ -1141,6 +1141,7 @@ static UColToken *ucol_tok_initAReset(UColTokenParser *src, UChar *expand, uint3
|
||||
// this is a syntax error
|
||||
*status = U_INVALID_FORMAT_ERROR;
|
||||
syntaxError(src->source,src->parsedToken.charsOffset-1,src->parsedToken.charsOffset+src->parsedToken.charsLen,parseError);
|
||||
uprv_free(sourceToken);
|
||||
return 0;
|
||||
} else {
|
||||
sourceToken->prefix = 0;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2004-2007, International Business Machines
|
||||
* Copyright (C) 2004-2008, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
* file name: regex.cpp
|
||||
@ -196,10 +196,6 @@ uregex_clone(const URegularExpression *source, UErrorCode *status) {
|
||||
delete clone;
|
||||
return NULL;
|
||||
}
|
||||
if (clone == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
clone->fPat = source->fPat;
|
||||
clone->fPatRefCount = source->fPatRefCount;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2007, International Business Machines Corporation and *
|
||||
* Copyright (C) 2007-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -1336,6 +1336,10 @@ VTimeZone::parse(UErrorCode& status) {
|
||||
if (U_FAILURE(status)) {
|
||||
goto cleanupParse;
|
||||
}
|
||||
if (rules == NULL || dates == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
goto cleanupParse;
|
||||
}
|
||||
|
||||
for (n = 0; n < vtzlines->size(); n++) {
|
||||
UnicodeString *line = (UnicodeString*)vtzlines->elementAt(n);
|
||||
@ -1530,9 +1534,17 @@ VTimeZone::parse(UErrorCode& status) {
|
||||
getDefaultTZName(tzid, FALSE, tzname);
|
||||
initialRule = new InitialTimeZoneRule(tzname,
|
||||
initialRawOffset, initialDSTSavings);
|
||||
if (initialRule == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
goto cleanupParse;
|
||||
}
|
||||
|
||||
// Finally, create the RuleBasedTimeZone
|
||||
rbtz = new RuleBasedTimeZone(tzid, initialRule);
|
||||
if (rbtz == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
goto cleanupParse;
|
||||
}
|
||||
while (!rules->isEmpty()) {
|
||||
TimeZoneRule *tzr = (TimeZoneRule*)rules->orphanElementAt(0);
|
||||
rbtz->addTransitionRule(tzr, status);
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2006, International Business Machines
|
||||
* Copyright (C) 1999-2008, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
*******************************************************************************
|
||||
@ -255,7 +255,10 @@ main(int argc, char* argv[]) {
|
||||
char *end;
|
||||
|
||||
uprv_strcpy(pathBuf, path);
|
||||
end = uprv_strchr(pathBuf, 0);
|
||||
end = uprv_strrchr(pathBuf, 0);
|
||||
if (end == NULL) {
|
||||
end = pathBuf+strlen(pathBuf);
|
||||
}
|
||||
if(*(end-1)!=U_FILE_SEP_CHAR) {
|
||||
*(end++)=U_FILE_SEP_CHAR;
|
||||
}
|
||||
@ -559,14 +562,27 @@ addTaggedAlias(uint16_t tag, const char *alias, uint16_t converter) {
|
||||
static void
|
||||
addOfficialTaggedStandards(char *line, int32_t lineLen) {
|
||||
char *atag;
|
||||
char *tag = strchr(line, '{') + 1;
|
||||
char *endTagExp;
|
||||
char *tag;
|
||||
static const char WHITESPACE[] = " \t";
|
||||
|
||||
if (tagCount > UCNV_NUM_RESERVED_TAGS) {
|
||||
fprintf(stderr, "error(line %d): official tags already added\n", lineNum);
|
||||
exit(U_BUFFER_OVERFLOW_ERROR);
|
||||
}
|
||||
strchr(tag, '}')[0] = 0;
|
||||
tag = strchr(line, '{');
|
||||
if (tag == NULL) {
|
||||
/* Why were we called? */
|
||||
fprintf(stderr, "error(line %d): Missing start of tag group\n", lineNum);
|
||||
exit(U_PARSE_ERROR);
|
||||
}
|
||||
tag++;
|
||||
endTagExp = strchr(tag, '}');
|
||||
if (endTagExp == NULL) {
|
||||
fprintf(stderr, "error(line %d): Missing end of tag group\n", lineNum);
|
||||
exit(U_PARSE_ERROR);
|
||||
}
|
||||
endTagExp[0] = 0;
|
||||
|
||||
tag = strtok(tag, WHITESPACE);
|
||||
while (tag != NULL) {
|
||||
|
@ -587,12 +587,7 @@ UCAElements *readAnElement(FILE *data, tempUCATable *t, UCAConstants *consts, UE
|
||||
*(endCodePoint) = 0;
|
||||
}
|
||||
|
||||
if(element != NULL) {
|
||||
memset(element, 0, sizeof(*element));
|
||||
} else {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
memset(element, 0, sizeof(*element));
|
||||
|
||||
element->cPoints = element->uchars;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2000-2006, International Business Machines
|
||||
* Copyright (C) 2000-2008, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
***************************************************************************
|
||||
@ -276,23 +276,12 @@ pkg_mak_writeObjRules(UPKGOptions *o, FileStream *makefile, CharList **objects,
|
||||
CharList *oTail = NULL;
|
||||
CharList *infiles;
|
||||
CharList *parents = NULL, *commands = NULL;
|
||||
int32_t genFileOffset = 0; /* offset from beginning of .c and .o file name, use to chop off package name for AS/400 */
|
||||
char *parentPath;
|
||||
const char *tchar;
|
||||
char tree[1024];
|
||||
|
||||
infiles = o->files; /* raw files - no paths other than tree paths */
|
||||
|
||||
#if defined (OS400)
|
||||
if(infiles != NULL) {
|
||||
baseName = findBasename(infiles->str);
|
||||
p = uprv_strchr(baseName, '_');
|
||||
if(p != NULL) {
|
||||
genFileOffset = (p-baseName)+1; /* "package_" - name + underscore */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
for(;infiles;infiles = infiles->next) {
|
||||
baseName = infiles->str; /* skip the icudt28b/ part */
|
||||
p = uprv_strrchr(baseName, '.');
|
||||
@ -317,7 +306,7 @@ pkg_mak_writeObjRules(UPKGOptions *o, FileStream *makefile, CharList **objects,
|
||||
}
|
||||
}
|
||||
|
||||
*objects = pkg_appendToList(*objects, &oTail, uprv_strdup(tmp + genFileOffset)); /* Offset for AS/400 */
|
||||
*objects = pkg_appendToList(*objects, &oTail, uprv_strdup(tmp));
|
||||
|
||||
/* write source list */
|
||||
uprv_strcpy(cfile,tmp);
|
||||
@ -363,18 +352,13 @@ pkg_mak_writeObjRules(UPKGOptions *o, FileStream *makefile, CharList **objects,
|
||||
pkg_writeCharList(makefile, commands, "\n\t",0);
|
||||
T_FileStream_write(makefile, "\n\n", 2);
|
||||
#else
|
||||
if(genFileOffset > 0) { /* for AS/400 */
|
||||
sprintf(stanza, "@mv $(TEMP_PATH)%s $(TEMP_PATH)%s", cfile, cfile+genFileOffset);
|
||||
commands = pkg_appendToList(commands, NULL, uprv_strdup(stanza));
|
||||
}
|
||||
|
||||
sprintf(stanza, "@$(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $(TEMP_DIR)/%s", cfile+genFileOffset); /* for AS/400 */
|
||||
sprintf(stanza, "@$(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $(TEMP_DIR)/%s", cfile);
|
||||
commands = pkg_appendToList(commands, NULL, uprv_strdup(stanza));
|
||||
|
||||
sprintf(stanza, "@$(RMV) $(TEMP_DIR)/%s", cfile+genFileOffset);
|
||||
sprintf(stanza, "@$(RMV) $(TEMP_DIR)/%s", cfile);
|
||||
commands = pkg_appendToList(commands, NULL, uprv_strdup(stanza));
|
||||
|
||||
sprintf(stanza, "$(TEMP_PATH)%s", tmp+genFileOffset); /* for AS/400 */
|
||||
sprintf(stanza, "$(TEMP_PATH)%s", tmp);
|
||||
pkg_mak_writeStanza(makefile, o, stanza, parents, commands);
|
||||
#endif
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
#define MAX_IN_BUF 1000
|
||||
#define MAX_U_BUF 1500
|
||||
#define CONTEXT_LEN 15
|
||||
#define CONTEXT_LEN 20
|
||||
|
||||
struct UCHARBUF {
|
||||
UChar* buffer;
|
||||
@ -221,9 +221,9 @@ ucbuf_fillucbuf( UCHARBUF* buf,UErrorCode* error){
|
||||
(UBool)(buf->remaining==0),error);
|
||||
|
||||
if(U_FAILURE(*error)){
|
||||
char context[CONTEXT_LEN];
|
||||
char preContext[CONTEXT_LEN];
|
||||
char postContext[CONTEXT_LEN];
|
||||
char context[CONTEXT_LEN+1];
|
||||
char preContext[CONTEXT_LEN+1];
|
||||
char postContext[CONTEXT_LEN+1];
|
||||
int8_t len = CONTEXT_LEN;
|
||||
int32_t start=0;
|
||||
int32_t stop =0;
|
||||
@ -417,9 +417,9 @@ ucbuf_getcx32(UCHARBUF* buf,UErrorCode* error) {
|
||||
*/
|
||||
if(c32==0xFFFFFFFF){
|
||||
if(buf->showWarning) {
|
||||
char context[20];
|
||||
int32_t len = 20;
|
||||
if(length < len) {
|
||||
char context[CONTEXT_LEN+1];
|
||||
int32_t len = CONTEXT_LEN;
|
||||
if(length < len) {
|
||||
len = length;
|
||||
}
|
||||
context[len]= 0 ; /* null terminate the buffer */
|
||||
|
Loading…
Reference in New Issue
Block a user