+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
*
*
*******************************************************************************
* file name: usprep.cpp
- * encoding: US-ASCII
+ * encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
Static cache for already opened StringPrep profiles
*/
static UHashtable *SHARED_DATA_HASHTABLE = NULL;
-static icu::UInitOnce gSharedDataInitOnce;
-
-static UMutex usprepMutex = U_MUTEX_INITIALIZER;
+static icu::UInitOnce gSharedDataInitOnce = U_INITONCE_INITIALIZER;
+static UMutex usprepMutex;
/* format version of spp file */
//static uint8_t formatVersion[4]={ 0, 0, 0, 0 };
UHashTok namekey, pathkey;
namekey.pointer = b->name;
pathkey.pointer = b->path;
- return uhash_hashChars(namekey)+37*uhash_hashChars(pathkey);
+ uint32_t unsignedHash = static_cast<uint32_t>(uhash_hashChars(namekey)) +
+ 37u * static_cast<uint32_t>(uhash_hashChars(pathkey));
+ return static_cast<int32_t>(unsignedHash);
}
/* compares two entries */
newProfile->doNFKC = (UBool)((newProfile->indexes[_SPREP_OPTIONS] & _SPREP_NORMALIZATION_ON) > 0);
newProfile->checkBiDi = (UBool)((newProfile->indexes[_SPREP_OPTIONS] & _SPREP_CHECK_BIDI_ON) > 0);
- if(newProfile->checkBiDi) {
- newProfile->bdp = ubidi_getSingleton();
- }
-
LocalMemory<UStringPrepKey> key;
LocalMemory<char> keyName;
LocalMemory<char> keyPath;
if( key.allocateInsteadAndReset() == NULL ||
- keyName.allocateInsteadAndCopy(uprv_strlen(name)+1) == NULL ||
+ keyName.allocateInsteadAndCopy(static_cast<int32_t>(uprv_strlen(name)+1)) == NULL ||
(path != NULL &&
- keyPath.allocateInsteadAndCopy(uprv_strlen(path)+1) == NULL)
+ keyPath.allocateInsteadAndCopy(static_cast<int32_t>(uprv_strlen(path)+1)) == NULL)
) {
*status = U_MEMORY_ALLOCATION_ERROR;
usprep_unload(newProfile.getAlias());
((result < _SPREP_TYPE_THRESHOLD) && (result & 0x01) /* first bit says it the code point is prohibited*/)
){
*status = U_STRINGPREP_PROHIBITED_ERROR;
- uprv_syntaxError(b1, b2Index-U16_LENGTH(ch), b2Len, parseError);
+ uprv_syntaxError(b2, b2Index-U16_LENGTH(ch), b2Len, parseError);
return 0;
}
if(profile->checkBiDi) {
- direction = ubidi_getClass(profile->bdp, ch);
+ direction = ubidi_getClass(ch);
if(firstCharDir == U_CHAR_DIRECTION_COUNT){
firstCharDir = direction;
}