diff options
author | romankoshelev <romankoshelev@yandex-team.com> | 2023-08-14 19:51:50 +0300 |
---|---|---|
committer | romankoshelev <romankoshelev@yandex-team.com> | 2023-08-15 01:24:11 +0300 |
commit | cfcd865e05c0d0525ea27d1e153a043b32a85138 (patch) | |
tree | 68d3b3b25271e8a4998505897a269ff7ce119b76 /contrib/libs/icu/io | |
parent | ccb790c507bd5e8ffe2ef9886ce5ee0a7ce22a15 (diff) | |
download | ydb-cfcd865e05c0d0525ea27d1e153a043b32a85138.tar.gz |
Update ICU to 73.2
Diffstat (limited to 'contrib/libs/icu/io')
-rw-r--r-- | contrib/libs/icu/io/locbund.cpp | 28 | ||||
-rw-r--r-- | contrib/libs/icu/io/sprintf.cpp | 46 | ||||
-rw-r--r-- | contrib/libs/icu/io/sscanf.cpp | 30 | ||||
-rw-r--r-- | contrib/libs/icu/io/ucln_io.cpp | 6 | ||||
-rw-r--r-- | contrib/libs/icu/io/ufile.cpp | 62 | ||||
-rw-r--r-- | contrib/libs/icu/io/ufmt_cmn.cpp | 28 | ||||
-rw-r--r-- | contrib/libs/icu/io/uprintf.cpp | 34 | ||||
-rw-r--r-- | contrib/libs/icu/io/uprntf_p.cpp | 156 | ||||
-rw-r--r-- | contrib/libs/icu/io/uscanf.cpp | 10 | ||||
-rw-r--r-- | contrib/libs/icu/io/uscanf_p.cpp | 144 | ||||
-rw-r--r-- | contrib/libs/icu/io/ustdio.cpp | 120 | ||||
-rw-r--r-- | contrib/libs/icu/io/ustream.cpp | 24 |
12 files changed, 355 insertions, 333 deletions
diff --git a/contrib/libs/icu/io/locbund.cpp b/contrib/libs/icu/io/locbund.cpp index 46c97bc043..3f6d6309ac 100644 --- a/contrib/libs/icu/io/locbund.cpp +++ b/contrib/libs/icu/io/locbund.cpp @@ -35,13 +35,13 @@ static UNumberFormat *gPosixNumberFormat[ULOCALEBUNDLE_NUMBERFORMAT_COUNT]; U_CDECL_BEGIN -static UBool U_CALLCONV locbund_cleanup(void) { +static UBool U_CALLCONV locbund_cleanup() { int32_t style; for (style = 0; style < ULOCALEBUNDLE_NUMBERFORMAT_COUNT; style++) { unum_close(gPosixNumberFormat[style]); - gPosixNumberFormat[style] = NULL; + gPosixNumberFormat[style] = nullptr; } - return TRUE; + return true; } U_CDECL_END @@ -49,17 +49,17 @@ static inline UNumberFormat * copyInvariantFormatter(ULocaleBundle *result, UNum U_NAMESPACE_USE static UMutex gLock; Mutex lock(&gLock); - if (result->fNumberFormat[style-1] == NULL) { - if (gPosixNumberFormat[style-1] == NULL) { + if (result->fNumberFormat[style-1] == nullptr) { + if (gPosixNumberFormat[style-1] == nullptr) { UErrorCode status = U_ZERO_ERROR; - UNumberFormat *formatAlias = unum_open(style, NULL, 0, "en_US_POSIX", NULL, &status); + UNumberFormat *formatAlias = unum_open(style, nullptr, 0, "en_US_POSIX", nullptr, &status); if (U_SUCCESS(status)) { gPosixNumberFormat[style-1] = formatAlias; ucln_io_registerCleanup(UCLN_IO_LOCBUND, locbund_cleanup); } } /* Copy the needed formatter. */ - if (gPosixNumberFormat[style-1] != NULL) { + if (gPosixNumberFormat[style-1] != nullptr) { UErrorCode status = U_ZERO_ERROR; result->fNumberFormat[style-1] = unum_clone(gPosixNumberFormat[style-1], &status); } @@ -75,7 +75,7 @@ u_locbund_init(ULocaleBundle *result, const char *loc) if(result == 0) return 0; - if (loc == NULL) { + if (loc == nullptr) { loc = uloc_getDefault(); } @@ -124,11 +124,11 @@ u_locbund_clone(const ULocaleBundle *bundle) if (result->fNumberFormat[styleIdx]) { result->fNumberFormat[styleIdx] = unum_clone(bundle->fNumberFormat[styleIdx], &status); if (U_FAILURE(status)) { - result->fNumberFormat[styleIdx] = NULL; + result->fNumberFormat[styleIdx] = nullptr; } } else { - result->fNumberFormat[styleIdx] = NULL; + result->fNumberFormat[styleIdx] = nullptr; } } result->fDateFormat = (bundle->fDateFormat == 0 ? 0 : @@ -159,19 +159,19 @@ u_locbund_close(ULocaleBundle *bundle) U_CAPI UNumberFormat * u_locbund_getNumberFormat(ULocaleBundle *bundle, UNumberFormatStyle style) { - UNumberFormat *formatAlias = NULL; + UNumberFormat *formatAlias = nullptr; if (style > UNUM_IGNORE) { formatAlias = bundle->fNumberFormat[style-1]; - if (formatAlias == NULL) { + if (formatAlias == nullptr) { if (bundle->isInvariantLocale) { formatAlias = copyInvariantFormatter(bundle, style); } else { UErrorCode status = U_ZERO_ERROR; - formatAlias = unum_open(style, NULL, 0, bundle->fLocale, NULL, &status); + formatAlias = unum_open(style, nullptr, 0, bundle->fLocale, nullptr, &status); if (U_FAILURE(status)) { unum_close(formatAlias); - formatAlias = NULL; + formatAlias = nullptr; } else { bundle->fNumberFormat[style-1] = formatAlias; diff --git a/contrib/libs/icu/io/sprintf.cpp b/contrib/libs/icu/io/sprintf.cpp index 3a593abb48..48d9bcc27c 100644 --- a/contrib/libs/icu/io/sprintf.cpp +++ b/contrib/libs/icu/io/sprintf.cpp @@ -37,10 +37,16 @@ /* u_minstrncpy copies the minimum number of code units of (count or output->available) */ static int32_t u_sprintf_write(void *context, - const UChar *str, + const char16_t *str, int32_t count) { u_localized_print_string *output = (u_localized_print_string *)context; + + /* just calculating buffer size */ + if (output->str == 0) { + return count; + } + int32_t size = ufmt_min(count, output->available); u_strncpy(output->str + (output->len - output->available), str, size); @@ -51,13 +57,19 @@ u_sprintf_write(void *context, static int32_t u_sprintf_pad_and_justify(void *context, const u_printf_spec_info *info, - const UChar *result, + const char16_t *result, int32_t resultLen) { u_localized_print_string *output = (u_localized_print_string *)context; int32_t written = 0; int32_t lengthOfResult = resultLen; + /* just calculating buffer size */ + if (output->str == 0 && + info->fWidth != -1 && resultLen < info->fWidth) { + return info->fWidth; + } + resultLen = ufmt_min(resultLen, output->available); /* pad and justify, if needed */ @@ -100,7 +112,7 @@ u_sprintf_pad_and_justify(void *context, } U_CAPI int32_t U_EXPORT2 -u_sprintf(UChar *buffer, +u_sprintf(char16_t *buffer, const char *patternSpecification, ... ) { @@ -115,8 +127,8 @@ u_sprintf(UChar *buffer, } U_CAPI int32_t U_EXPORT2 -u_sprintf_u(UChar *buffer, - const UChar *patternSpecification, +u_sprintf_u(char16_t *buffer, + const char16_t *patternSpecification, ... ) { va_list ap; @@ -130,7 +142,7 @@ u_sprintf_u(UChar *buffer, } U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ -u_vsprintf(UChar *buffer, +u_vsprintf(char16_t *buffer, const char *patternSpecification, va_list ap) { @@ -138,7 +150,7 @@ u_vsprintf(UChar *buffer, } U_CAPI int32_t U_EXPORT2 -u_snprintf(UChar *buffer, +u_snprintf(char16_t *buffer, int32_t count, const char *patternSpecification, ... ) @@ -154,9 +166,9 @@ u_snprintf(UChar *buffer, } U_CAPI int32_t U_EXPORT2 -u_snprintf_u(UChar *buffer, +u_snprintf_u(char16_t *buffer, int32_t count, - const UChar *patternSpecification, + const char16_t *patternSpecification, ... ) { va_list ap; @@ -170,19 +182,19 @@ u_snprintf_u(UChar *buffer, } U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ -u_vsnprintf(UChar *buffer, +u_vsnprintf(char16_t *buffer, int32_t count, const char *patternSpecification, va_list ap) { int32_t written; - UChar *pattern; - UChar patBuffer[UFMT_DEFAULT_BUFFER_SIZE]; + char16_t *pattern; + char16_t patBuffer[UFMT_DEFAULT_BUFFER_SIZE]; int32_t size = (int32_t)strlen(patternSpecification) + 1; /* convert from the default codepage to Unicode */ if (size >= (int32_t)MAX_UCHAR_BUFFER_SIZE(patBuffer)) { - pattern = (UChar *)uprv_malloc(size * sizeof(UChar)); + pattern = (char16_t *)uprv_malloc(size * sizeof(char16_t)); if(pattern == 0) { return 0; } @@ -204,8 +216,8 @@ u_vsnprintf(UChar *buffer, } U_CAPI int32_t U_EXPORT2 -u_vsprintf_u(UChar *buffer, - const UChar *patternSpecification, +u_vsprintf_u(char16_t *buffer, + const char16_t *patternSpecification, va_list ap) { return u_vsnprintf_u(buffer, INT32_MAX, patternSpecification, ap); @@ -217,9 +229,9 @@ static const u_printf_stream_handler g_sprintf_stream_handler = { }; U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ -u_vsnprintf_u(UChar *buffer, +u_vsnprintf_u(char16_t *buffer, int32_t count, - const UChar *patternSpecification, + const char16_t *patternSpecification, va_list ap) { int32_t written = 0; /* haven't written anything yet */ diff --git a/contrib/libs/icu/io/sscanf.cpp b/contrib/libs/icu/io/sscanf.cpp index 47c0bace27..8940127eb1 100644 --- a/contrib/libs/icu/io/sscanf.cpp +++ b/contrib/libs/icu/io/sscanf.cpp @@ -33,7 +33,7 @@ U_CAPI int32_t U_EXPORT2 -u_sscanf(const UChar *buffer, +u_sscanf(const char16_t *buffer, const char *patternSpecification, ... ) { @@ -48,8 +48,8 @@ u_sscanf(const UChar *buffer, } U_CAPI int32_t U_EXPORT2 -u_sscanf_u(const UChar *buffer, - const UChar *patternSpecification, +u_sscanf_u(const char16_t *buffer, + const char16_t *patternSpecification, ... ) { va_list ap; @@ -63,18 +63,18 @@ u_sscanf_u(const UChar *buffer, } U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ -u_vsscanf(const UChar *buffer, +u_vsscanf(const char16_t *buffer, const char *patternSpecification, va_list ap) { int32_t converted; - UChar *pattern; - UChar patBuffer[UFMT_DEFAULT_BUFFER_SIZE]; + char16_t *pattern; + char16_t patBuffer[UFMT_DEFAULT_BUFFER_SIZE]; int32_t size = (int32_t)uprv_strlen(patternSpecification) + 1; /* convert from the default codepage to Unicode */ if (size >= (int32_t)MAX_UCHAR_BUFFER_SIZE(patBuffer)) { - pattern = (UChar *)uprv_malloc(size * sizeof(UChar)); + pattern = (char16_t *)uprv_malloc(size * sizeof(char16_t)); if(pattern == 0) { return 0; } @@ -96,22 +96,22 @@ u_vsscanf(const UChar *buffer, } U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ -u_vsscanf_u(const UChar *buffer, - const UChar *patternSpecification, +u_vsscanf_u(const char16_t *buffer, + const char16_t *patternSpecification, va_list ap) { int32_t converted; UFILE inStr; - inStr.fConverter = NULL; - inStr.fFile = NULL; - inStr.fOwnFile = FALSE; + inStr.fConverter = nullptr; + inStr.fFile = nullptr; + inStr.fOwnFile = false; #if !UCONFIG_NO_TRANSLITERATION - inStr.fTranslit = NULL; + inStr.fTranslit = nullptr; #endif inStr.fUCBuffer[0] = 0; - inStr.str.fBuffer = (UChar *)buffer; - inStr.str.fPos = (UChar *)buffer; + inStr.str.fBuffer = (char16_t *)buffer; + inStr.str.fPos = (char16_t *)buffer; inStr.str.fLimit = buffer + u_strlen(buffer); if(u_locbund_init(&inStr.str.fBundle, "en_US_POSIX") == 0) { diff --git a/contrib/libs/icu/io/ucln_io.cpp b/contrib/libs/icu/io/ucln_io.cpp index c1307b5d97..e2ddb35870 100644 --- a/contrib/libs/icu/io/ucln_io.cpp +++ b/contrib/libs/icu/io/ucln_io.cpp @@ -36,7 +36,7 @@ static const char copyright[] = U_COPYRIGHT_STRING; static cleanupFunc *gCleanupFunctions[UCLN_IO_COUNT]; -static UBool U_CALLCONV io_cleanup(void) +static UBool U_CALLCONV io_cleanup() { int32_t libType = UCLN_IO_START; @@ -45,13 +45,13 @@ static UBool U_CALLCONV io_cleanup(void) if (gCleanupFunctions[libType]) { gCleanupFunctions[libType](); - gCleanupFunctions[libType] = NULL; + gCleanupFunctions[libType] = nullptr; } } #if !UCLN_NO_AUTO_CLEANUP && (defined(UCLN_AUTO_ATEXIT) || defined(UCLN_AUTO_LOCAL)) ucln_unRegisterAutomaticCleanup(); #endif - return TRUE; + return true; } void ucln_io_registerCleanup(ECleanupIOType type, diff --git a/contrib/libs/icu/io/ufile.cpp b/contrib/libs/icu/io/ufile.cpp index 607601935c..9e87e4058e 100644 --- a/contrib/libs/icu/io/ufile.cpp +++ b/contrib/libs/icu/io/ufile.cpp @@ -21,11 +21,18 @@ */ #include "unicode/platform.h" -#if defined(__GNUC__) && !defined(__clang__) && defined(__STRICT_ANSI__) -// g++, fileno isn't defined if __STRICT_ANSI__ is defined. -// clang fails to compile the <string> header unless __STRICT_ANSI__ is defined. -// __GNUC__ is set by both gcc and clang. -#undef __STRICT_ANSI__ +#if U_PLATFORM == U_PF_CYGWIN && defined(__STRICT_ANSI__) +/* GCC on cygwin (not msys2) with -std=c++11 or newer has stopped defining fileno, + unless gcc extensions are enabled (-std=gnu11). + fileno is POSIX, but is not standard ANSI C. + It has always been a GCC extension, which everyone used until recently. + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=40278#c7 + + For cygwin/mingw, the FILE* pointer isn't opaque, so we can just use a simple macro. + Suggested fix from: https://github.com/gabime/spdlog/issues/1581#issuecomment-650323251 +*/ +#define _fileno(__F) ((__F)->_file) +#define fileno(__F) _fileno(__F) #endif #include "locmap.h" @@ -45,7 +52,10 @@ #include "cmemory.h" #if U_PLATFORM_USES_ONLY_WIN32_API && !defined(fileno) -/* Windows likes to rename Unix-like functions */ +/* We will just create an alias to Microsoft's implementation, + which is prefixed with _ as they deprecated non-ansi-standard POSIX function names. + https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/posix-fileno?view=msvc-170 +*/ #define fileno _fileno #endif @@ -58,11 +68,11 @@ finit_owner(FILE *f, { UErrorCode status = U_ZERO_ERROR; UFILE *result; - if(f == NULL) { + if(f == nullptr) { return 0; } result = (UFILE*) uprv_malloc(sizeof(UFILE)); - if(result == NULL) { + if(result == nullptr) { return 0; } @@ -84,10 +94,10 @@ finit_owner(FILE *f, #endif /* If the codepage is not "" use the ucnv_open default behavior */ - if(codepage == NULL || *codepage != '\0') { + if(codepage == nullptr || *codepage != '\0') { result->fConverter = ucnv_open(codepage, &status); } - /* else result->fConverter is already memset'd to NULL. */ + /* else result->fConverter is already memset'd to nullptr. */ if(U_SUCCESS(status)) { result->fOwnFile = takeOwnership; @@ -98,7 +108,7 @@ finit_owner(FILE *f, #endif /* DO NOT fclose here!!!!!! */ uprv_free(result); - result = NULL; + result = nullptr; } return result; @@ -109,7 +119,7 @@ u_finit(FILE *f, const char *locale, const char *codepage) { - return finit_owner(f, locale, codepage, FALSE); + return finit_owner(f, locale, codepage, false); } U_CAPI UFILE* U_EXPORT2 @@ -117,7 +127,7 @@ u_fadopt(FILE *f, const char *locale, const char *codepage) { - return finit_owner(f, locale, codepage, TRUE); + return finit_owner(f, locale, codepage, true); } U_CAPI UFILE* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ @@ -132,7 +142,7 @@ u_fopen(const char *filename, return 0; } - result = finit_owner(systemFile, locale, codepage, TRUE); + result = finit_owner(systemFile, locale, codepage, true); if (!result) { /* Something bad happened. @@ -158,7 +168,7 @@ u_fopen(const char *filename, #endif U_CAPI UFILE* U_EXPORT2 -u_fopen_u(const UChar *filename, +u_fopen_u(const char16_t *filename, const char *perm, const char *locale, const char *codepage) @@ -186,14 +196,14 @@ u_fopen_u(const UChar *filename, wchar_t wperm[40] = {}; size_t retVal; mbstowcs_s(&retVal, wperm, UPRV_LENGTHOF(wperm), perm, _TRUNCATE); - FILE *systemFile = _wfopen(reinterpret_cast<const wchar_t *>(filename), wperm); // may return NULL for long filename + FILE *systemFile = _wfopen(reinterpret_cast<const wchar_t *>(filename), wperm); // may return nullptr for long filename if (systemFile) { - result = finit_owner(systemFile, locale, codepage, TRUE); + result = finit_owner(systemFile, locale, codepage, true); } if (!result && systemFile) { /* Something bad happened. Maybe the converter couldn't be opened. - Bu do not fclose(systemFile) if systemFile is NULL. */ + Bu do not fclose(systemFile) if systemFile is nullptr. */ fclose(systemFile); } } @@ -206,20 +216,20 @@ u_fopen_u(const UChar *filename, U_CAPI UFILE* U_EXPORT2 -u_fstropen(UChar *stringBuf, +u_fstropen(char16_t *stringBuf, int32_t capacity, const char *locale) { UFILE *result; if (capacity < 0) { - return NULL; + return nullptr; } result = (UFILE*) uprv_malloc(sizeof(UFILE)); /* Null pointer test */ - if (result == NULL) { - return NULL; /* Just get out. */ + if (result == nullptr) { + return nullptr; /* Just get out. */ } uprv_memset(result, 0, sizeof(UFILE)); result->str.fBuffer = stringBuf; @@ -242,11 +252,11 @@ U_CAPI UBool U_EXPORT2 u_feof(UFILE *f) { UBool endOfBuffer; - if (f == NULL) { - return TRUE; + if (f == nullptr) { + return true; } endOfBuffer = (UBool)(f->str.fPos >= f->str.fLimit); - if (f->fFile != NULL) { + if (f->fFile != nullptr) { return endOfBuffer && feof(f->fFile); } return endOfBuffer; @@ -329,7 +339,7 @@ U_CAPI const char* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov u_fgetcodepage(UFILE *file) { UErrorCode status = U_ZERO_ERROR; - const char *codepage = NULL; + const char *codepage = nullptr; if (file->fConverter) { codepage = ucnv_getName(file->fConverter, &status); diff --git a/contrib/libs/icu/io/ufmt_cmn.cpp b/contrib/libs/icu/io/ufmt_cmn.cpp index a475175f37..3d8f6413d8 100644 --- a/contrib/libs/icu/io/ufmt_cmn.cpp +++ b/contrib/libs/icu/io/ufmt_cmn.cpp @@ -38,7 +38,7 @@ #define UPPERCASE_Z 0x005A int -ufmt_digitvalue(UChar c) +ufmt_digitvalue(char16_t c) { if( ((c>=DIGIT_0)&&(c<=DIGIT_9)) || ((c>=LOWERCASE_A)&&(c<=LOWERCASE_Z)) || @@ -53,7 +53,7 @@ ufmt_digitvalue(UChar c) } UBool -ufmt_isdigit(UChar c, +ufmt_isdigit(char16_t c, int32_t radix) { int digitVal = ufmt_digitvalue(c); @@ -65,7 +65,7 @@ ufmt_isdigit(UChar c, #define TO_LC_DIGIT(a) a <= 9 ? (DIGIT_0 + a) : (0x0057 + a) void -ufmt_64tou(UChar *buffer, +ufmt_64tou(char16_t *buffer, int32_t *len, uint64_t value, uint8_t radix, @@ -74,12 +74,12 @@ ufmt_64tou(UChar *buffer, { int32_t length = 0; uint32_t digit; - UChar *left, *right, temp; + char16_t *left, *right, temp; do { digit = (uint32_t)(value % radix); value = value / radix; - buffer[length++] = (UChar)(uselower ? TO_LC_DIGIT(digit) + buffer[length++] = (char16_t)(uselower ? TO_LC_DIGIT(digit) : TO_UC_DIGIT(digit)); } while(value); @@ -102,7 +102,7 @@ ufmt_64tou(UChar *buffer, } void -ufmt_ptou(UChar *buffer, +ufmt_ptou(char16_t *buffer, int32_t *len, void *value, UBool uselower) @@ -134,11 +134,11 @@ ufmt_ptou(UChar *buffer, } int64_t -ufmt_uto64(const UChar *buffer, +ufmt_uto64(const char16_t *buffer, int32_t *len, int8_t radix) { - const UChar *limit; + const char16_t *limit; int32_t count; uint64_t result; @@ -165,7 +165,7 @@ ufmt_uto64(const UChar *buffer, #define NIBBLE_PER_BYTE 2 void * -ufmt_utop(const UChar *buffer, +ufmt_utop(const char16_t *buffer, int32_t *len) { int32_t count, resultIdx, incVal, offset; @@ -178,7 +178,7 @@ ufmt_utop(const UChar *buffer, /* initialize variables */ count = 0; offset = 0; - result.ptr = NULL; + result.ptr = nullptr; /* Skip the leading zeros */ while(buffer[count] == DIGIT_0 || u_isspace(buffer[count])) { @@ -223,11 +223,11 @@ ufmt_utop(const UChar *buffer, return result.ptr; } -UChar* +char16_t* ufmt_defaultCPToUnicode(const char *s, int32_t sSize, - UChar *target, int32_t tSize) + char16_t *target, int32_t tSize) { - UChar *alias; + char16_t *alias; UErrorCode status = U_ZERO_ERROR; UConverter *defConverter = u_getDefaultConverter(&status); @@ -243,7 +243,7 @@ ufmt_defaultCPToUnicode(const char *s, int32_t sSize, alias = target; ucnv_toUnicode(defConverter, &alias, alias + tSize, &s, s + sSize - 1, - NULL, TRUE, &status); + nullptr, true, &status); /* add the null terminator */ diff --git a/contrib/libs/icu/io/uprintf.cpp b/contrib/libs/icu/io/uprintf.cpp index 3c9effaada..7effa61993 100644 --- a/contrib/libs/icu/io/uprintf.cpp +++ b/contrib/libs/icu/io/uprintf.cpp @@ -40,22 +40,22 @@ U_NAMESPACE_USE -static UFILE *gStdOut = NULL; -static UInitOnce gStdOutInitOnce = U_INITONCE_INITIALIZER; +static UFILE *gStdOut = nullptr; +static UInitOnce gStdOutInitOnce {}; -static UBool U_CALLCONV uprintf_cleanup(void) +static UBool U_CALLCONV uprintf_cleanup() { - if (gStdOut != NULL) { + if (gStdOut != nullptr) { u_fclose(gStdOut); - gStdOut = NULL; + gStdOut = nullptr; } gStdOutInitOnce.reset(); - return TRUE; + return true; } static void U_CALLCONV u_stdout_init() { - U_ASSERT(gStdOut == NULL); - gStdOut = u_finit(stdout, NULL, NULL); + U_ASSERT(gStdOut == nullptr); + gStdOut = u_finit(stdout, nullptr, nullptr); ucln_io_registerCleanup(UCLN_IO_PRINTF, &uprintf_cleanup); } @@ -68,7 +68,7 @@ u_get_stdout() static int32_t U_EXPORT2 u_printf_write(void *context, - const UChar *str, + const char16_t *str, int32_t count) { return u_file_write(str, count, (UFILE *)context); @@ -77,7 +77,7 @@ u_printf_write(void *context, static int32_t u_printf_pad_and_justify(void *context, const u_printf_spec_info *info, - const UChar *result, + const char16_t *result, int32_t resultLen) { UFILE *output = (UFILE *)context; @@ -138,7 +138,7 @@ u_printf(const char *patternSpecification, U_CAPI int32_t U_EXPORT2 u_fprintf_u( UFILE *f, - const UChar *patternSpecification, + const char16_t *patternSpecification, ... ) { va_list ap; @@ -152,7 +152,7 @@ u_fprintf_u( UFILE *f, } U_CAPI int32_t U_EXPORT2 -u_printf_u(const UChar *patternSpecification, +u_printf_u(const char16_t *patternSpecification, ...) { va_list ap; @@ -169,13 +169,13 @@ u_vfprintf( UFILE *f, va_list ap) { int32_t count; - UChar *pattern; - UChar buffer[UFMT_DEFAULT_BUFFER_SIZE]; + char16_t *pattern; + char16_t buffer[UFMT_DEFAULT_BUFFER_SIZE]; size_t size = strlen(patternSpecification) + 1; /* convert from the default codepage to Unicode */ if (size >= MAX_UCHAR_BUFFER_SIZE(buffer)) { - pattern = (UChar *)uprv_malloc(size * sizeof(UChar)); + pattern = (char16_t *)uprv_malloc(size * sizeof(char16_t)); if(pattern == 0) { return 0; } @@ -203,13 +203,13 @@ static const u_printf_stream_handler g_stream_handler = { U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ u_vfprintf_u( UFILE *f, - const UChar *patternSpecification, + const char16_t *patternSpecification, va_list ap) { int32_t written = 0; /* haven't written anything yet */ /* parse and print the whole format string */ - u_printf_parse(&g_stream_handler, patternSpecification, f, NULL, &f->str.fBundle, &written, ap); + u_printf_parse(&g_stream_handler, patternSpecification, f, nullptr, &f->str.fBundle, &written, ap); /* return # of UChars written */ return written; diff --git a/contrib/libs/icu/io/uprntf_p.cpp b/contrib/libs/icu/io/uprntf_p.cpp index 1fbaf06c95..399d2dc751 100644 --- a/contrib/libs/icu/io/uprntf_p.cpp +++ b/contrib/libs/icu/io/uprntf_p.cpp @@ -71,7 +71,7 @@ #define UFMT_USTRING {ufmt_ustring, u_printf_ustring_handler} -#define UFMT_EMPTY {ufmt_empty, NULL} +#define UFMT_EMPTY {ufmt_empty, nullptr} /** * A u_printf handler function. @@ -115,15 +115,15 @@ typedef struct u_printf_spec { #define UPRINTF_BUFFER_SIZE 1024 #define UPRINTF_SYMBOL_BUFFER_SIZE 8 -static const UChar gNullStr[] = {0x28, 0x6E, 0x75, 0x6C, 0x6C, 0x29, 0}; /* "(null)" */ -static const UChar gSpaceStr[] = {0x20, 0}; /* " " */ +static const char16_t gNullStr[] = {0x28, 0x6E, 0x75, 0x6C, 0x6C, 0x29, 0}; /* "(null)" */ +static const char16_t gSpaceStr[] = {0x20, 0}; /* " " */ /* Sets the sign of a format based on u_printf_spec_info */ /* TODO: Is setting the prefix symbol to a positive sign a good idea in all locales? */ static void u_printf_set_sign(UNumberFormat *format, const u_printf_spec_info *info, - UChar *prefixBuffer, + char16_t *prefixBuffer, int32_t *prefixBufLen, UErrorCode *status) { @@ -139,7 +139,7 @@ u_printf_set_sign(UNumberFormat *format, unum_setTextAttribute(format, UNUM_POSITIVE_PREFIX, gSpaceStr, 1, status); } else { - UChar plusSymbol[UPRINTF_SYMBOL_BUFFER_SIZE]; + char16_t plusSymbol[UPRINTF_SYMBOL_BUFFER_SIZE]; int32_t symbolLen; symbolLen = unum_getSymbol(format, @@ -162,7 +162,7 @@ u_printf_set_sign(UNumberFormat *format, static void u_printf_reset_sign(UNumberFormat *format, const u_printf_spec_info *info, - UChar *prefixBuffer, + char16_t *prefixBuffer, int32_t *prefixBufLen, UErrorCode *status) { @@ -187,7 +187,7 @@ u_printf_simple_percent_handler(const u_printf_stream_handler *handler, (void)formatBundle; (void)info; (void)args; - static const UChar PERCENT[] = { UP_PERCENT }; + static const char16_t PERCENT[] = { UP_PERCENT }; /* put a single '%' onto the output */ return handler->write(context, PERCENT, 1); @@ -202,8 +202,8 @@ u_printf_string_handler(const u_printf_stream_handler *handler, const ufmt_args *args) { (void)formatBundle; - UChar *s; - UChar buffer[UFMT_DEFAULT_BUFFER_SIZE]; + char16_t *s; + char16_t buffer[UFMT_DEFAULT_BUFFER_SIZE]; int32_t len, written; int32_t argSize; const char *arg = (const char*)(args[0].ptrValue); @@ -213,9 +213,9 @@ u_printf_string_handler(const u_printf_stream_handler *handler, argSize = (int32_t)strlen(arg) + 1; if (argSize >= MAX_UCHAR_BUFFER_SIZE(buffer)) { s = ufmt_defaultCPToUnicode(arg, argSize, - (UChar *)uprv_malloc(MAX_UCHAR_BUFFER_NEEDED(argSize)), + (char16_t *)uprv_malloc(MAX_UCHAR_BUFFER_NEEDED(argSize)), MAX_UCHAR_BUFFER_NEEDED(argSize)); - if(s == NULL) { + if(s == nullptr) { return 0; } } @@ -225,7 +225,7 @@ u_printf_string_handler(const u_printf_stream_handler *handler, } } else { - s = (UChar *)gNullStr; + s = (char16_t *)gNullStr; } len = u_strlen(s); @@ -253,7 +253,7 @@ u_printf_char_handler(const u_printf_stream_handler *handler, const ufmt_args *args) { (void)formatBundle; - UChar s[U16_MAX_LENGTH+1]; + char16_t s[U16_MAX_LENGTH+1]; int32_t len = 1, written; unsigned char arg = (unsigned char)(args[0].int64Value); @@ -283,8 +283,8 @@ u_printf_double_handler(const u_printf_stream_handler *handler, { double num = (double) (args[0].doubleValue); UNumberFormat *format; - UChar result[UPRINTF_BUFFER_SIZE]; - UChar prefixBuffer[UPRINTF_BUFFER_SIZE]; + char16_t result[UPRINTF_BUFFER_SIZE]; + char16_t prefixBuffer[UPRINTF_BUFFER_SIZE]; int32_t prefixBufferLen = sizeof(prefixBuffer); int32_t minDecimalDigits; int32_t maxDecimalDigits; @@ -359,8 +359,8 @@ u_printf_integer_handler(const u_printf_stream_handler *handler, { int64_t num = args[0].int64Value; UNumberFormat *format; - UChar result[UPRINTF_BUFFER_SIZE]; - UChar prefixBuffer[UPRINTF_BUFFER_SIZE]; + char16_t result[UPRINTF_BUFFER_SIZE]; + char16_t prefixBuffer[UPRINTF_BUFFER_SIZE]; int32_t prefixBufferLen = sizeof(prefixBuffer); int32_t minDigits = -1; int32_t resultLen; @@ -425,7 +425,7 @@ u_printf_hex_handler(const u_printf_stream_handler *handler, { (void)formatBundle; int64_t num = args[0].int64Value; - UChar result[UPRINTF_BUFFER_SIZE]; + char16_t result[UPRINTF_BUFFER_SIZE]; int32_t len = UPRINTF_BUFFER_SIZE; @@ -443,7 +443,7 @@ u_printf_hex_handler(const u_printf_stream_handler *handler, /* convert to alt form, if desired */ if(num != 0 && info->fAlt && len < UPRINTF_BUFFER_SIZE - 2) { /* shift the formatted string right by 2 chars */ - memmove(result + 2, result, len * sizeof(UChar)); + memmove(result + 2, result, len * sizeof(char16_t)); result[0] = 0x0030; result[1] = info->fSpec; len += 2; @@ -461,7 +461,7 @@ u_printf_octal_handler(const u_printf_stream_handler *handler, { (void)formatBundle; int64_t num = args[0].int64Value; - UChar result[UPRINTF_BUFFER_SIZE]; + char16_t result[UPRINTF_BUFFER_SIZE]; int32_t len = UPRINTF_BUFFER_SIZE; @@ -473,13 +473,13 @@ u_printf_octal_handler(const u_printf_stream_handler *handler, /* format the number, preserving the minimum # of digits */ ufmt_64tou(result, &len, num, 8, - FALSE, /* doesn't matter for octal */ + false, /* doesn't matter for octal */ info->fPrecision == -1 && info->fZero ? info->fWidth : info->fPrecision); /* convert to alt form, if desired */ if(info->fAlt && result[0] != 0x0030 && len < UPRINTF_BUFFER_SIZE - 1) { /* shift the formatted string right by 1 char */ - memmove(result + 1, result, len * sizeof(UChar)); + memmove(result + 1, result, len * sizeof(char16_t)); result[0] = 0x0030; len += 1; } @@ -496,7 +496,7 @@ u_printf_uinteger_handler(const u_printf_stream_handler *handler, { int64_t num = args[0].int64Value; UNumberFormat *format; - UChar result[UPRINTF_BUFFER_SIZE]; + char16_t result[UPRINTF_BUFFER_SIZE]; int32_t minDigits = -1; int32_t resultLen; UErrorCode status = U_ZERO_ERROR; @@ -548,11 +548,11 @@ u_printf_pointer_handler(const u_printf_stream_handler *handler, const ufmt_args *args) { (void)formatBundle; - UChar result[UPRINTF_BUFFER_SIZE]; + char16_t result[UPRINTF_BUFFER_SIZE]; int32_t len = UPRINTF_BUFFER_SIZE; /* format the pointer in hex */ - ufmt_ptou(result, &len, args[0].ptrValue, TRUE/*, info->fPrecision*/); + ufmt_ptou(result, &len, args[0].ptrValue, true/*, info->fPrecision*/); return handler->pad_and_justify(context, info, result, len); } @@ -566,16 +566,16 @@ u_printf_scientific_handler(const u_printf_stream_handler *handler, { double num = (double) (args[0].doubleValue); UNumberFormat *format; - UChar result[UPRINTF_BUFFER_SIZE]; - UChar prefixBuffer[UPRINTF_BUFFER_SIZE]; + char16_t result[UPRINTF_BUFFER_SIZE]; + char16_t prefixBuffer[UPRINTF_BUFFER_SIZE]; int32_t prefixBufferLen = sizeof(prefixBuffer); int32_t minDecimalDigits; int32_t maxDecimalDigits; UErrorCode status = U_ZERO_ERROR; - UChar srcExpBuf[UPRINTF_SYMBOL_BUFFER_SIZE]; + char16_t srcExpBuf[UPRINTF_SYMBOL_BUFFER_SIZE]; int32_t srcLen, expLen; int32_t resultLen; - UChar expBuf[UPRINTF_SYMBOL_BUFFER_SIZE]; + char16_t expBuf[UPRINTF_SYMBOL_BUFFER_SIZE]; prefixBuffer[0] = 0; @@ -599,7 +599,7 @@ u_printf_scientific_handler(const u_printf_stream_handler *handler, &status); /* Upper/lower case the e */ - if (info->fSpec == (UChar)0x65 /* e */) { + if (info->fSpec == (char16_t)0x65 /* e */) { expLen = u_strToLower(expBuf, (int32_t)sizeof(expBuf), srcExpBuf, srcLen, formatBundle->fLocale, @@ -625,7 +625,7 @@ u_printf_scientific_handler(const u_printf_stream_handler *handler, /* set the appropriate flags and number of decimal digits on the formatter */ if(info->fPrecision != -1) { /* set the # of decimal digits */ - if (info->fOrigSpec == (UChar)0x65 /* e */ || info->fOrigSpec == (UChar)0x45 /* E */) { + if (info->fOrigSpec == (char16_t)0x65 /* e */ || info->fOrigSpec == (char16_t)0x45 /* E */) { unum_setAttribute(format, UNUM_FRACTION_DIGITS, info->fPrecision); } else { @@ -686,8 +686,8 @@ u_printf_percent_handler(const u_printf_stream_handler *handler, { double num = (double) (args[0].doubleValue); UNumberFormat *format; - UChar result[UPRINTF_BUFFER_SIZE]; - UChar prefixBuffer[UPRINTF_BUFFER_SIZE]; + char16_t result[UPRINTF_BUFFER_SIZE]; + char16_t prefixBuffer[UPRINTF_BUFFER_SIZE]; int32_t prefixBufferLen = sizeof(prefixBuffer); int32_t minDecimalDigits; int32_t maxDecimalDigits; @@ -761,10 +761,10 @@ u_printf_ustring_handler(const u_printf_stream_handler *handler, { (void)formatBundle; int32_t len, written; - const UChar *arg = (const UChar*)(args[0].ptrValue); + const char16_t *arg = (const char16_t*)(args[0].ptrValue); /* allocate enough space for the buffer */ - if (arg == NULL) { + if (arg == nullptr) { arg = gNullStr; } len = u_strlen(arg); @@ -790,7 +790,7 @@ u_printf_uchar_handler(const u_printf_stream_handler *handler, { (void)formatBundle; int32_t written = 0; - UChar arg = (UChar)(args[0].int64Value); + char16_t arg = (char16_t)(args[0].int64Value); /* width = minimum # of characters to write */ /* precision = maximum # of characters to write */ @@ -840,7 +840,7 @@ u_printf_scidbl_handler(const u_printf_stream_handler *handler, else { format = u_locbund_getNumberFormat(formatBundle, UNUM_DECIMAL); /* Check for null pointer */ - if (format == NULL) { + if (format == nullptr) { return 0; } maxSigDecimalDigits = unum_getAttribute(format, UNUM_MAX_SIGNIFICANT_DIGITS); @@ -851,12 +851,12 @@ u_printf_scidbl_handler(const u_printf_stream_handler *handler, if (significantDigits == -1) { significantDigits = 6; } - unum_setAttribute(format, UNUM_SIGNIFICANT_DIGITS_USED, TRUE); + unum_setAttribute(format, UNUM_SIGNIFICANT_DIGITS_USED, true); unum_setAttribute(format, UNUM_MAX_SIGNIFICANT_DIGITS, significantDigits); /* call the double handler */ retVal = u_printf_double_handler(handler, context, formatBundle, &scidbl_info, args); unum_setAttribute(format, UNUM_MAX_SIGNIFICANT_DIGITS, maxSigDecimalDigits); - unum_setAttribute(format, UNUM_SIGNIFICANT_DIGITS_USED, FALSE); + unum_setAttribute(format, UNUM_SIGNIFICANT_DIGITS_USED, false); } return retVal; } @@ -889,8 +889,8 @@ u_printf_spellout_handler(const u_printf_stream_handler *handler, { double num = (double) (args[0].doubleValue); UNumberFormat *format; - UChar result[UPRINTF_BUFFER_SIZE]; - UChar prefixBuffer[UPRINTF_BUFFER_SIZE]; + char16_t result[UPRINTF_BUFFER_SIZE]; + char16_t prefixBuffer[UPRINTF_BUFFER_SIZE]; int32_t prefixBufferLen = sizeof(prefixBuffer); int32_t minDecimalDigits; int32_t maxDecimalDigits; @@ -1058,15 +1058,15 @@ static const u_printf_info g_u_printf_infos[UPRINTF_NUM_FMT_HANDLERS] = { (s) == MOD_LOWERL || \ (s) == MOD_L /* Returns an array of the parsed argument type given in the format string. */ -static ufmt_args* parseArguments(const UChar *alias, va_list ap, UErrorCode *status) { - ufmt_args *arglist = NULL; - ufmt_type_info *typelist = NULL; - UBool *islonglong = NULL; +static ufmt_args* parseArguments(const char16_t *alias, va_list ap, UErrorCode *status) { + ufmt_args *arglist = nullptr; + ufmt_type_info *typelist = nullptr; + UBool *islonglong = nullptr; int32_t size = 0; int32_t pos = 0; - UChar type; + char16_t type; uint16_t handlerNum; - const UChar *aliasStart = alias; + const char16_t *aliasStart = alias; /* get maximum number of arguments */ for(;;) { @@ -1096,10 +1096,10 @@ static ufmt_args* parseArguments(const UChar *alias, va_list ap, UErrorCode *sta /* if there is no '$', don't read anything */ if(*alias != SPEC_DOLLARSIGN) { - return NULL; + return nullptr; } } else { - return NULL; + return nullptr; } if (pos > size) { @@ -1112,7 +1112,7 @@ static ufmt_args* parseArguments(const UChar *alias, va_list ap, UErrorCode *sta islonglong = (UBool*)uprv_malloc(sizeof(UBool) * size); arglist = (ufmt_args*)uprv_malloc(sizeof(ufmt_args) * size); - /* If malloc failed, return NULL */ + /* If malloc failed, return nullptr */ if (!typelist || !islonglong || !arglist) { if (typelist) { uprv_free(typelist); @@ -1127,7 +1127,7 @@ static ufmt_args* parseArguments(const UChar *alias, va_list ap, UErrorCode *sta } *status = U_MEMORY_ALLOCATION_ERROR; - return NULL; + return nullptr; } /* reset alias back to the beginning */ @@ -1160,11 +1160,11 @@ static ufmt_args* parseArguments(const UChar *alias, va_list ap, UErrorCode *sta /* skip over everything except for the type */ while (ISMOD(*alias) || ISFLAG(*alias) || ISDIGIT(*alias) || *alias == SPEC_ASTERISK || *alias == SPEC_PERIOD || *alias == SPEC_DOLLARSIGN) { - islonglong[pos] = FALSE; + islonglong[pos] = false; if (ISMOD(*alias)) { alias++; if (*alias == MOD_LOWERL) { - islonglong[pos] = TRUE; + islonglong[pos] = true; } } alias++; @@ -1206,7 +1206,7 @@ static ufmt_args* parseArguments(const UChar *alias, va_list ap, UErrorCode *sta break; default: /* else args is ignored */ - arglist[pos].ptrValue = NULL; + arglist[pos].ptrValue = nullptr; break; } } @@ -1220,7 +1220,7 @@ static ufmt_args* parseArguments(const UChar *alias, va_list ap, UErrorCode *sta /* We parse the argument list in Unicode */ U_CFUNC int32_t u_printf_parse(const u_printf_stream_handler *streamHandler, - const UChar *fmt, + const char16_t *fmt, void *context, u_localized_print_string *locStringContext, ULocaleBundle *formatBundle, @@ -1234,12 +1234,12 @@ u_printf_parse(const u_printf_stream_handler *streamHandler, u_printf_spec spec; u_printf_spec_info *info = &(spec.fInfo); - const UChar *alias = fmt; - const UChar *backup; - const UChar *lastAlias; - const UChar *orgAlias = fmt; + const char16_t *alias = fmt; + const char16_t *backup; + const char16_t *lastAlias; + const char16_t *orgAlias = fmt; /* parsed argument list */ - ufmt_args *arglist = NULL; /* initialized it to avoid compiler warnings */ + ufmt_args *arglist = nullptr; /* initialized it to avoid compiler warnings */ UErrorCode status = U_ZERO_ERROR; if (!locStringContext || locStringContext->available >= 0) { /* get the parsed list of argument types */ @@ -1315,28 +1315,28 @@ u_printf_parse(const u_printf_stream_handler *streamHandler, /* left justify */ case FLAG_MINUS: - info->fLeft = TRUE; + info->fLeft = true; break; /* always show sign */ case FLAG_PLUS: - info->fShowSign = TRUE; + info->fShowSign = true; break; /* use space if no sign present */ case FLAG_SPACE: - info->fShowSign = TRUE; - info->fSpace = TRUE; + info->fShowSign = true; + info->fSpace = true; break; /* use alternate form */ case FLAG_POUND: - info->fAlt = TRUE; + info->fAlt = true; break; /* pad with leading zeroes */ case FLAG_ZERO: - info->fZero = TRUE; + info->fZero = true; info->fPadChar = 0x0030; break; @@ -1345,10 +1345,10 @@ u_printf_parse(const u_printf_stream_handler *streamHandler, /* TODO test that all four are numbers */ /* first four characters are hex values for pad char */ - info->fPadChar = (UChar)ufmt_digitvalue(*alias++); - info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*alias++)); - info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*alias++)); - info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*alias++)); + info->fPadChar = (char16_t)ufmt_digitvalue(*alias++); + info->fPadChar = (char16_t)((info->fPadChar * 16) + ufmt_digitvalue(*alias++)); + info->fPadChar = (char16_t)((info->fPadChar * 16) + ufmt_digitvalue(*alias++)); + info->fPadChar = (char16_t)((info->fPadChar * 16) + ufmt_digitvalue(*alias++)); /* final character is ignored */ alias++; @@ -1454,23 +1454,23 @@ u_printf_parse(const u_printf_stream_handler *streamHandler, /* short */ case MOD_H: - info->fIsShort = TRUE; + info->fIsShort = true; break; /* long or long long */ case MOD_LOWERL: if(*alias == MOD_LOWERL) { - info->fIsLongLong = TRUE; + info->fIsLongLong = true; /* skip over the next 'l' */ alias++; } else - info->fIsLong = TRUE; + info->fIsLong = true; break; /* long double */ case MOD_L: - info->fIsLongDouble = TRUE; + info->fIsLongDouble = true; break; } } @@ -1492,7 +1492,7 @@ u_printf_parse(const u_printf_stream_handler *streamHandler, /* if it's negative, take the absolute value and set left alignment */ if(info->fWidth < 0) { info->fWidth *= -1; /* Make positive */ - info->fLeft = TRUE; + info->fLeft = true; } } @@ -1542,7 +1542,7 @@ u_printf_parse(const u_printf_stream_handler *streamHandler, break; default: /* else args is ignored */ - args.ptrValue = NULL; + args.ptrValue = nullptr; break; } } else { /* no positional argument specified */ @@ -1575,7 +1575,7 @@ u_printf_parse(const u_printf_stream_handler *streamHandler, break; default: /* else args is ignored */ - args.ptrValue = NULL; + args.ptrValue = nullptr; break; } } @@ -1596,7 +1596,7 @@ u_printf_parse(const u_printf_stream_handler *streamHandler, } } /* delete parsed argument list */ - if (arglist != NULL) { + if (arglist != nullptr) { uprv_free(arglist); } /* return # of characters in this format that have been parsed. */ diff --git a/contrib/libs/icu/io/uscanf.cpp b/contrib/libs/icu/io/uscanf.cpp index ce2e47a588..2d72ccf515 100644 --- a/contrib/libs/icu/io/uscanf.cpp +++ b/contrib/libs/icu/io/uscanf.cpp @@ -50,7 +50,7 @@ u_fscanf(UFILE *f, U_CAPI int32_t U_EXPORT2 u_fscanf_u(UFILE *f, - const UChar *patternSpecification, + const char16_t *patternSpecification, ... ) { va_list ap; @@ -69,13 +69,13 @@ u_vfscanf(UFILE *f, va_list ap) { int32_t converted; - UChar *pattern; - UChar patBuffer[UFMT_DEFAULT_BUFFER_SIZE]; + char16_t *pattern; + char16_t patBuffer[UFMT_DEFAULT_BUFFER_SIZE]; int32_t size = (int32_t)uprv_strlen(patternSpecification) + 1; /* convert from the default codepage to Unicode */ if (size >= MAX_UCHAR_BUFFER_SIZE(patBuffer)) { - pattern = (UChar *)uprv_malloc(size * sizeof(UChar)); + pattern = (char16_t *)uprv_malloc(size * sizeof(char16_t)); if(pattern == 0) { return 0; } @@ -98,7 +98,7 @@ u_vfscanf(UFILE *f, U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ u_vfscanf_u(UFILE *f, - const UChar *patternSpecification, + const char16_t *patternSpecification, va_list ap) { return u_scanf_parse(f, patternSpecification, ap); diff --git a/contrib/libs/icu/io/uscanf_p.cpp b/contrib/libs/icu/io/uscanf_p.cpp index 5bf3e5b7a8..0a41dfe07d 100644 --- a/contrib/libs/icu/io/uscanf_p.cpp +++ b/contrib/libs/icu/io/uscanf_p.cpp @@ -83,16 +83,16 @@ typedef struct u_scanf_spec_info { int32_t fWidth; /* Width */ - UChar fSpec; /* Format specification */ + char16_t fSpec; /* Format specification */ - UChar fPadChar; /* Padding character */ + char16_t fPadChar; /* Padding character */ - UBool fSkipArg; /* TRUE if arg should be skipped */ + UBool fSkipArg; /* true if arg should be skipped */ UBool fIsLongDouble; /* L flag */ UBool fIsShort; /* h flag */ UBool fIsLong; /* l flag */ UBool fIsLongLong; /* ll flag */ - UBool fIsString; /* TRUE if this is a NULL-terminated string. */ + UBool fIsString; /* true if this is a NUL-terminated string. */ } u_scanf_spec_info; @@ -112,11 +112,11 @@ typedef struct u_scanf_spec { * @return The number of characters contained in this specifier. */ static int32_t -u_scanf_parse_spec (const UChar *fmt, +u_scanf_parse_spec (const char16_t *fmt, u_scanf_spec *spec) { - const UChar *s = fmt; - const UChar *backup; + const char16_t *s = fmt; + const char16_t *backup; u_scanf_spec_info *info = &(spec->fInfo); /* initialize spec to default values */ @@ -125,12 +125,12 @@ u_scanf_parse_spec (const UChar *fmt, info->fWidth = -1; info->fSpec = 0x0000; info->fPadChar = 0x0020; - info->fSkipArg = FALSE; - info->fIsLongDouble = FALSE; - info->fIsShort = FALSE; - info->fIsLong = FALSE; - info->fIsLongLong = FALSE; - info->fIsString = TRUE; + info->fSkipArg = false; + info->fIsLongDouble = false; + info->fIsShort = false; + info->fIsLong = false; + info->fIsLongLong = false; + info->fIsString = true; /* skip over the initial '%' */ @@ -168,17 +168,17 @@ u_scanf_parse_spec (const UChar *fmt, /* skip argument */ case FLAG_ASTERISK: - info->fSkipArg = TRUE; + info->fSkipArg = true; break; /* pad character specified */ case FLAG_PAREN: /* first four characters are hex values for pad char */ - info->fPadChar = (UChar)ufmt_digitvalue(*s++); - info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*s++)); - info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*s++)); - info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*s++)); + info->fPadChar = (char16_t)ufmt_digitvalue(*s++); + info->fPadChar = (char16_t)((info->fPadChar * 16) + ufmt_digitvalue(*s++)); + info->fPadChar = (char16_t)((info->fPadChar * 16) + ufmt_digitvalue(*s++)); + info->fPadChar = (char16_t)((info->fPadChar * 16) + ufmt_digitvalue(*s++)); /* final character is ignored */ s++; @@ -203,23 +203,23 @@ u_scanf_parse_spec (const UChar *fmt, /* short */ case MOD_H: - info->fIsShort = TRUE; + info->fIsShort = true; break; /* long or long long */ case MOD_LOWERL: if(*s == MOD_LOWERL) { - info->fIsLongLong = TRUE; + info->fIsLongLong = true; /* skip over the next 'l' */ s++; } else - info->fIsLong = TRUE; + info->fIsLong = true; break; /* long double */ case MOD_L: - info->fIsLongDouble = TRUE; + info->fIsLongDouble = true; break; } } @@ -277,7 +277,7 @@ u_scanf_parse_spec (const UChar *fmt, #define UFMT_USTRING {ufmt_ustring, u_scanf_ustring_handler} -#define UFMT_EMPTY {ufmt_empty, NULL} +#define UFMT_EMPTY {ufmt_empty, nullptr} /** * A u_scanf handler function. @@ -298,7 +298,7 @@ u_scanf_parse_spec (const UChar *fmt, typedef int32_t (*u_scanf_handler) (UFILE *stream, u_scanf_spec_info *info, ufmt_args *args, - const UChar *fmt, + const char16_t *fmt, int32_t *fmtConsumed, int32_t *argConverted); @@ -316,14 +316,14 @@ typedef struct u_scanf_info { static int32_t u_scanf_skip_leading_ws(UFILE *input, - UChar pad) + char16_t pad) { - UChar c; + char16_t c; int32_t count = 0; UBool isNotEOF; /* skip all leading ws in the input */ - while( ((isNotEOF = ufile_getch(input, &c)) == TRUE) && (c == pad || u_isWhitespace(c)) ) + while( ((isNotEOF = ufile_getch(input, &c))==(UBool)true) && (c == pad || u_isWhitespace(c)) ) { count++; } @@ -341,10 +341,10 @@ u_scanf_skip_leading_positive_sign(UFILE *input, UNumberFormat *format, UErrorCode *status) { - UChar c; + char16_t c; int32_t count = 0; UBool isNotEOF; - UChar plusSymbol[USCANF_SYMBOL_BUFFER_SIZE]; + char16_t plusSymbol[USCANF_SYMBOL_BUFFER_SIZE]; int32_t symbolLen; UErrorCode localStatus = U_ZERO_ERROR; @@ -357,7 +357,7 @@ u_scanf_skip_leading_positive_sign(UFILE *input, if (U_SUCCESS(localStatus)) { /* skip all leading ws in the input */ - while( ((isNotEOF = ufile_getch(input, &c)) == TRUE) && (count < symbolLen && c == plusSymbol[count]) ) + while( ((isNotEOF = ufile_getch(input, &c))==(UBool)true) && (count < symbolLen && c == plusSymbol[count]) ) { count++; } @@ -376,7 +376,7 @@ static int32_t u_scanf_simple_percent_handler(UFILE *input, u_scanf_spec_info *info, ufmt_args *args, - const UChar *fmt, + const char16_t *fmt, int32_t *fmtConsumed, int32_t *argConverted) { @@ -397,7 +397,7 @@ static int32_t u_scanf_count_handler(UFILE *input, u_scanf_spec_info *info, ufmt_args *args, - const UChar *fmt, + const char16_t *fmt, int32_t *fmtConsumed, int32_t *argConverted) { @@ -425,7 +425,7 @@ static int32_t u_scanf_double_handler(UFILE *input, u_scanf_spec_info *info, ufmt_args *args, - const UChar *fmt, + const char16_t *fmt, int32_t *fmtConsumed, int32_t *argConverted) { @@ -493,7 +493,7 @@ static int32_t u_scanf_scientific_handler(UFILE *input, u_scanf_spec_info *info, ufmt_args *args, - const UChar *fmt, + const char16_t *fmt, int32_t *fmtConsumed, int32_t *argConverted) { @@ -506,9 +506,9 @@ u_scanf_scientific_handler(UFILE *input, int32_t parsePos = 0; int32_t skipped; UErrorCode status = U_ZERO_ERROR; - UChar srcExpBuf[UPRINTF_SYMBOL_BUFFER_SIZE]; + char16_t srcExpBuf[UPRINTF_SYMBOL_BUFFER_SIZE]; int32_t srcLen, expLen; - UChar expBuf[UPRINTF_SYMBOL_BUFFER_SIZE]; + char16_t expBuf[UPRINTF_SYMBOL_BUFFER_SIZE]; /* skip all ws in the input */ @@ -540,7 +540,7 @@ u_scanf_scientific_handler(UFILE *input, &status); /* Upper/lower case the e */ - if (info->fSpec == (UChar)0x65 /* e */) { + if (info->fSpec == (char16_t)0x65 /* e */) { expLen = u_strToLower(expBuf, (int32_t)sizeof(expBuf), srcExpBuf, srcLen, input->str.fBundle.fLocale, @@ -593,7 +593,7 @@ static int32_t u_scanf_scidbl_handler(UFILE *input, u_scanf_spec_info *info, ufmt_args *args, - const UChar *fmt, + const char16_t *fmt, int32_t *fmtConsumed, int32_t *argConverted) { @@ -686,7 +686,7 @@ static int32_t u_scanf_integer_handler(UFILE *input, u_scanf_spec_info *info, ufmt_args *args, - const UChar *fmt, + const char16_t *fmt, int32_t *fmtConsumed, int32_t *argConverted) { @@ -763,7 +763,7 @@ static int32_t u_scanf_uinteger_handler(UFILE *input, u_scanf_spec_info *info, ufmt_args *args, - const UChar *fmt, + const char16_t *fmt, int32_t *fmtConsumed, int32_t *argConverted) { @@ -775,7 +775,7 @@ static int32_t u_scanf_percent_handler(UFILE *input, u_scanf_spec_info *info, ufmt_args *args, - const UChar *fmt, + const char16_t *fmt, int32_t *fmtConsumed, int32_t *argConverted) { @@ -835,14 +835,14 @@ static int32_t u_scanf_string_handler(UFILE *input, u_scanf_spec_info *info, ufmt_args *args, - const UChar *fmt, + const char16_t *fmt, int32_t *fmtConsumed, int32_t *argConverted) { (void)fmt; (void)fmtConsumed; - const UChar *source; + const char16_t *source; UConverter *conv; char *arg = (char*)(args[0].ptrValue); char *alias = arg; @@ -850,8 +850,8 @@ u_scanf_string_handler(UFILE *input, UErrorCode status = U_ZERO_ERROR; int32_t count; int32_t skipped = 0; - UChar c; - UBool isNotEOF = FALSE; + char16_t c; + UBool isNotEOF = false; /* skip all ws in the input */ if (info->fIsString) { @@ -868,7 +868,7 @@ u_scanf_string_handler(UFILE *input, return -1; while( (info->fWidth == -1 || count < info->fWidth) - && ((isNotEOF = ufile_getch(input, &c)) == TRUE) + && ((isNotEOF = ufile_getch(input, &c))==(UBool)true) && (!info->fIsString || (c != info->fPadChar && !u_isWhitespace(c)))) { @@ -885,7 +885,7 @@ u_scanf_string_handler(UFILE *input, /* convert the character to the default codepage */ ucnv_fromUnicode(conv, &alias, limit, &source, source + 1, - NULL, TRUE, &status); + nullptr, true, &status); if(U_FAILURE(status)) { /* clean up */ @@ -921,14 +921,14 @@ static int32_t u_scanf_char_handler(UFILE *input, u_scanf_spec_info *info, ufmt_args *args, - const UChar *fmt, + const char16_t *fmt, int32_t *fmtConsumed, int32_t *argConverted) { if (info->fWidth < 0) { info->fWidth = 1; } - info->fIsString = FALSE; + info->fIsString = false; return u_scanf_string_handler(input, info, args, fmt, fmtConsumed, argConverted); } @@ -936,19 +936,19 @@ static int32_t u_scanf_ustring_handler(UFILE *input, u_scanf_spec_info *info, ufmt_args *args, - const UChar *fmt, + const char16_t *fmt, int32_t *fmtConsumed, int32_t *argConverted) { (void)fmt; (void)fmtConsumed; - UChar *arg = (UChar*)(args[0].ptrValue); - UChar *alias = arg; + char16_t *arg = (char16_t*)(args[0].ptrValue); + char16_t *alias = arg; int32_t count; int32_t skipped = 0; - UChar c; - UBool isNotEOF = FALSE; + char16_t c; + UBool isNotEOF = false; /* skip all ws in the input */ if (info->fIsString) { @@ -959,7 +959,7 @@ u_scanf_ustring_handler(UFILE *input, count = 0; while( (info->fWidth == -1 || count < info->fWidth) - && ((isNotEOF = ufile_getch(input, &c)) == TRUE) + && ((isNotEOF = ufile_getch(input, &c))==(UBool)true) && (!info->fIsString || (c != info->fPadChar && !u_isWhitespace(c)))) { @@ -993,14 +993,14 @@ static int32_t u_scanf_uchar_handler(UFILE *input, u_scanf_spec_info *info, ufmt_args *args, - const UChar *fmt, + const char16_t *fmt, int32_t *fmtConsumed, int32_t *argConverted) { if (info->fWidth < 0) { info->fWidth = 1; } - info->fIsString = FALSE; + info->fIsString = false; return u_scanf_ustring_handler(input, info, args, fmt, fmtConsumed, argConverted); } @@ -1008,7 +1008,7 @@ static int32_t u_scanf_spellout_handler(UFILE *input, u_scanf_spec_info *info, ufmt_args *args, - const UChar *fmt, + const char16_t *fmt, int32_t *fmtConsumed, int32_t *argConverted) { @@ -1070,7 +1070,7 @@ static int32_t u_scanf_hex_handler(UFILE *input, u_scanf_spec_info *info, ufmt_args *args, - const UChar *fmt, + const char16_t *fmt, int32_t *fmtConsumed, int32_t *argConverted) { @@ -1129,7 +1129,7 @@ static int32_t u_scanf_octal_handler(UFILE *input, u_scanf_spec_info *info, ufmt_args *args, - const UChar *fmt, + const char16_t *fmt, int32_t *fmtConsumed, int32_t *argConverted) { @@ -1179,7 +1179,7 @@ static int32_t u_scanf_pointer_handler(UFILE *input, u_scanf_spec_info *info, ufmt_args *args, - const UChar *fmt, + const char16_t *fmt, int32_t *fmtConsumed, int32_t *argConverted) { @@ -1230,7 +1230,7 @@ static int32_t u_scanf_scanset_handler(UFILE *input, u_scanf_spec_info *info, ufmt_args *args, - const UChar *fmt, + const char16_t *fmt, int32_t *fmtConsumed, int32_t *argConverted) { @@ -1238,9 +1238,9 @@ u_scanf_scanset_handler(UFILE *input, UErrorCode status = U_ZERO_ERROR; int32_t chLeft = INT32_MAX; UChar32 c; - UChar *alias = (UChar*) (args[0].ptrValue); - UBool isNotEOF = FALSE; - UBool readCharacter = FALSE; + char16_t *alias = (char16_t*) (args[0].ptrValue); + UBool isNotEOF = false; + UBool readCharacter = false; /* Create an empty set */ scanset = uset_open(0, -1); @@ -1262,11 +1262,11 @@ u_scanf_scanset_handler(UFILE *input, /* grab characters one at a time and make sure they are in the scanset */ while(chLeft > 0) { - if ( ((isNotEOF = ufile_getch32(input, &c)) == TRUE) && uset_contains(scanset, c) ) { - readCharacter = TRUE; + if ( ((isNotEOF = ufile_getch32(input, &c))==(UBool)true) && uset_contains(scanset, c) ) { + readCharacter = true; if (!info->fSkipArg) { int32_t idx = 0; - UBool isError = FALSE; + UBool isError = false; U16_APPEND(alias, idx, chLeft, c, isError); if (isError) { @@ -1355,10 +1355,10 @@ static const u_scanf_info g_u_scanf_infos[USCANF_NUM_FMT_HANDLERS] = { U_CFUNC int32_t u_scanf_parse(UFILE *f, - const UChar *patternSpecification, + const char16_t *patternSpecification, va_list ap) { - const UChar *alias; + const char16_t *alias; int32_t count, converted, argConsumed, cpConsumed; uint16_t handlerNum; @@ -1402,7 +1402,7 @@ u_scanf_parse(UFILE *f, break; } else if(spec.fInfo.fSkipArg) { - args.ptrValue = NULL; + args.ptrValue = nullptr; } else { switch(info) { @@ -1423,7 +1423,7 @@ u_scanf_parse(UFILE *f, default: /* else args is ignored */ - args.ptrValue = NULL; + args.ptrValue = nullptr; break; } } diff --git a/contrib/libs/icu/io/ustdio.cpp b/contrib/libs/icu/io/ustdio.cpp index d6eb5cf9ec..4130f34044 100644 --- a/contrib/libs/icu/io/ustdio.cpp +++ b/contrib/libs/icu/io/ustdio.cpp @@ -43,11 +43,11 @@ /* TODO: is this correct for all codepages? Should we just use \n and let the converter handle it? */ #if U_PLATFORM_USES_ONLY_WIN32_API -static const UChar DELIMITERS [] = { DELIM_CR, DELIM_LF, 0x0000 }; +static const char16_t DELIMITERS [] = { DELIM_CR, DELIM_LF, 0x0000 }; static const uint32_t DELIMITERS_LEN = 2; /* TODO: Default newline writing should be detected based upon the converter being used. */ #else -static const UChar DELIMITERS [] = { DELIM_LF, 0x0000 }; +static const char16_t DELIMITERS [] = { DELIM_LF, 0x0000 }; static const uint32_t DELIMITERS_LEN = 1; #endif @@ -67,7 +67,7 @@ U_CAPI UTransliterator* U_EXPORT2 u_fsettransliterator(UFILE *file, UFileDirection direction, UTransliterator *adopt, UErrorCode *status) { - UTransliterator *old = NULL; + UTransliterator *old = nullptr; if(U_FAILURE(*status)) { @@ -87,21 +87,21 @@ u_fsettransliterator(UFILE *file, UFileDirection direction, return adopt; } - if(adopt == NULL) /* they are clearing it */ + if(adopt == nullptr) /* they are clearing it */ { - if(file->fTranslit != NULL) + if(file->fTranslit != nullptr) { /* TODO: Check side */ old = file->fTranslit->translit; uprv_free(file->fTranslit->buffer); - file->fTranslit->buffer=NULL; + file->fTranslit->buffer=nullptr; uprv_free(file->fTranslit); - file->fTranslit=NULL; + file->fTranslit=nullptr; } } else { - if(file->fTranslit == NULL) + if(file->fTranslit == nullptr) { file->fTranslit = (UFILETranslitBuffer*) uprv_malloc(sizeof(UFILETranslitBuffer)); if(!file->fTranslit) @@ -112,7 +112,7 @@ u_fsettransliterator(UFILE *file, UFileDirection direction, file->fTranslit->capacity = 0; file->fTranslit->length = 0; file->fTranslit->pos = 0; - file->fTranslit->buffer = NULL; + file->fTranslit->buffer = nullptr; } else { @@ -126,7 +126,7 @@ u_fsettransliterator(UFILE *file, UFileDirection direction, return old; } -static const UChar * u_file_translit(UFILE *f, const UChar *src, int32_t *count, UBool flush) +static const char16_t * u_file_translit(UFILE *f, const char16_t *src, int32_t *count, UBool flush) { int32_t newlen; int32_t junkCount = 0; @@ -135,7 +135,7 @@ static const UChar * u_file_translit(UFILE *f, const UChar *src, int32_t *count, UTransPosition pos; UErrorCode status = U_ZERO_ERROR; - if(count == NULL) + if(count == nullptr) { count = &junkCount; } @@ -150,7 +150,7 @@ static const UChar * u_file_translit(UFILE *f, const UChar *src, int32_t *count, if(f->fTranslit->length > f->fTranslit->pos) { memmove(f->fTranslit->buffer, f->fTranslit->buffer + f->fTranslit->pos, - (f->fTranslit->length - f->fTranslit->pos)*sizeof(UChar)); + (f->fTranslit->length - f->fTranslit->pos)*sizeof(char16_t)); } f->fTranslit->length -= f->fTranslit->pos; /* always */ f->fTranslit->pos = 0; @@ -160,17 +160,17 @@ static const UChar * u_file_translit(UFILE *f, const UChar *src, int32_t *count, if(newlen > f->fTranslit->capacity) { - if(f->fTranslit->buffer == NULL) + if(f->fTranslit->buffer == nullptr) { - f->fTranslit->buffer = (UChar*)uprv_malloc(newlen * sizeof(UChar)); + f->fTranslit->buffer = (char16_t*)uprv_malloc(newlen * sizeof(char16_t)); } else { - f->fTranslit->buffer = (UChar*)uprv_realloc(f->fTranslit->buffer, newlen * sizeof(UChar)); + f->fTranslit->buffer = (char16_t*)uprv_realloc(f->fTranslit->buffer, newlen * sizeof(char16_t)); } /* Check for malloc/realloc failure. */ - if (f->fTranslit->buffer == NULL) { - return NULL; + if (f->fTranslit->buffer == nullptr) { + return nullptr; } f->fTranslit->capacity = newlen; } @@ -182,7 +182,7 @@ static const UChar * u_file_translit(UFILE *f, const UChar *src, int32_t *count, f->fTranslit->length += *count; /* Now, translit in place as much as we can */ - if(flush == FALSE) + if(flush == false) { textLength = f->fTranslit->length; pos.contextStart = 0; @@ -239,7 +239,7 @@ ufile_flush_translit(UFILE *f) return; #endif - u_file_write_flush(NULL, 0, f, FALSE, TRUE); + u_file_write_flush(nullptr, 0, f, false, true); } @@ -250,7 +250,7 @@ ufile_flush_io(UFILE *f) return; /* skip if no file */ } - u_file_write_flush(NULL, 0, f, TRUE, FALSE); + u_file_write_flush(nullptr, 0, f, true, false); } @@ -274,7 +274,7 @@ ufile_close_translit(UFILE *f) } uprv_free(f->fTranslit); - f->fTranslit = NULL; + f->fTranslit = nullptr; #endif } @@ -282,7 +282,7 @@ ufile_close_translit(UFILE *f) /* Input/output */ U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ -u_fputs(const UChar *s, +u_fputs(const char16_t *s, UFILE *f) { int32_t count = u_file_write(s, u_strlen(s), f); @@ -294,9 +294,9 @@ U_CAPI UChar32 U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 u_fputc(UChar32 uc, UFILE *f) { - UChar buf[2]; + char16_t buf[2]; int32_t idx = 0; - UBool isError = FALSE; + UBool isError = false; U16_APPEND(buf, idx, UPRV_LENGTHOF(buf), uc, isError); if (isError) { @@ -307,7 +307,7 @@ u_fputc(UChar32 uc, U_CFUNC int32_t U_EXPORT2 -u_file_write_flush(const UChar *chars, +u_file_write_flush(const char16_t *chars, int32_t count, UFILE *f, UBool flushIO, @@ -315,9 +315,9 @@ u_file_write_flush(const UChar *chars, { /* Set up conversion parameters */ UErrorCode status = U_ZERO_ERROR; - const UChar *mySource = chars; - const UChar *mySourceBegin; - const UChar *mySourceEnd; + const char16_t *mySource = chars; + const char16_t *mySourceBegin; + const char16_t *mySourceEnd; char charBuffer[UFILE_CHARBUFFER_SIZE]; char *myTarget = charBuffer; int32_t written = 0; @@ -353,13 +353,13 @@ u_file_write_flush(const UChar *chars, do { mySourceBegin = mySource; /* beginning location for this loop */ status = U_ZERO_ERROR; - if(f->fConverter != NULL) { /* We have a valid converter */ + if(f->fConverter != nullptr) { /* We have a valid converter */ ucnv_fromUnicode(f->fConverter, &myTarget, charBuffer + UFILE_CHARBUFFER_SIZE, &mySource, mySourceEnd, - NULL, + nullptr, flushIO, &status); } else { /*weiv: do the invariant conversion */ @@ -392,11 +392,11 @@ u_file_write_flush(const UChar *chars, } U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ -u_file_write( const UChar *chars, +u_file_write( const char16_t *chars, int32_t count, UFILE *f) { - return u_file_write_flush(chars,count,f,FALSE,FALSE); + return u_file_write_flush(chars,count,f,false,false); } @@ -407,7 +407,7 @@ ufile_fill_uchar_buffer(UFILE *f) UErrorCode status; const char *mySource; const char *mySourceEnd; - UChar *myTarget; + char16_t *myTarget; int32_t bufferSize; int32_t maxCPBytes; int32_t bytesRead; @@ -416,7 +416,7 @@ ufile_fill_uchar_buffer(UFILE *f) char charBuffer[UFILE_CHARBUFFER_SIZE]; u_localized_string *str; - if (f->fFile == NULL) { + if (f->fFile == nullptr) { /* There is nothing to do. It's a string. */ return; } @@ -437,9 +437,9 @@ ufile_fill_uchar_buffer(UFILE *f) /* record how much buffer space is available */ availLength = UFILE_UCHARBUFFER_SIZE - dataSize; - /* Determine the # of codepage bytes needed to fill our UChar buffer */ - /* weiv: if converter is NULL, we use invariant converter with charwidth = 1)*/ - maxCPBytes = availLength / (f->fConverter!=NULL?(2*ucnv_getMinCharSize(f->fConverter)):1); + /* Determine the # of codepage bytes needed to fill our char16_t buffer */ + /* weiv: if converter is nullptr, we use invariant converter with charwidth = 1)*/ + maxCPBytes = availLength / (f->fConverter!=nullptr?(2*ucnv_getMinCharSize(f->fConverter)):1); /* Read in the data to convert */ if (f->fFileno == 0) { @@ -462,14 +462,14 @@ ufile_fill_uchar_buffer(UFILE *f) myTarget = f->fUCBuffer + dataSize; bufferSize = UFILE_UCHARBUFFER_SIZE; - if(f->fConverter != NULL) { /* We have a valid converter */ + if(f->fConverter != nullptr) { /* We have a valid converter */ /* Perform the conversion */ ucnv_toUnicode(f->fConverter, &myTarget, f->fUCBuffer + bufferSize, &mySource, mySourceEnd, - NULL, + nullptr, (UBool)(feof(f->fFile) != 0), &status); @@ -483,22 +483,22 @@ ufile_fill_uchar_buffer(UFILE *f) str->fLimit = myTarget; } -U_CAPI UChar* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ -u_fgets(UChar *s, +U_CAPI char16_t* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ +u_fgets(char16_t *s, int32_t n, UFILE *f) { int32_t dataSize; int32_t count; - UChar *alias; - const UChar *limit; - UChar *sItr; - UChar currDelim = 0; + char16_t *alias; + const char16_t *limit; + char16_t *sItr; + char16_t currDelim = 0; u_localized_string *str; if (n <= 0) { /* Caller screwed up. We need to write the null terminatior. */ - return NULL; + return nullptr; } /* fill the buffer if needed */ @@ -515,7 +515,7 @@ u_fgets(UChar *s, /* if 0 characters were left, return 0 */ if (dataSize == 0) - return NULL; + return nullptr; /* otherwise, iteratively fill the buffer and copy */ count = 0; @@ -587,15 +587,15 @@ u_fgets(UChar *s, } U_CFUNC UBool U_EXPORT2 -ufile_getch(UFILE *f, UChar *ch) +ufile_getch(UFILE *f, char16_t *ch) { - UBool isValidChar = FALSE; + UBool isValidChar = false; *ch = U_EOF; /* if we have an available character in the buffer, return it */ if(f->str.fPos < f->str.fLimit){ *ch = *(f->str.fPos)++; - isValidChar = TRUE; + isValidChar = true; } else { /* otherwise, fill the buffer and return the next character */ @@ -604,16 +604,16 @@ ufile_getch(UFILE *f, UChar *ch) } if(f->str.fPos < f->str.fLimit) { *ch = *(f->str.fPos)++; - isValidChar = TRUE; + isValidChar = true; } } return isValidChar; } -U_CAPI UChar U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ +U_CAPI char16_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ u_fgetc(UFILE *f) { - UChar ch; + char16_t ch; ufile_getch(f, &ch); return ch; } @@ -621,14 +621,14 @@ u_fgetc(UFILE *f) U_CFUNC UBool U_EXPORT2 ufile_getch32(UFILE *f, UChar32 *c32) { - UBool isValidChar = FALSE; + UBool isValidChar = false; u_localized_string *str; *c32 = U_EOF; /* Fill the buffer if it is empty */ str = &f->str; - if (f && str->fPos + 1 >= str->fLimit) { + if (str->fPos + 1 >= str->fLimit) { ufile_fill_uchar_buffer(f); } @@ -637,16 +637,16 @@ ufile_getch32(UFILE *f, UChar32 *c32) *c32 = *(str->fPos)++; if (U_IS_LEAD(*c32)) { if (str->fPos < str->fLimit) { - UChar c16 = *(str->fPos)++; + char16_t c16 = *(str->fPos)++; *c32 = U16_GET_SUPPLEMENTARY(*c32, c16); - isValidChar = TRUE; + isValidChar = true; } else { *c32 = U_EOF; } } else { - isValidChar = TRUE; + isValidChar = true; } } @@ -693,7 +693,7 @@ u_fungetc(UChar32 ch, } U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ -u_file_read( UChar *chars, +u_file_read( char16_t *chars, int32_t count, UFILE *f) { @@ -717,7 +717,7 @@ u_file_read( UChar *chars, } /* copy the current data in the buffer */ - memcpy(chars + read, str->fPos, dataSize * sizeof(UChar)); + memcpy(chars + read, str->fPos, dataSize * sizeof(char16_t)); /* update number of items read */ read += dataSize; diff --git a/contrib/libs/icu/io/ustream.cpp b/contrib/libs/icu/io/ustream.cpp index 51676ea0f5..fd783b3b23 100644 --- a/contrib/libs/icu/io/ustream.cpp +++ b/contrib/libs/icu/io/ustream.cpp @@ -47,13 +47,13 @@ operator<<(STD_OSTREAM& stream, const UnicodeString& str) // use the default converter to convert chunks of text converter = u_getDefaultConverter(&errorCode); if(U_SUCCESS(errorCode)) { - const UChar *us = str.getBuffer(); - const UChar *uLimit = us + str.length(); + const char16_t *us = str.getBuffer(); + const char16_t *uLimit = us + str.length(); char *s, *sLimit = buffer + (sizeof(buffer) - 1); do { errorCode = U_ZERO_ERROR; s = buffer; - ucnv_fromUnicode(converter, &s, sLimit, &us, uLimit, 0, FALSE, &errorCode); + ucnv_fromUnicode(converter, &s, sLimit, &us, uLimit, 0, false, &errorCode); *s = 0; // write this chunk @@ -78,7 +78,7 @@ operator>>(STD_ISTREAM& stream, UnicodeString& str) } /* ipfx should eat whitespace when ios::skipws is set */ - UChar uBuffer[16]; + char16_t uBuffer[16]; char buffer[16]; int32_t idx = 0; UConverter *converter; @@ -87,13 +87,13 @@ operator>>(STD_ISTREAM& stream, UnicodeString& str) // use the default converter to convert chunks of text converter = u_getDefaultConverter(&errorCode); if(U_SUCCESS(errorCode)) { - UChar *us = uBuffer; - const UChar *uLimit = uBuffer + UPRV_LENGTHOF(uBuffer); + char16_t *us = uBuffer; + const char16_t *uLimit = uBuffer + UPRV_LENGTHOF(uBuffer); const char *s, *sLimit; char ch; - UChar ch32; - UBool initialWhitespace = TRUE; - UBool continueReading = TRUE; + char16_t ch32; + UBool initialWhitespace = true; + UBool continueReading = true; /* We need to consume one byte at a time to see what is considered whitespace. */ while (continueReading) { @@ -103,7 +103,7 @@ operator>>(STD_ISTREAM& stream, UnicodeString& str) if (!initialWhitespace) { stream.clear(stream.eofbit); } - continueReading = FALSE; + continueReading = false; } sLimit = &ch + (int)continueReading; us = uBuffer; @@ -140,13 +140,13 @@ operator>>(STD_ISTREAM& stream, UnicodeString& str) else { if (initialWhitespace) { /* - When initialWhitespace is TRUE, we haven't appended any + When initialWhitespace is true, we haven't appended any character yet. This is where we truncate the string, to avoid modifying the string before we know if we can actually read from the stream. */ str.truncate(0); - initialWhitespace = FALSE; + initialWhitespace = false; } str.append(ch32); } |