U_CDECL_END static U_INLINE UNumberFormat * copyInvariantFormatter(ULocaleBundle *result, UNumberFormatStyle style) { if (result->fNumberFormat[style-1] == NULL) { UErrorCode status = U_ZERO_ERROR; UBool needsInit; UMTX_CHECK(NULL, gPosixNumberFormat[style-1] == NULL, needsInit); if (needsInit) { UNumberFormat *formatAlias = unum_open(style, NULL, 0, "en_US_POSIX", NULL, &status); /* Cache upon first request. */ if (U_SUCCESS(status)) { umtx_lock(NULL); gPosixNumberFormat[style-1] = formatAlias; ucln_io_registerCleanup(UCLN_IO_LOCBUND, locbund_cleanup); umtx_unlock(NULL); } } /* Copy the needed formatter. */ result->fNumberFormat[style-1] = unum_clone(gPosixNumberFormat[style-1], &status); } return result->fNumberFormat[style-1]; }
U_CAPI UFILE * U_EXPORT2 u_get_stdout() { if (gStdOut == NULL) { gStdOut = u_finit(stdout, NULL, NULL); ucln_io_registerCleanup(UCLN_IO_PRINTF, &uprintf_cleanup); } return gStdOut; }
static inline UNumberFormat * copyInvariantFormatter(ULocaleBundle *result, UNumberFormatStyle style) { U_NAMESPACE_USE Mutex lock(&gLock); if (result->fNumberFormat[style-1] == NULL) { if (gPosixNumberFormat[style-1] == NULL) { UErrorCode status = U_ZERO_ERROR; UNumberFormat *formatAlias = unum_open(style, NULL, 0, "en_US_POSIX", NULL, &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) { UErrorCode status = U_ZERO_ERROR; result->fNumberFormat[style-1] = unum_clone(gPosixNumberFormat[style-1], &status); } } return result->fNumberFormat[style-1]; }