ICU-3537 fix for fcdTrieIndex cleanup

X-SVN-Rev: 14406
This commit is contained in:
Vladimir Weinstein 2004-01-26 21:16:25 +00:00
parent 62fa14f790
commit a4513276b9
2 changed files with 41 additions and 6 deletions

View File

@ -68,6 +68,11 @@ static UCollator* _staticUCA = NULL;
// used for cleanup in ucol_cleanup
static UDataMemory* UCA_DATA_MEM = NULL;
// this is static pointer to the normalizer fcdTrieIndex
// it is always the same between calls to u_cleanup
// and therefore writing to it is not synchronized.
// It is cleaned in ucol_cleanup
static const uint16_t *fcdTrieIndex=NULL;
U_CDECL_BEGIN
static UBool U_CALLCONV
@ -801,8 +806,6 @@ void ucol_putOptionsToHeader(UCollator* result, UColOptionSet * opts, UErrorCode
}
#endif
static const uint16_t *fcdTrieIndex=NULL;
/**
* Approximate determination if a character is at a contraction end.
@ -952,9 +955,6 @@ UCollator* ucol_initCollator(const UCATableHeader *image, UCollator *fillIn, con
result->expansionCESize = (uint8_t*)result->image +
result->image->expansionCESize;
if (fcdTrieIndex == NULL) {
fcdTrieIndex = unorm_getFCDTrie(status);
}
//result->errorCode = *status;
@ -981,6 +981,7 @@ ucol_cleanup(void)
ucol_close(_staticUCA);
_staticUCA = NULL;
}
fcdTrieIndex = NULL;
return TRUE;
}
@ -1359,6 +1360,10 @@ ucol_initUCA(UErrorCode *status) {
result = NULL;
newUCA = NULL;
}
if (fcdTrieIndex == NULL) {
fcdTrieIndex = unorm_getFCDTrie(status);
ucln_i18n_registerCleanup();
}
umtx_unlock(NULL);
if(newUCA != NULL) {

View File

@ -40,6 +40,7 @@
#include "unicode/uloc.h"
#include "unicode/ucoleitr.h"
#include "unicode/ustring.h"
#include "unicode/uclean.h"
#include "cintltst.h"
#include "ccolltst.h"
@ -80,6 +81,8 @@ static void TestInvalidRules(void);
static void TestJitterbug1098(void);
static void TestFCDCrash(void);
const UCollationResult results[] = {
UCOL_LESS,
UCOL_LESS, /*UCOL_GREATER,*/
@ -137,7 +140,8 @@ void addAllCollTest(TestNode** root)
addTest(root, &TestSurrogates, "tscoll/callcoll/TestSurrogates");
addTest(root, &TestInvalidRules, "tscoll/callcoll/TestInvalidRules");
addTest(root, &TestJB1401, "tscoll/callcoll/TestJB1401");
addTest(root, &TestJitterbug1098, "tscoll/callcoll/TestJitterbug1098");
addTest(root, &TestJitterbug1098, "tscoll/callcoll/TestJitterbug1098");
addTest(root, &TestFCDCrash, "tscoll/callcoll/TestFCDCrash");
}
@ -1145,5 +1149,31 @@ TestJitterbug1098(){
}
}
static void
TestFCDCrash(void) {
static char *test[] = {
"Gr\\u00F6\\u00DFe",
"Grossist"
};
UErrorCode status = U_ZERO_ERROR;
UCollator *coll = ucol_open("es", &status);
if(U_FAILURE(status)) {
log_err("Couldn't open collator\n");
return;
}
ucol_close(coll);
coll = NULL;
u_cleanup();
coll = ucol_open("de_DE", &status);
if(U_FAILURE(status)) {
log_err("Couldn't open collator\n");
return;
}
ucol_setAttribute(coll, UCOL_NORMALIZATION_MODE, UCOL_ON, &status);
genericOrderingTest(coll, test, 2);
ucol_close(coll);
}
#endif /* #if !UCONFIG_NO_COLLATION */