ICU-3050 minor code review changes

X-SVN-Rev: 13016
This commit is contained in:
Ram Viswanadha 2003-09-02 22:32:17 +00:00
parent 8f7092b9b3
commit 1c1fa55d36
5 changed files with 17 additions and 14 deletions

View File

@ -86,6 +86,8 @@ struct UStringPrepProfile{
UDataMemory* sprepData; UDataMemory* sprepData;
UBool isDataLoaded; UBool isDataLoaded;
int32_t refCount; int32_t refCount;
UBool doNFKC;
UBool checkBiDi;
}; };
/** /**

View File

@ -66,7 +66,7 @@ typedef struct UStringPrepProfile UStringPrepProfile;
* @see usprep_prepare * @see usprep_prepare
* @draft ICU 2.8 * @draft ICU 2.8
*/ */
#define USPREP_NONE 0x0000 #define USPREP_DEFAULT 0x0000
/** /**
* Option to allow processing of unassigned code points in the input * Option to allow processing of unassigned code points in the input

View File

@ -277,6 +277,11 @@ usprep_getProfile(const char* path,
if(!loadData(profile, path, name, _SPREP_DATA_TYPE, status) || U_FAILURE(*status) ){ if(!loadData(profile, path, name, _SPREP_DATA_TYPE, status) || U_FAILURE(*status) ){
return NULL; return NULL;
} }
/* get the options */
profile->doNFKC = (UBool)((profile->indexes[_SPREP_OPTIONS] & _SPREP_NORMALIZATION_ON) > 0);
profile->checkBiDi = (UBool)((profile->indexes[_SPREP_OPTIONS] & _SPREP_CHECK_BIDI_ON) > 0);
umtx_lock(&usprepMutex); umtx_lock(&usprepMutex);
/* add the data object to the cache */ /* add the data object to the cache */
uhash_put(SHARED_DATA_HASHTABLE, key, profile, status); uhash_put(SHARED_DATA_HASHTABLE, key, profile, status);
@ -656,10 +661,6 @@ usprep_prepare( const UStringPrepProfile* profile,
int32_t rtlPos =-1, ltrPos =-1; int32_t rtlPos =-1, ltrPos =-1;
const int32_t *indexes = profile->indexes; const int32_t *indexes = profile->indexes;
// get the options
UBool doNFKC = (UBool)((indexes[_SPREP_OPTIONS] & _SPREP_NORMALIZATION_ON) > 0);
UBool checkBiDi = (UBool)((indexes[_SPREP_OPTIONS] & _SPREP_CHECK_BIDI_ON) > 0);
//get the string length //get the string length
if(srcLength == -1){ if(srcLength == -1){
srcLength = u_strlen(src); srcLength = u_strlen(src);
@ -683,7 +684,7 @@ usprep_prepare( const UStringPrepProfile* profile,
} }
// normalize // normalize
if(doNFKC == TRUE){ if(profile->doNFKC == TRUE){
b2Len = usprep_normalize(b1,b1Len, b2,b2Capacity,status); b2Len = usprep_normalize(b1,b1Len, b2,b2Capacity,status);
if(*status == U_BUFFER_OVERFLOW_ERROR){ if(*status == U_BUFFER_OVERFLOW_ERROR){
@ -748,7 +749,7 @@ usprep_prepare( const UStringPrepProfile* profile,
rtlPos = b2Index-1; rtlPos = b2Index-1;
} }
} }
if(checkBiDi == TRUE){ if(profile->checkBiDi == TRUE){
// satisfy 2 // satisfy 2
if( leftToRight == TRUE && rightToLeft == TRUE){ if( leftToRight == TRUE && rightToLeft == TRUE){
*status = U_STRINGPREP_CHECK_BIDI_ERROR; *status = U_STRINGPREP_CHECK_BIDI_ERROR;

View File

@ -86,7 +86,7 @@ nfs4_prepare( const char* src, int32_t srcLength,
/* open the profile */ /* open the profile */
profile = usprep_open(testdatapath, NFS4DataFileNames[state], status); profile = usprep_open(testdatapath, NFS4DataFileNames[state], status);
/* prepare the string */ /* prepare the string */
b2Len = usprep_prepare(profile, b1, b1Len, b2, b2Capacity, USPREP_NONE, parseError, status); b2Len = usprep_prepare(profile, b1, b1Len, b2, b2Capacity, USPREP_DEFAULT, parseError, status);
if(*status == U_BUFFER_OVERFLOW_ERROR){ if(*status == U_BUFFER_OVERFLOW_ERROR){
*status = U_ZERO_ERROR; *status = U_ZERO_ERROR;
b2 = (UChar*) malloc(b2Len * U_SIZEOF_UCHAR); b2 = (UChar*) malloc(b2Len * U_SIZEOF_UCHAR);
@ -94,7 +94,7 @@ nfs4_prepare( const char* src, int32_t srcLength,
*status = U_MEMORY_ALLOCATION_ERROR; *status = U_MEMORY_ALLOCATION_ERROR;
goto CLEANUP; goto CLEANUP;
} }
b2Len = usprep_prepare(profile, b1, b1Len, b2, b2Len, USPREP_NONE, parseError, status); b2Len = usprep_prepare(profile, b1, b1Len, b2, b2Len, USPREP_DEFAULT, parseError, status);
} }
/* convert the string back to UTF-8 */ /* convert the string back to UTF-8 */

View File

@ -52,11 +52,11 @@ static void
Test_nfs4_cs_prep_data(void){ Test_nfs4_cs_prep_data(void){
UErrorCode errorCode = U_ZERO_ERROR; UErrorCode errorCode = U_ZERO_ERROR;
log_verbose("Testing nfs4_cs_prep_ci.txt\n"); log_verbose("Testing nfs4_cs_prep_ci.txt\n");
doStringPrepTest("nfscsi","nfs4_cs_prep_ci.txt", USPREP_NONE, &errorCode); doStringPrepTest("nfscsi","nfs4_cs_prep_ci.txt", USPREP_DEFAULT, &errorCode);
log_verbose("Testing nfs4_cs_prep_cs.txt\n"); log_verbose("Testing nfs4_cs_prep_cs.txt\n");
errorCode = U_ZERO_ERROR; errorCode = U_ZERO_ERROR;
doStringPrepTest("nfscss","nfs4_cs_prep_cs.txt", USPREP_NONE, &errorCode); doStringPrepTest("nfscss","nfs4_cs_prep_cs.txt", USPREP_DEFAULT, &errorCode);
} }
@ -64,17 +64,17 @@ static void
Test_nfs4_cis_prep_data(void){ Test_nfs4_cis_prep_data(void){
UErrorCode errorCode = U_ZERO_ERROR; UErrorCode errorCode = U_ZERO_ERROR;
log_verbose("Testing nfs4_cis_prep.txt\n"); log_verbose("Testing nfs4_cis_prep.txt\n");
doStringPrepTest("nfscis","nfs4_cis_prep.txt", USPREP_NONE, &errorCode); doStringPrepTest("nfscis","nfs4_cis_prep.txt", USPREP_DEFAULT, &errorCode);
} }
static void static void
Test_nfs4_mixed_prep_data(void){ Test_nfs4_mixed_prep_data(void){
UErrorCode errorCode = U_ZERO_ERROR; UErrorCode errorCode = U_ZERO_ERROR;
log_verbose("Testing nfs4_mixed_prep_s.txt\n"); log_verbose("Testing nfs4_mixed_prep_s.txt\n");
doStringPrepTest("nfsmxs","nfs4_mixed_prep_s.txt", USPREP_NONE, &errorCode); doStringPrepTest("nfsmxs","nfs4_mixed_prep_s.txt", USPREP_DEFAULT, &errorCode);
errorCode = U_ZERO_ERROR; errorCode = U_ZERO_ERROR;
log_verbose("Testing nfs4_mixed_prep_p.txt\n"); log_verbose("Testing nfs4_mixed_prep_p.txt\n");
doStringPrepTest("nfsmxp","nfs4_mixed_prep_p.txt", USPREP_NONE, &errorCode); doStringPrepTest("nfsmxp","nfs4_mixed_prep_p.txt", USPREP_DEFAULT, &errorCode);
} }