diff options
author | George Hazan <george.hazan@gmail.com> | 2013-07-26 20:19:11 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-07-26 20:19:11 +0000 |
commit | 53ee3b7f1d7b8571827e88832ded5ce786ac8cf9 (patch) | |
tree | dc89899495d6e0b9d810260b856c1ae24ac82d02 | |
parent | da6b6d88e3fb3e28959f82969665880a5d90993b (diff) |
fix for formatting numbers
git-svn-id: http://svn.miranda-ng.org/main/trunk@5494 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/Weather/src/weather_conv.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/plugins/Weather/src/weather_conv.cpp b/plugins/Weather/src/weather_conv.cpp index a86ac070c4..85e6e703a1 100644 --- a/plugins/Weather/src/weather_conv.cpp +++ b/plugins/Weather/src/weather_conv.cpp @@ -48,7 +48,7 @@ BOOL is_number(TCHAR *s) return FALSE;
}
-static void numToStr(double num, TCHAR* str)
+static void numToStr(double num, TCHAR *str, size_t strSize)
{
int i = (int)(num * (opt.NoFrac ? 10 : 100));
int u = abs(i);
@@ -65,9 +65,9 @@ static void numToStr(double num, TCHAR* str) if (i < 0 && (w || r)) *(str++) = '-';
if (r)
- mir_sntprintf(str, SIZEOF(str), _T("%i.%i"), w, r);
+ mir_sntprintf(str, strSize, _T("%i.%i"), w, r);
else
- mir_sntprintf(str, SIZEOF(str), _T("%i"), w);
+ mir_sntprintf(str, strSize, _T("%i"), w);
}
//============ UNIT CONVERSIONS ============
@@ -107,7 +107,7 @@ void GetTemp(TCHAR *tempchar, TCHAR *unit, TCHAR* str) switch (opt.tUnit) {
case 1:
// rounding
- numToStr((temp-32)/9*5, tstr);
+ numToStr((temp-32)/9*5, tstr, SIZEOF(tstr));
if (opt.DoNotAppendUnit)
mir_sntprintf(str, SIZEOF(str), _T("%s"), tstr);
else
@@ -115,7 +115,7 @@ void GetTemp(TCHAR *tempchar, TCHAR *unit, TCHAR* str) break;
case 2:
- numToStr(temp, tstr);
+ numToStr(temp, tstr, SIZEOF(tstr));
if (opt.DoNotAppendUnit)
mir_sntprintf(str, SIZEOF(str), _T("%s"), tstr);
else
@@ -212,19 +212,19 @@ void GetSpeed(TCHAR *tempchar, TCHAR *unit, TCHAR *str) // convert to apporiate unit
switch (opt.wUnit) {
case 1:
- numToStr(tempunit * 3.6, tstr);
+ numToStr(tempunit * 3.6, tstr, SIZEOF(tstr));
mir_sntprintf(str, SIZEOF(str), _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("km/h"));
break;
case 2:
- numToStr(tempunit, tstr);
+ numToStr(tempunit, tstr, SIZEOF(tstr));
mir_sntprintf(str, SIZEOF(str), _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("m/s"));
break;
case 3:
- numToStr(tempunit / 0.44704, tstr);
+ numToStr(tempunit / 0.44704, tstr, SIZEOF(tstr));
mir_sntprintf(str, SIZEOF(str), _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("mph"));
break;
case 4:
- numToStr(tempunit / 0.514444, tstr);
+ numToStr(tempunit / 0.514444, tstr, SIZEOF(tstr));
mir_sntprintf(str, SIZEOF(str), _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("knots"));
break;
}
|