* Fixed broken FormatMonetary() versions which also fixes a warning.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34297 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-11-26 19:48:15 +00:00
parent 0d70a99f23
commit c668114b36
+13 -6
View File
@@ -1,7 +1,8 @@
/* /*
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved. * Copyright 2003-2009, Axel Dörfler, [email protected].
** Distributed under the terms of the OpenBeOS License. * Copyright 2009, Destugues, [email protected].
*/ * Distributed under the terms of the MIT License.
*/
#include <Country.h> #include <Country.h>
@@ -425,14 +426,20 @@ ssize_t
BCountry::FormatMonetary(char* string, size_t maxSize, double value) BCountry::FormatMonetary(char* string, size_t maxSize, double value)
{ {
BString fullString; BString fullString;
FormatMonetary(&fullString, value); ssize_t written = FormatMonetary(&fullString, value);
strncpy(string, fullString.String(), maxSize); if (written < 0)
return written;
return strlcpy(string, fullString.String(), maxSize);
} }
ssize_t ssize_t
BCountry::FormatMonetary(BString* string, double value) BCountry::FormatMonetary(BString* string, double value)
{ {
if (string == NULL)
return B_BAD_VALUE;
UErrorCode err; UErrorCode err;
NumberFormat* numberFormatter NumberFormat* numberFormatter
= NumberFormat::createCurrencyInstance(*fICULocale, err); = NumberFormat::createCurrencyInstance(*fICULocale, err);
@@ -447,7 +454,7 @@ BCountry::FormatMonetary(BString* string, double value)
ICUString.toUTF8(stringConverter); ICUString.toUTF8(stringConverter);
return B_OK; return string->Length();
} }