From a757184e5db3112d3de0b69eec7d39b937e396bc Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Thu, 25 Jul 2013 15:32:06 +0000 Subject: replace sprintf to mir_snprintf (part 5) git-svn-id: http://svn.miranda-ng.org/main/trunk@5481 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Weather/src/weather_conv.cpp | 40 ++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'plugins/Weather/src/weather_conv.cpp') diff --git a/plugins/Weather/src/weather_conv.cpp b/plugins/Weather/src/weather_conv.cpp index 565def07cb..a86ac070c4 100644 --- a/plugins/Weather/src/weather_conv.cpp +++ b/plugins/Weather/src/weather_conv.cpp @@ -65,9 +65,9 @@ static void numToStr(double num, TCHAR* str) if (i < 0 && (w || r)) *(str++) = '-'; if (r) - wsprintf(str, _T("%i.%i"), w, r); + mir_sntprintf(str, SIZEOF(str), _T("%i.%i"), w, r); else - wsprintf(str, _T("%i"), w); + mir_sntprintf(str, SIZEOF(str), _T("%i"), w); } //============ UNIT CONVERSIONS ============ @@ -109,17 +109,17 @@ void GetTemp(TCHAR *tempchar, TCHAR *unit, TCHAR* str) // rounding numToStr((temp-32)/9*5, tstr); if (opt.DoNotAppendUnit) - wsprintf(str, _T("%s"), tstr); + mir_sntprintf(str, SIZEOF(str), _T("%s"), tstr); else - wsprintf(str, _T("%s%sC"), tstr, opt.DegreeSign); + mir_sntprintf(str, SIZEOF(str), _T("%s%sC"), tstr, opt.DegreeSign); break; case 2: numToStr(temp, tstr); if (opt.DoNotAppendUnit) - wsprintf(str, _T("%s"), tstr); + mir_sntprintf(str, SIZEOF(str), _T("%s"), tstr); else - wsprintf(str, _T("%s%sF"), tstr, opt.DegreeSign); + mir_sntprintf(str, SIZEOF(str), _T("%s%sF"), tstr, opt.DegreeSign); break; } } @@ -160,19 +160,19 @@ void GetPressure(TCHAR *tempchar, TCHAR *unit, TCHAR* str) switch (opt.pUnit) { case 1: intunit = (int)(tempunit + 0.5); - wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("kPa")); + mir_sntprintf(str, SIZEOF(str), _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("kPa")); break; case 2: intunit = (int)(tempunit + 0.5); - wsprintf(str, _T("%i %s"), intunit, opt.DoNotAppendUnit ? _T("") : TranslateT("mb")); + mir_sntprintf(str, SIZEOF(str), _T("%i %s"), intunit, opt.DoNotAppendUnit ? _T("") : TranslateT("mb")); break; case 3: intunit = (int)((tempunit*10 / 33.86388) + 0.5); - wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("in")); + mir_sntprintf(str, SIZEOF(str), _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("in")); break; case 4: intunit = (int)((tempunit*10 / 1.33322) + 0.5); - wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("mm")); + mir_sntprintf(str, SIZEOF(str), _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("mm")); break; default: _tcscpy(str, tempchar); @@ -213,19 +213,19 @@ void GetSpeed(TCHAR *tempchar, TCHAR *unit, TCHAR *str) switch (opt.wUnit) { case 1: numToStr(tempunit * 3.6, tstr); - wsprintf(str, _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("km/h")); + mir_sntprintf(str, SIZEOF(str), _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("km/h")); break; case 2: numToStr(tempunit, tstr); - wsprintf(str, _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("m/s")); + mir_sntprintf(str, SIZEOF(str), _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("m/s")); break; case 3: numToStr(tempunit / 0.44704, tstr); - wsprintf(str, _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("mph")); + mir_sntprintf(str, SIZEOF(str), _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("mph")); break; case 4: numToStr(tempunit / 0.514444, tstr); - wsprintf(str, _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("knots")); + mir_sntprintf(str, SIZEOF(str), _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("knots")); break; } } @@ -258,11 +258,11 @@ void GetDist(TCHAR *tempchar, TCHAR *unit, TCHAR *str) switch (opt.vUnit) { case 1: intunit = (int)((tempunit*10) + 0.5); - wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("km")); + mir_sntprintf(str, SIZEOF(str), _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("km")); break; case 2: intunit = (int)((tempunit*10 / 1.609) + 0.5); - wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("miles")); + mir_sntprintf(str, SIZEOF(str), _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("miles")); break; default: _tcscpy(str, tempchar); @@ -298,11 +298,11 @@ void GetElev(TCHAR *tempchar, TCHAR *unit, TCHAR *str) switch (opt.eUnit) { case 1: intunit = (int)((tempunit*10 * 3.28) + 0.5); - wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("ft")); + mir_sntprintf(str, SIZEOF(str), _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("ft")); break; case 2: intunit = (int)((tempunit*10) + 0.5); - wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("m")); + mir_sntprintf(str, SIZEOF(str), _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("m")); break; default: _tcscpy(str, tempchar); @@ -550,7 +550,7 @@ TCHAR* GetDisplay(WEATHERINFO *w, const TCHAR *dis, TCHAR* str) name[0] = 0; // read the entire variable name while (dis[i] != ']' && i < _tcslen(dis)) { - wsprintfA(temp, "%c", dis[i++]); + mir_snprintf(temp, SIZEOF(temp), "%c", dis[i++]); strcat(name, temp); } // access the database to get its value @@ -564,7 +564,7 @@ TCHAR* GetDisplay(WEATHERINFO *w, const TCHAR *dis, TCHAR* str) } // if the character is not a variable, write the original character to the new string else { - wsprintf( lpzDate, _T("%c"), dis[i]); + mir_sntprintf(lpzDate, SIZEOF(lpzDate), _T("%c"), dis[i]); _tcscat(str, lpzDate); } } -- cgit v1.2.3