From 8e5113cc6255d0765501c26c20ded7107b9df8e5 Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Thu, 17 Aug 2006 05:21:06 +0000 Subject: [PATCH] ICU-5254 Fix for MinGW X-SVN-Rev: 20078 --- icu4c/source/i18n/winnmfmt.cpp | 14 ++++++++++---- icu4c/source/test/intltest/winnmtst.cpp | 15 +++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/icu4c/source/i18n/winnmfmt.cpp b/icu4c/source/i18n/winnmfmt.cpp index 175b89e171e..32b1cd7c137 100644 --- a/icu4c/source/i18n/winnmfmt.cpp +++ b/icu4c/source/i18n/winnmfmt.cpp @@ -23,6 +23,7 @@ #include "unicode/ustring.h" #include "cmemory.h" +#include "uassert.h" #include "locmap.h" # define WIN32_LEAN_AND_MEAN @@ -234,11 +235,16 @@ UnicodeString &Win32NumberFormat::format(int32_t numDigits, UnicodeString &appen nBuffer[0] = 0x0000; + /* Due to the arguments causing a result to be <= 23 characters (+2 for NULL and minus), + we don't need to reallocate the buffer. */ va_start(args, fmt); result = _vsnwprintf(nBuffer, STACK_BUFFER_SIZE, fmt, args); va_end(args); - if (result < 0) { + /* Just to make sure of the above statement, we add this assert */ + U_ASSERT(result >=0); + // The following code is not used because _vscwprintf isn't available on MinGW at the moment. + /*if (result < 0) { int newLength; va_start(args, fmt); @@ -250,7 +256,7 @@ UnicodeString &Win32NumberFormat::format(int32_t numDigits, UnicodeString &appen va_start(args, fmt); result = _vsnwprintf(nBuffer, newLength + 1, fmt, args); va_end(args); - } + }*/ // vswprintf is sensitive to the locale set by setlocale. For some locales // it doesn't use "." as the decimal separator, which is what GetNumberFormatW @@ -325,9 +331,9 @@ UnicodeString &Win32NumberFormat::format(int32_t numDigits, UnicodeString &appen DELETE_ARRAY(buffer); } - if (nBuffer != nStackBuffer) { + /*if (nBuffer != nStackBuffer) { DELETE_ARRAY(nBuffer); - } + }*/ return appendTo; } diff --git a/icu4c/source/test/intltest/winnmtst.cpp b/icu4c/source/test/intltest/winnmtst.cpp index 976bc5e5849..dfbf200bff0 100644 --- a/icu4c/source/test/intltest/winnmtst.cpp +++ b/icu4c/source/test/intltest/winnmtst.cpp @@ -30,6 +30,7 @@ #include "cstring.h" #include "locmap.h" #include "wintz.h" +#include "uassert.h" # define WIN32_LEAN_AND_MEAN # define VC_EXTRALEAN @@ -137,11 +138,16 @@ static UnicodeString &getWindowsFormat(int32_t lcid, UBool currency, UnicodeStri nBuffer[0] = 0x0000; + /* Due to the arguments causing a result to be <= 23 characters (+2 for NULL and minus), + we don't need to reallocate the buffer. */ va_start(args, fmt); result = _vsnwprintf(nBuffer, STACK_BUFFER_SIZE, fmt, args); va_end(args); - if (result < 0) { + /* Just to make sure of the above statement, we add this assert */ + U_ASSERT(result >=0); + // The following code is not used because _vscwprintf isn't available on MinGW at the moment. + /*if (result < 0) { int newLength; va_start(args, fmt); @@ -153,7 +159,8 @@ static UnicodeString &getWindowsFormat(int32_t lcid, UBool currency, UnicodeStri va_start(args, fmt); result = _vsnwprintf(nBuffer, newLength + 1, fmt, args); va_end(args); - } + }*/ + // vswprintf is sensitive to the locale set by setlocale. For some locales // it doesn't use "." as the decimal separator, which is what GetNumberFormatW @@ -212,9 +219,9 @@ static UnicodeString &getWindowsFormat(int32_t lcid, UBool currency, UnicodeStri DELETE_ARRAY(buffer); } - if (nBuffer != nStackBuffer) { + /*if (nBuffer != nStackBuffer) { DELETE_ARRAY(nBuffer); - } + }*/ return appendTo; }