summaryrefslogtreecommitdiffstats
path: root/thirdparty/icu4c/common/ucnv_bld.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/icu4c/common/ucnv_bld.cpp')
-rw-r--r--thirdparty/icu4c/common/ucnv_bld.cpp224
1 files changed, 112 insertions, 112 deletions
diff --git a/thirdparty/icu4c/common/ucnv_bld.cpp b/thirdparty/icu4c/common/ucnv_bld.cpp
index a0fbfe2d7f..564b645bed 100644
--- a/thirdparty/icu4c/common/ucnv_bld.cpp
+++ b/thirdparty/icu4c/common/ucnv_bld.cpp
@@ -57,10 +57,10 @@ extern void UCNV_DEBUG_LOG(char *what, char *who, void *p, int l);
static const UConverterSharedData * const
converterData[UCNV_NUMBER_OF_SUPPORTED_CONVERTER_TYPES]={
- NULL, NULL,
+ nullptr, nullptr,
#if UCONFIG_NO_LEGACY_CONVERSION
- NULL,
+ nullptr,
#else
&_MBCSData,
#endif
@@ -68,22 +68,22 @@ converterData[UCNV_NUMBER_OF_SUPPORTED_CONVERTER_TYPES]={
&_Latin1Data,
&_UTF8Data, &_UTF16BEData, &_UTF16LEData,
#if UCONFIG_ONLY_HTML_CONVERSION
- NULL, NULL,
+ nullptr, nullptr,
#else
&_UTF32BEData, &_UTF32LEData,
#endif
- NULL,
+ nullptr,
#if UCONFIG_NO_LEGACY_CONVERSION
- NULL,
+ nullptr,
#else
&_ISO2022Data,
#endif
#if UCONFIG_NO_LEGACY_CONVERSION || UCONFIG_ONLY_HTML_CONVERSION
- NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL,
- NULL,
+ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
+ nullptr,
#else
&_LMBCSData1,&_LMBCSData2, &_LMBCSData3, &_LMBCSData4, &_LMBCSData5, &_LMBCSData6,
&_LMBCSData8,&_LMBCSData11,&_LMBCSData16,&_LMBCSData17,&_LMBCSData18,&_LMBCSData19,
@@ -91,27 +91,27 @@ converterData[UCNV_NUMBER_OF_SUPPORTED_CONVERTER_TYPES]={
#endif
#if UCONFIG_ONLY_HTML_CONVERSION
- NULL,
+ nullptr,
#else
&_SCSUData,
#endif
#if UCONFIG_NO_LEGACY_CONVERSION || UCONFIG_ONLY_HTML_CONVERSION
- NULL,
+ nullptr,
#else
&_ISCIIData,
#endif
&_ASCIIData,
#if UCONFIG_ONLY_HTML_CONVERSION
- NULL, NULL, &_UTF16Data, NULL, NULL, NULL,
+ nullptr, nullptr, &_UTF16Data, nullptr, nullptr, nullptr,
#else
&_UTF7Data, &_Bocu1Data, &_UTF16Data, &_UTF32Data, &_CESU8Data, &_IMAPData,
#endif
#if UCONFIG_NO_LEGACY_CONVERSION || UCONFIG_ONLY_HTML_CONVERSION
- NULL,
+ nullptr,
#else
&_CompoundTextData
#endif
@@ -193,20 +193,20 @@ static struct {
/*initializes some global variables */
-static UHashtable *SHARED_DATA_HASHTABLE = NULL;
+static UHashtable *SHARED_DATA_HASHTABLE = nullptr;
static icu::UMutex cnvCacheMutex;
/* Note: the global mutex is used for */
/* reference count updates. */
-static const char **gAvailableConverters = NULL;
+static const char **gAvailableConverters = nullptr;
static uint16_t gAvailableConverterCount = 0;
static icu::UInitOnce gAvailableConvertersInitOnce {};
#if !U_CHARSET_IS_UTF8
/* This contains the resolved converter name. So no further alias lookup is needed again. */
-static char gDefaultConverterNameBuffer[UCNV_MAX_CONVERTER_NAME_LENGTH + 1]; /* +1 for NULL */
-static const char *gDefaultConverterName = NULL;
+static char gDefaultConverterNameBuffer[UCNV_MAX_CONVERTER_NAME_LENGTH + 1]; /* +1 for nullptr */
+static const char *gDefaultConverterName = nullptr;
/*
If the default converter is an algorithmic converter, this is the cached value.
@@ -214,7 +214,7 @@ We don't cache a full UConverter and clone it because ucnv_clone doesn't have
less overhead than an algorithmic open. We don't cache non-algorithmic converters
because ucnv_flushCache must be able to unload the default converter and its table.
*/
-static const UConverterSharedData *gDefaultAlgorithmicSharedData = NULL;
+static const UConverterSharedData *gDefaultAlgorithmicSharedData = nullptr;
/* Does gDefaultConverterName have a converter option and require extra parsing? */
static UBool gDefaultConverterContainsOption;
@@ -232,7 +232,7 @@ ucnv_flushAvailableConverterCache() {
gAvailableConverterCount = 0;
if (gAvailableConverters) {
uprv_free((char **)gAvailableConverters);
- gAvailableConverters = NULL;
+ gAvailableConverters = nullptr;
}
gAvailableConvertersInitOnce.reset();
}
@@ -241,28 +241,28 @@ ucnv_flushAvailableConverterCache() {
/* in use by open converters. */
/* Not thread safe. */
/* Not supported API. */
-static UBool U_CALLCONV ucnv_cleanup(void) {
+static UBool U_CALLCONV ucnv_cleanup() {
ucnv_flushCache();
- if (SHARED_DATA_HASHTABLE != NULL && uhash_count(SHARED_DATA_HASHTABLE) == 0) {
+ if (SHARED_DATA_HASHTABLE != nullptr && uhash_count(SHARED_DATA_HASHTABLE) == 0) {
uhash_close(SHARED_DATA_HASHTABLE);
- SHARED_DATA_HASHTABLE = NULL;
+ SHARED_DATA_HASHTABLE = nullptr;
}
/* Isn't called from flushCache because other threads may have preexisting references to the table. */
ucnv_flushAvailableConverterCache();
#if !U_CHARSET_IS_UTF8
- gDefaultConverterName = NULL;
+ gDefaultConverterName = nullptr;
gDefaultConverterNameBuffer[0] = 0;
gDefaultConverterContainsOption = false;
- gDefaultAlgorithmicSharedData = NULL;
+ gDefaultAlgorithmicSharedData = nullptr;
#endif
- return (SHARED_DATA_HASHTABLE == NULL);
+ return (SHARED_DATA_HASHTABLE == nullptr);
}
U_CAPI void U_EXPORT2
-ucnv_enableCleanup(void) {
+ucnv_enableCleanup() {
ucln_common_registerCleanup(UCLN_COMMON_UCNV, ucnv_cleanup);
}
@@ -295,22 +295,22 @@ ucnv_data_unFlattenClone(UConverterLoadArgs *pArgs, UDataMemory *pData, UErrorCo
UConverterType type = (UConverterType)source->conversionType;
if(U_FAILURE(*status))
- return NULL;
+ return nullptr;
if( (uint16_t)type >= UCNV_NUMBER_OF_SUPPORTED_CONVERTER_TYPES ||
- converterData[type] == NULL ||
+ converterData[type] == nullptr ||
!converterData[type]->isReferenceCounted ||
converterData[type]->referenceCounter != 1 ||
source->structSize != sizeof(UConverterStaticData))
{
*status = U_INVALID_TABLE_FORMAT;
- return NULL;
+ return nullptr;
}
data = (UConverterSharedData *)uprv_malloc(sizeof(UConverterSharedData));
- if(data == NULL) {
+ if(data == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
/* copy initial values from the static structure for this type */
@@ -323,11 +323,11 @@ ucnv_data_unFlattenClone(UConverterLoadArgs *pArgs, UDataMemory *pData, UErrorCo
/* fill in fields from the loaded data */
data->dataMemory = (void*)pData; /* for future use */
- if(data->impl->load != NULL) {
+ if(data->impl->load != nullptr) {
data->impl->load(data, pArgs, raw + source->structSize, status);
if(U_FAILURE(*status)) {
uprv_free(data);
- return NULL;
+ return nullptr;
}
}
return data;
@@ -346,16 +346,16 @@ static UConverterSharedData *createConverterFromFile(UConverterLoadArgs *pArgs,
if (U_FAILURE (*err)) {
UTRACE_EXIT_STATUS(*err);
- return NULL;
+ return nullptr;
}
UTRACE_DATA2(UTRACE_OPEN_CLOSE, "load converter %s from package %s", pArgs->name, pArgs->pkg);
- data = udata_openChoice(pArgs->pkg, DATA_TYPE, pArgs->name, isCnvAcceptable, NULL, err);
+ data = udata_openChoice(pArgs->pkg, DATA_TYPE, pArgs->name, isCnvAcceptable, nullptr, err);
if(U_FAILURE(*err))
{
UTRACE_EXIT_STATUS(*err);
- return NULL;
+ return nullptr;
}
sharedData = ucnv_data_unFlattenClone(pArgs, data, err);
@@ -363,7 +363,7 @@ static UConverterSharedData *createConverterFromFile(UConverterLoadArgs *pArgs,
{
udata_close(data);
UTRACE_EXIT_STATUS(*err);
- return NULL;
+ return nullptr;
}
/*
@@ -413,7 +413,7 @@ getAlgorithmicTypeFromName(const char *realName)
}
}
- return NULL;
+ return nullptr;
}
/*
@@ -437,11 +437,11 @@ ucnv_shareConverterData(UConverterSharedData * data)
{
UErrorCode err = U_ZERO_ERROR;
/*Lazy evaluates the Hashtable itself */
- /*void *sanity = NULL;*/
+ /*void *sanity = nullptr;*/
- if (SHARED_DATA_HASHTABLE == NULL)
+ if (SHARED_DATA_HASHTABLE == nullptr)
{
- SHARED_DATA_HASHTABLE = uhash_openSize(uhash_hashChars, uhash_compareChars, NULL,
+ SHARED_DATA_HASHTABLE = uhash_openSize(uhash_hashChars, uhash_compareChars, nullptr,
ucnv_io_countKnownConverters(&err)*UCNV_CACHE_LOAD_FACTOR,
&err);
ucnv_enableCleanup();
@@ -454,7 +454,7 @@ ucnv_shareConverterData(UConverterSharedData * data)
/*
sanity = ucnv_getSharedConverterData (data->staticData->name);
- if(sanity != NULL)
+ if(sanity != nullptr)
{
UCNV_DEBUG_LOG("put:overwrite!",data->staticData->name,sanity);
}
@@ -466,7 +466,7 @@ ucnv_shareConverterData(UConverterSharedData * data)
uhash_put(SHARED_DATA_HASHTABLE,
(void*) data->staticData->name, /* Okay to cast away const as long as
- keyDeleter == NULL */
+ keyDeleter == nullptr */
data,
&err);
UCNV_DEBUG_LOG("put", data->staticData->name,data);
@@ -475,17 +475,17 @@ ucnv_shareConverterData(UConverterSharedData * data)
/* Look up a converter name in the shared data cache. */
/* cnvCacheMutex must be held by the caller to protect the hash table. */
-/* gets the shared data from the SHARED_DATA_HASHTABLE (might return NULL if it isn't there)
+/* gets the shared data from the SHARED_DATA_HASHTABLE (might return nullptr if it isn't there)
* @param name The name of the shared data
* @return the shared data from the SHARED_DATA_HASHTABLE
*/
static UConverterSharedData *
ucnv_getSharedConverterData(const char *name)
{
- /*special case when no Table has yet been created we return NULL */
- if (SHARED_DATA_HASHTABLE == NULL)
+ /*special case when no Table has yet been created we return nullptr */
+ if (SHARED_DATA_HASHTABLE == nullptr)
{
- return NULL;
+ return nullptr;
}
else
{
@@ -519,11 +519,11 @@ ucnv_deleteSharedConverterData(UConverterSharedData * deadSharedData)
return false;
}
- if (deadSharedData->impl->unload != NULL) {
+ if (deadSharedData->impl->unload != nullptr) {
deadSharedData->impl->unload(deadSharedData);
}
- if(deadSharedData->dataMemory != NULL)
+ if(deadSharedData->dataMemory != nullptr)
{
UDataMemory *data = (UDataMemory*)deadSharedData->dataMemory;
udata_close(data);
@@ -537,29 +537,29 @@ ucnv_deleteSharedConverterData(UConverterSharedData * deadSharedData)
/**
* Load a non-algorithmic converter.
- * If pkg==NULL, then this function must be called inside umtx_lock(&cnvCacheMutex).
+ * If pkg==nullptr, then this function must be called inside umtx_lock(&cnvCacheMutex).
*/
UConverterSharedData *
ucnv_load(UConverterLoadArgs *pArgs, UErrorCode *err) {
UConverterSharedData *mySharedConverterData;
- if(err == NULL || U_FAILURE(*err)) {
- return NULL;
+ if(err == nullptr || U_FAILURE(*err)) {
+ return nullptr;
}
- if(pArgs->pkg != NULL && *pArgs->pkg != 0) {
+ if(pArgs->pkg != nullptr && *pArgs->pkg != 0) {
/* application-provided converters are not currently cached */
return createConverterFromFile(pArgs, err);
}
mySharedConverterData = ucnv_getSharedConverterData(pArgs->name);
- if (mySharedConverterData == NULL)
+ if (mySharedConverterData == nullptr)
{
/*Not cached, we need to stream it in from file */
mySharedConverterData = createConverterFromFile(pArgs, err);
- if (U_FAILURE (*err) || (mySharedConverterData == NULL))
+ if (U_FAILURE (*err) || (mySharedConverterData == nullptr))
{
- return NULL;
+ return nullptr;
}
else if (!pArgs->onlyTestIsLoadable)
{
@@ -584,7 +584,7 @@ ucnv_load(UConverterLoadArgs *pArgs, UErrorCode *err) {
*/
U_CAPI void
ucnv_unload(UConverterSharedData *sharedData) {
- if(sharedData != NULL) {
+ if(sharedData != nullptr) {
if (sharedData->referenceCounter > 0) {
sharedData->referenceCounter--;
}
@@ -598,7 +598,7 @@ ucnv_unload(UConverterSharedData *sharedData) {
U_CFUNC void
ucnv_unloadSharedDataIfReady(UConverterSharedData *sharedData)
{
- if(sharedData != NULL && sharedData->isReferenceCounted) {
+ if(sharedData != nullptr && sharedData->isReferenceCounted) {
umtx_lock(&cnvCacheMutex);
ucnv_unload(sharedData);
umtx_unlock(&cnvCacheMutex);
@@ -608,7 +608,7 @@ ucnv_unloadSharedDataIfReady(UConverterSharedData *sharedData)
U_CFUNC void
ucnv_incrementRefCount(UConverterSharedData *sharedData)
{
- if(sharedData != NULL && sharedData->isReferenceCounted) {
+ if(sharedData != nullptr && sharedData->isReferenceCounted) {
umtx_lock(&cnvCacheMutex);
sharedData->referenceCounter++;
umtx_unlock(&cnvCacheMutex);
@@ -715,27 +715,27 @@ ucnv_loadSharedData(const char *converterName,
UErrorCode * err) {
UConverterNamePieces stackPieces;
UConverterLoadArgs stackArgs;
- UConverterSharedData *mySharedConverterData = NULL;
+ UConverterSharedData *mySharedConverterData = nullptr;
UErrorCode internalErrorCode = U_ZERO_ERROR;
UBool mayContainOption = true;
UBool checkForAlgorithmic = true;
if (U_FAILURE (*err)) {
- return NULL;
+ return nullptr;
}
- if(pPieces == NULL) {
- if(pArgs != NULL) {
+ if(pPieces == nullptr) {
+ if(pArgs != nullptr) {
/*
* Bad: We may set pArgs pointers to stackPieces fields
* which will be invalid after this function returns.
*/
*err = U_INTERNAL_PROGRAM_ERROR;
- return NULL;
+ return nullptr;
}
pPieces = &stackPieces;
}
- if(pArgs == NULL) {
+ if(pArgs == nullptr) {
uprv_memset(&stackArgs, 0, sizeof(stackArgs));
stackArgs.size = (int32_t)sizeof(stackArgs);
pArgs = &stackArgs;
@@ -749,17 +749,17 @@ ucnv_loadSharedData(const char *converterName,
pArgs->locale = pPieces->locale;
pArgs->options = pPieces->options;
- /* In case "name" is NULL we want to open the default converter. */
- if (converterName == NULL) {
+ /* In case "name" is nullptr we want to open the default converter. */
+ if (converterName == nullptr) {
#if U_CHARSET_IS_UTF8
pArgs->name = "UTF-8";
return (UConverterSharedData *)converterData[UCNV_UTF8];
#else
/* Call ucnv_getDefaultName first to query the name from the OS. */
pArgs->name = ucnv_getDefaultName();
- if (pArgs->name == NULL) {
+ if (pArgs->name == nullptr) {
*err = U_MISSING_RESOURCE_ERROR;
- return NULL;
+ return nullptr;
}
mySharedConverterData = (UConverterSharedData *)gDefaultAlgorithmicSharedData;
checkForAlgorithmic = false;
@@ -777,12 +777,12 @@ ucnv_loadSharedData(const char *converterName,
parseConverterOptions(converterName, pPieces, pArgs, err);
if (U_FAILURE(*err)) {
/* Very bad name used. */
- return NULL;
+ return nullptr;
}
/* get the canonical converter name */
pArgs->name = ucnv_io_getConverterName(pArgs->name, &mayContainOption, &internalErrorCode);
- if (U_FAILURE(internalErrorCode) || pArgs->name == NULL) {
+ if (U_FAILURE(internalErrorCode) || pArgs->name == nullptr) {
/*
* set the input name in case the converter was added
* without updating the alias table, or when there is no alias table
@@ -802,7 +802,7 @@ ucnv_loadSharedData(const char *converterName,
if (checkForAlgorithmic) {
mySharedConverterData = (UConverterSharedData *)getAlgorithmicTypeFromName(pArgs->name);
}
- if (mySharedConverterData == NULL)
+ if (mySharedConverterData == nullptr)
{
/* it is a data-based converter, get its shared data. */
/* Hold the cnvCacheMutex through the whole process of checking the */
@@ -810,14 +810,14 @@ ucnv_loadSharedData(const char *converterName,
/* to prevent other threads from modifying the cache during the */
/* process. */
pArgs->nestedLoads=1;
- pArgs->pkg=NULL;
+ pArgs->pkg=nullptr;
umtx_lock(&cnvCacheMutex);
mySharedConverterData = ucnv_load(pArgs, err);
umtx_unlock(&cnvCacheMutex);
- if (U_FAILURE (*err) || (mySharedConverterData == NULL))
+ if (U_FAILURE (*err) || (mySharedConverterData == nullptr))
{
- return NULL;
+ return nullptr;
}
}
@@ -851,7 +851,7 @@ ucnv_createConverter(UConverter *myUConverter, const char *converterName, UError
/* exit with error */
UTRACE_EXIT_STATUS(*err);
- return NULL;
+ return nullptr;
}
U_CFUNC UBool
@@ -894,15 +894,15 @@ ucnv_createAlgorithmicConverter(UConverter *myUConverter,
if(type<0 || UCNV_NUMBER_OF_SUPPORTED_CONVERTER_TYPES<=type) {
*err = U_ILLEGAL_ARGUMENT_ERROR;
UTRACE_EXIT_STATUS(U_ILLEGAL_ARGUMENT_ERROR);
- return NULL;
+ return nullptr;
}
sharedData = converterData[type];
- if(sharedData == NULL || sharedData->isReferenceCounted) {
+ if(sharedData == nullptr || sharedData->isReferenceCounted) {
/* not a valid type, or not an algorithmic converter */
*err = U_ILLEGAL_ARGUMENT_ERROR;
UTRACE_EXIT_STATUS(U_ILLEGAL_ARGUMENT_ERROR);
- return NULL;
+ return nullptr;
}
stackArgs.name = "";
@@ -928,7 +928,7 @@ ucnv_createConverterFromPackage(const char *packageName, const char *converterNa
if(U_FAILURE(*err)) {
UTRACE_EXIT_STATUS(*err);
- return NULL;
+ return nullptr;
}
UTRACE_DATA2(UTRACE_OPEN_CLOSE, "open converter %s from package %s", converterName, packageName);
@@ -941,7 +941,7 @@ ucnv_createConverterFromPackage(const char *packageName, const char *converterNa
if (U_FAILURE(*err)) {
/* Very bad name used. */
UTRACE_EXIT_STATUS(*err);
- return NULL;
+ return nullptr;
}
stackArgs.nestedLoads=1;
stackArgs.pkg=packageName;
@@ -951,16 +951,16 @@ ucnv_createConverterFromPackage(const char *packageName, const char *converterNa
if (U_FAILURE(*err)) {
UTRACE_EXIT_STATUS(*err);
- return NULL;
+ return nullptr;
}
/* create the actual converter */
- myUConverter = ucnv_createConverterFromSharedData(NULL, mySharedConverterData, &stackArgs, err);
+ myUConverter = ucnv_createConverterFromSharedData(nullptr, mySharedConverterData, &stackArgs, err);
if (U_FAILURE(*err)) {
ucnv_close(myUConverter);
UTRACE_EXIT_STATUS(*err);
- return NULL;
+ return nullptr;
}
UTRACE_EXIT_PTR_STATUS(myUConverter, *err);
@@ -980,14 +980,14 @@ ucnv_createConverterFromSharedData(UConverter *myUConverter,
ucnv_unloadSharedDataIfReady(mySharedConverterData);
return myUConverter;
}
- if(myUConverter == NULL)
+ if(myUConverter == nullptr)
{
myUConverter = (UConverter *) uprv_malloc (sizeof (UConverter));
- if(myUConverter == NULL)
+ if(myUConverter == nullptr)
{
*err = U_MEMORY_ALLOCATION_ERROR;
ucnv_unloadSharedDataIfReady(mySharedConverterData);
- return NULL;
+ return nullptr;
}
isCopyLocal = false;
} else {
@@ -1013,12 +1013,12 @@ ucnv_createConverterFromSharedData(UConverter *myUConverter,
myUConverter->toUCallbackReason = UCNV_ILLEGAL; /* default reason to invoke (*fromCharErrorBehaviour) */
}
- if(mySharedConverterData->impl->open != NULL) {
+ if(mySharedConverterData->impl->open != nullptr) {
mySharedConverterData->impl->open(myUConverter, pArgs, err);
if(U_FAILURE(*err) && !pArgs->onlyTestIsLoadable) {
/* don't ucnv_close() if onlyTestIsLoadable because not fully initialized */
ucnv_close(myUConverter);
- return NULL;
+ return nullptr;
}
}
@@ -1030,7 +1030,7 @@ ucnv_createConverterFromSharedData(UConverter *myUConverter,
U_CAPI int32_t U_EXPORT2
ucnv_flushCache ()
{
- UConverterSharedData *mySharedData = NULL;
+ UConverterSharedData *mySharedData = nullptr;
int32_t pos;
int32_t tableDeletedNum = 0;
const UHashElement *e;
@@ -1045,7 +1045,7 @@ ucnv_flushCache ()
/*if shared data hasn't even been lazy evaluated yet
* return 0
*/
- if (SHARED_DATA_HASHTABLE == NULL) {
+ if (SHARED_DATA_HASHTABLE == nullptr) {
UTRACE_EXIT_VALUE((int32_t)0);
return 0;
}
@@ -1072,7 +1072,7 @@ ucnv_flushCache ()
do {
remaining = 0;
pos = UHASH_FIRST;
- while ((e = uhash_nextElement (SHARED_DATA_HASHTABLE, &pos)) != NULL)
+ while ((e = uhash_nextElement (SHARED_DATA_HASHTABLE, &pos)) != nullptr)
{
mySharedData = (UConverterSharedData *) e->value.pointer;
/*deletes only if reference counter == 0 */
@@ -1102,7 +1102,7 @@ ucnv_flushCache ()
static void U_CALLCONV initAvailableConvertersList(UErrorCode &errCode) {
U_ASSERT(gAvailableConverterCount == 0);
- U_ASSERT(gAvailableConverters == NULL);
+ U_ASSERT(gAvailableConverters == nullptr);
ucnv_enableCleanup();
UEnumeration *allConvEnum = ucnv_openAllNames(&errCode);
@@ -1121,13 +1121,13 @@ static void U_CALLCONV initAvailableConvertersList(UErrorCode &errCode) {
/* Open the default converter to make sure that it has first dibs in the hash table. */
UErrorCode localStatus = U_ZERO_ERROR;
UConverter tempConverter;
- ucnv_close(ucnv_createConverter(&tempConverter, NULL, &localStatus));
+ ucnv_close(ucnv_createConverter(&tempConverter, nullptr, &localStatus));
gAvailableConverterCount = 0;
for (int32_t idx = 0; idx < allConverterCount; idx++) {
localStatus = U_ZERO_ERROR;
- const char *converterName = uenum_next(allConvEnum, NULL, &localStatus);
+ const char *converterName = uenum_next(allConvEnum, nullptr, &localStatus);
if (ucnv_canCreateConverter(converterName, &localStatus)) {
gAvailableConverters[gAvailableConverterCount++] = converterName;
}
@@ -1158,7 +1158,7 @@ ucnv_bld_getAvailableConverter(uint16_t n, UErrorCode *pErrorCode) {
}
*pErrorCode = U_INDEX_OUTOFBOUNDS_ERROR;
}
- return NULL;
+ return nullptr;
}
/* default converter name --------------------------------------------------- */
@@ -1181,7 +1181,7 @@ internalSetName(const char *name, UErrorCode *status) {
UConverterNamePieces stackPieces;
UConverterLoadArgs stackArgs=UCNV_LOAD_ARGS_INITIALIZER;
int32_t length=(int32_t)(uprv_strlen(name));
- UBool containsOption = (UBool)(uprv_strchr(name, UCNV_OPTION_SEP_CHAR) != NULL);
+ UBool containsOption = (UBool)(uprv_strchr(name, UCNV_OPTION_SEP_CHAR) != nullptr);
const UConverterSharedData *algorithmicSharedData;
stackArgs.name = name;
@@ -1240,22 +1240,22 @@ ucnv_getDefaultName() {
icu::Mutex lock(&cnvCacheMutex);
name = gDefaultConverterName;
}
- if(name==NULL) {
+ if(name==nullptr) {
UErrorCode errorCode = U_ZERO_ERROR;
- UConverter *cnv = NULL;
+ UConverter *cnv = nullptr;
name = uprv_getDefaultCodepage();
/* if the name is there, test it out and get the canonical name with options */
- if(name != NULL) {
+ if(name != nullptr) {
cnv = ucnv_open(name, &errorCode);
- if(U_SUCCESS(errorCode) && cnv != NULL) {
+ if(U_SUCCESS(errorCode) && cnv != nullptr) {
name = ucnv_getName(cnv, &errorCode);
}
}
- if(name == NULL || name[0] == 0
- || U_FAILURE(errorCode) || cnv == NULL
+ if(name == nullptr || name[0] == 0
+ || U_FAILURE(errorCode) || cnv == nullptr
|| uprv_strlen(name)>=sizeof(gDefaultConverterNameBuffer))
{
/* Panic time, let's use a fallback. */
@@ -1288,21 +1288,21 @@ See internalSetName or the API reference for details.
*/
U_CAPI void U_EXPORT2
ucnv_setDefaultName(const char *converterName) {
- if(converterName==NULL) {
+ if(converterName==nullptr) {
/* reset to the default codepage */
- gDefaultConverterName=NULL;
+ gDefaultConverterName=nullptr;
} else {
UErrorCode errorCode = U_ZERO_ERROR;
- UConverter *cnv = NULL;
- const char *name = NULL;
+ UConverter *cnv = nullptr;
+ const char *name = nullptr;
/* if the name is there, test it out and get the canonical name with options */
cnv = ucnv_open(converterName, &errorCode);
- if(U_SUCCESS(errorCode) && cnv != NULL) {
+ if(U_SUCCESS(errorCode) && cnv != nullptr) {
name = ucnv_getName(cnv, &errorCode);
}
- if(U_SUCCESS(errorCode) && name!=NULL) {
+ if(U_SUCCESS(errorCode) && name!=nullptr) {
internalSetName(name, &errorCode);
}
/* else this converter is bad to use. Don't change it to a bad value. */
@@ -1353,7 +1353,7 @@ ucnv_swap(const UDataSwapper *ds,
/* udata_swapDataHeader checks the arguments */
headerSize=udata_swapDataHeader(ds, inData, length, outData, pErrorCode);
- if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
+ if(pErrorCode==nullptr || U_FAILURE(*pErrorCode)) {
return 0;
}
@@ -1376,7 +1376,7 @@ ucnv_swap(const UDataSwapper *ds,
}
inBytes=(const uint8_t *)inData+headerSize;
- outBytes=(uint8_t *)outData+headerSize;
+ outBytes=(outData == nullptr) ? nullptr : (uint8_t *)outData+headerSize;
/* read the initial UConverterStaticData structure after the UDataInfo header */
inStaticData=(const UConverterStaticData *)inBytes;
@@ -1416,7 +1416,7 @@ ucnv_swap(const UDataSwapper *ds,
}
inBytes+=staticDataSize;
- outBytes+=staticDataSize;
+ if (outBytes != nullptr) outBytes+=staticDataSize;
if(length>=0) {
length-=(int32_t)staticDataSize;
}
@@ -1509,7 +1509,7 @@ ucnv_swap(const UDataSwapper *ds,
}
/* avoid compiler warnings - not otherwise necessary, and the value does not matter */
- inExtIndexes=NULL;
+ inExtIndexes=nullptr;
} else {
/* there is extension data after the base data, see ucnv_ext.h */
if(length>=0 && length<(extOffset+UCNV_EXT_INDEXES_MIN_LENGTH*4)) {