Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Unified Diff: source/io/uprintf.cpp

Issue 845603002: Update ICU to 54.1 step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@master
Patch Set: remove unusued directories Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/io/uprintf.c ('k') | source/io/uprntf_p.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/io/uprintf.cpp
diff --git a/source/io/uprintf.c b/source/io/uprintf.cpp
similarity index 89%
rename from source/io/uprintf.c
rename to source/io/uprintf.cpp
index 4f9ec18148d643204f73fa9643551d3c2417c72f..a7e79f8ea894205f2eaa45ca01f6c836cc638ba2 100644
--- a/source/io/uprintf.c
+++ b/source/io/uprintf.cpp
@@ -1,12 +1,12 @@
/*
******************************************************************************
*
-* Copyright (C) 1998-2012, International Business Machines
+* Copyright (C) 1998-2014, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
*
-* File uprintf.c
+* File uprintf.cpp
*
* Modification History:
*
@@ -20,7 +20,7 @@
#include "unicode/utypes.h"
-#if !UCONFIG_NO_FORMATTING
+#if !UCONFIG_NO_FORMATTING && !UCONFIG_NO_CONVERSION
#include "unicode/ustdio.h"
#include "unicode/ustring.h"
@@ -28,14 +28,18 @@
#include "unicode/udat.h"
#include "unicode/putil.h"
+#include "cmemory.h"
+#include "locbund.h"
+#include "mutex.h"
+#include "uassert.h"
#include "uprintf.h"
#include "ufile.h"
#include "ucln_io.h"
-#include "locbund.h"
-#include "cmemory.h"
+U_NAMESPACE_USE
static UFILE *gStdOut = NULL;
+static UInitOnce gStdOutInitOnce = U_INITONCE_INITIALIZER;
static UBool U_CALLCONV uprintf_cleanup(void)
{
@@ -43,16 +47,20 @@ static UBool U_CALLCONV uprintf_cleanup(void)
u_fclose(gStdOut);
gStdOut = NULL;
}
+ gStdOutInitOnce.reset();
return TRUE;
}
+static void U_CALLCONV u_stdout_init() {
+ U_ASSERT(gStdOut == NULL);
+ gStdOut = u_finit(stdout, NULL, NULL);
+ ucln_io_registerCleanup(UCLN_IO_PRINTF, &uprintf_cleanup);
+}
+
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);
- }
+ umtx_initOnce(gStdOutInitOnce, &u_stdout_init);
return gStdOut;
}
@@ -161,7 +169,7 @@ u_vfprintf( UFILE *f,
int32_t count;
UChar *pattern;
UChar buffer[UFMT_DEFAULT_BUFFER_SIZE];
- int32_t size = (int32_t)strlen(patternSpecification) + 1;
+ size_t size = strlen(patternSpecification) + 1;
/* convert from the default codepage to Unicode */
if (size >= MAX_UCHAR_BUFFER_SIZE(buffer)) {
« no previous file with comments | « source/io/uprintf.c ('k') | source/io/uprntf_p.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698