From c668114b36b95fd63b62e30699b9bea51f08066b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 26 Nov 2009 19:48:15 +0000 Subject: [PATCH] * 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 --- src/kits/locale/Country.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/kits/locale/Country.cpp b/src/kits/locale/Country.cpp index cd3d433dbb..46f2dcca47 100644 --- a/src/kits/locale/Country.cpp +++ b/src/kits/locale/Country.cpp @@ -1,7 +1,8 @@ -/* -** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ +/* + * Copyright 2003-2009, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2009, Destugues, pulkomandy@gmail.com. + * Distributed under the terms of the MIT License. + */ #include @@ -425,14 +426,20 @@ ssize_t BCountry::FormatMonetary(char* string, size_t maxSize, double value) { BString fullString; - FormatMonetary(&fullString, value); - strncpy(string, fullString.String(), maxSize); + ssize_t written = FormatMonetary(&fullString, value); + if (written < 0) + return written; + + return strlcpy(string, fullString.String(), maxSize); } ssize_t BCountry::FormatMonetary(BString* string, double value) { + if (string == NULL) + return B_BAD_VALUE; + UErrorCode err; NumberFormat* numberFormatter = NumberFormat::createCurrencyInstance(*fICULocale, err); @@ -447,7 +454,7 @@ BCountry::FormatMonetary(BString* string, double value) ICUString.toUTF8(stringConverter); - return B_OK; + return string->Length(); }