diff options
author | George Hazan <george.hazan@gmail.com> | 2013-08-19 19:04:33 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-08-19 19:04:33 +0000 |
commit | 664200e644b45e52c70affa1c036d7366474ae9d (patch) | |
tree | d05be80055dae5be865e2a56c14d7f6d0ad0fa06 /src/core | |
parent | 857add6ec30c59d98482c21c60e13f8c3adb89e9 (diff) |
core *printf patch
git-svn-id: http://svn.miranda-ng.org/main/trunk@5750 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/stdchat/src/clist.cpp | 2 | ||||
-rw-r--r-- | src/core/stdchat/src/log.cpp | 13 | ||||
-rw-r--r-- | src/core/stdchat/src/main.cpp | 2 | ||||
-rw-r--r-- | src/core/stdchat/src/options.cpp | 12 | ||||
-rw-r--r-- | src/core/stdchat/src/tools.cpp | 2 | ||||
-rw-r--r-- | src/core/stdchat/src/window.cpp | 8 | ||||
-rw-r--r-- | src/core/stdclist/src/clcfonts.cpp | 2 | ||||
-rw-r--r-- | src/core/stdclist/src/cluiopts.cpp | 4 | ||||
-rw-r--r-- | src/core/stdfile/filexferdlg.cpp | 5 | ||||
-rw-r--r-- | src/core/stdmsg/src/msglog.cpp | 17 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgs.cpp | 2 |
11 files changed, 36 insertions, 33 deletions
diff --git a/src/core/stdchat/src/clist.cpp b/src/core/stdchat/src/clist.cpp index a4fac02a9d..8ddc8c40d8 100644 --- a/src/core/stdchat/src/clist.cpp +++ b/src/core/stdchat/src/clist.cpp @@ -259,7 +259,7 @@ BOOL CList_AddEvent(HANDLE hContact, HICON hIcon, HANDLE hEvent, int type, TCHAR return FALSE;
va_start(marker, fmt);
- _vsntprintf(szBuf, SIZEOF(szBuf), fmt, marker);
+ mir_vsntprintf(szBuf, SIZEOF(szBuf), fmt, marker);
va_end(marker);
cle.cbSize = sizeof(cle);
diff --git a/src/core/stdchat/src/log.cpp b/src/core/stdchat/src/log.cpp index 85b52d5262..0a465fa7dd 100644 --- a/src/core/stdchat/src/log.cpp +++ b/src/core/stdchat/src/log.cpp @@ -114,7 +114,7 @@ static int Log_AppendRTF(LOGSTREAMDATA* streamData, BOOL simpleMode, char **buff char* d;
va_start(va, fmt);
- lineLen = _vsntprintf( line, 8000, fmt, va);
+ lineLen = mir_vsntprintf( line, 8000, fmt, va);
if (lineLen < 0) lineLen = 8000;
line[lineLen] = 0;
va_end(va);
@@ -216,7 +216,7 @@ static int Log_AppendRTF(LOGSTREAMDATA* streamData, BOOL simpleMode, char **buff else if (*line > 0 && *line < 128) {
*d++ = (char) *line;
}
- else d += sprintf(d, "\\u%u ?", (WORD)*line);
+ else d += sprintf(d, "\\u%u ?", (WORD)*line); //!!!!!!!!!!!
}
*cbBufferEnd = (int) (d - *buffer);
@@ -681,8 +681,9 @@ void LoadMsgLogBitmaps(void) pBmpBits = (PBYTE) mir_alloc(widthBytes * bih.biHeight);
for (i = 0; i < SIZEOF(pLogIconBmpBits); i++) {
hIcon = hIcons[i];
- pLogIconBmpBits[i] = (PBYTE) mir_alloc(RTFPICTHEADERMAXSIZE + (bih.biSize + widthBytes * bih.biHeight) * 2);
- rtfHeaderSize = sprintf((char *)pLogIconBmpBits[i], "{\\pict\\dibitmap0\\wbmbitspixel%u\\wbmplanes1\\wbmwidthbytes%u\\picw%u\\pich%u ", bih.biBitCount, widthBytes, bih.biWidth, bih.biHeight);
+ size_t size = RTFPICTHEADERMAXSIZE + (bih.biSize + widthBytes * bih.biHeight) * 2;
+ pLogIconBmpBits[i] = (PBYTE) mir_alloc(size);
+ rtfHeaderSize = mir_snprintf((char *)pLogIconBmpBits[i], size, "{\\pict\\dibitmap0\\wbmbitspixel%u\\wbmplanes1\\wbmwidthbytes%u\\picw%u\\pich%u ", bih.biBitCount, widthBytes, bih.biWidth, bih.biHeight);
hoBmp = (HBITMAP) SelectObject(hdcMem, hBmp);
FillRect(hdcMem, &rc, hBkgBrush);
DrawIconEx(hdcMem, 0, 0, hIcon, bih.biWidth, bih.biHeight, 0, NULL, DI_NORMAL);
@@ -691,9 +692,9 @@ void LoadMsgLogBitmaps(void) {
int n;
for (n = 0; n < sizeof(BITMAPINFOHEADER); n++)
- sprintf((char *)pLogIconBmpBits[i] + rtfHeaderSize + n * 2, "%02X", ((PBYTE) & bih)[n]);
+ sprintf((char *)pLogIconBmpBits[i] + rtfHeaderSize + n * 2, "%02X", ((PBYTE) & bih)[n]); //!!!!!!!!!!!!!
for (n = 0; n < widthBytes * bih.biHeight; n += 4)
- sprintf((char *)pLogIconBmpBits[i] + rtfHeaderSize + (bih.biSize + n) * 2, "%02X%02X%02X%02X", pBmpBits[n], pBmpBits[n + 1], pBmpBits[n + 2], pBmpBits[n + 3]);
+ sprintf((char *)pLogIconBmpBits[i] + rtfHeaderSize + (bih.biSize + n) * 2, "%02X%02X%02X%02X", pBmpBits[n], pBmpBits[n + 1], pBmpBits[n + 2], pBmpBits[n + 3]); //!!!!!!!!!!!!!
}
logIconBmpSize[i] = rtfHeaderSize + (bih.biSize + widthBytes * bih.biHeight) * 2 + 1;
pLogIconBmpBits[i][logIconBmpSize[i] - 1] = '}';
diff --git a/src/core/stdchat/src/main.cpp b/src/core/stdchat/src/main.cpp index b2985d4098..edb254145a 100644 --- a/src/core/stdchat/src/main.cpp +++ b/src/core/stdchat/src/main.cpp @@ -258,7 +258,7 @@ STDMETHODIMP CREOleCallback::GetNewStorage(LPSTORAGE * lplpstg) {
WCHAR szwName[64];
char szName[64];
- wsprintfA(szName, "s%u", nextStgId++);
+ mir_snprintf(szName, SIZEOF(szName), "s%u", nextStgId++);
MultiByteToWideChar(CP_ACP, 0, szName, -1, szwName, SIZEOF(szwName));
if (pictStg == NULL)
return STG_E_MEDIUMFULL;
diff --git a/src/core/stdchat/src/options.cpp b/src/core/stdchat/src/options.cpp index b49684e9a5..96dc9f1cf3 100644 --- a/src/core/stdchat/src/options.cpp +++ b/src/core/stdchat/src/options.cpp @@ -326,28 +326,28 @@ void LoadMsgDlgFont(int i, LOGFONT* lf, COLORREF* colour) DBVARIANT dbv;
if (colour) {
- wsprintfA(str, "Font%dCol", i);
+ mir_snprintf(str, SIZEOF(str), "Font%dCol", i);
*colour = db_get_dw(NULL, "ChatFonts", str, fontOptionsList[i].defColour);
}
if (lf) {
- wsprintfA(str, "Font%dSize", i);
+ mir_snprintf(str, SIZEOF(str), "Font%dSize", i);
lf->lfHeight = (char) db_get_b(NULL, "ChatFonts", str, fontOptionsList[i].defSize);
lf->lfWidth = 0;
lf->lfEscapement = 0;
lf->lfOrientation = 0;
- wsprintfA(str, "Font%dSty", i);
+ mir_snprintf(str, SIZEOF(str), "Font%dSty", i);
style = db_get_b(NULL, "ChatFonts", str, fontOptionsList[i].defStyle);
lf->lfWeight = style & FONTF_BOLD ? FW_BOLD : FW_NORMAL;
lf->lfItalic = style & FONTF_ITALIC ? 1 : 0;
lf->lfUnderline = 0;
lf->lfStrikeOut = 0;
- wsprintfA(str, "Font%dSet", i);
+ mir_snprintf(str, SIZEOF(str), "Font%dSet", i);
lf->lfCharSet = db_get_b(NULL, "ChatFonts", str, fontOptionsList[i].defCharset);
lf->lfOutPrecision = OUT_DEFAULT_PRECIS;
lf->lfClipPrecision = CLIP_DEFAULT_PRECIS;
lf->lfQuality = DEFAULT_QUALITY;
lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
- wsprintfA(str, "Font%d", i);
+ mir_snprintf(str, SIZEOF(str), "Font%d", i);
if (db_get_ts(NULL, "ChatFonts", str, &dbv))
lstrcpy(lf->lfFaceName, fontOptionsList[i].szDefFace);
else {
@@ -368,7 +368,7 @@ void RegisterFonts( void ) strncpy(fontid.dbSettingsGroup, "ChatFonts", sizeof(fontid.dbSettingsGroup));
_tcsncpy(fontid.group, _T("Chat Module"), SIZEOF(fontid.group));
_tcsncpy(fontid.name, fontOptionsList[i].szDescr, SIZEOF(fontid.name));
- sprintf(idstr, "Font%d", index);
+ mir_snprintf(idstr, SIZEOF(idstr), "Font%d", index);
strncpy(fontid.prefix, idstr, sizeof(fontid.prefix));
fontid.order = index;
diff --git a/src/core/stdchat/src/tools.cpp b/src/core/stdchat/src/tools.cpp index b72ee32fac..ce06d7e015 100644 --- a/src/core/stdchat/src/tools.cpp +++ b/src/core/stdchat/src/tools.cpp @@ -133,7 +133,7 @@ static int ShowPopup (HANDLE hContact, SESSION_INFO* si, HICON hIcon, char* psz return 0;
va_start(marker, fmt);
- _vsntprintf(szBuf, 4096, fmt, marker);
+ mir_vsntprintf(szBuf, 4096, fmt, marker);
va_end(marker);
pd.lchContact = hContact;
diff --git a/src/core/stdchat/src/window.cpp b/src/core/stdchat/src/window.cpp index c56f80b6c7..3308ceb167 100644 --- a/src/core/stdchat/src/window.cpp +++ b/src/core/stdchat/src/window.cpp @@ -1111,13 +1111,13 @@ static int RestoreWindowPosition(HWND hwnd, HANDLE hContact, char * szModule, ch wp.length=sizeof(wp);
GetWindowPlacement(hwnd,&wp);
- wsprintfA(szSettingName,"%sx",szNamePrefix);
+ mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sx", szNamePrefix);
x=db_get_dw(hContact,szModule,szSettingName,-1);
- wsprintfA(szSettingName,"%sy",szNamePrefix);
+ mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sy", szNamePrefix);
y=(int)db_get_dw(hContact,szModule,szSettingName,-1);
- wsprintfA(szSettingName,"%swidth",szNamePrefix);
+ mir_snprintf(szSettingName, SIZEOF(szSettingName), "%swidth", szNamePrefix);
width=db_get_dw(hContact,szModule,szSettingName,-1);
- wsprintfA(szSettingName,"%sheight",szNamePrefix);
+ mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sheight", szNamePrefix);
height=db_get_dw(hContact,szModule,szSettingName,-1);
if (x==-1)
diff --git a/src/core/stdclist/src/clcfonts.cpp b/src/core/stdclist/src/clcfonts.cpp index 1996b7b895..dcb4e658cf 100644 --- a/src/core/stdclist/src/clcfonts.cpp +++ b/src/core/stdclist/src/clcfonts.cpp @@ -97,7 +97,7 @@ void RegisterCListFonts() strncpy(fontid.dbSettingsGroup, "CLC", sizeof(fontid.dbSettingsGroup));
_tcsncpy(fontid.group, _T("Contact List"), SIZEOF(fontid.group));
_tcsncpy(fontid.name, szClistFontIdDescr[fontListOrder[i]], SIZEOF(fontid.name));
- sprintf(idstr, "Font%d", fontListOrder[i]);
+ mir_snprintf(idstr, SIZEOF(idstr), "Font%d", fontListOrder[i]);
strncpy(fontid.prefix, idstr, SIZEOF(fontid.prefix));
fontid.order = fontListOrder[i];
diff --git a/src/core/stdclist/src/cluiopts.cpp b/src/core/stdclist/src/cluiopts.cpp index d3e248056e..efd9c9fb92 100644 --- a/src/core/stdclist/src/cluiopts.cpp +++ b/src/core/stdclist/src/cluiopts.cpp @@ -148,9 +148,9 @@ static INT_PTR CALLBACK DlgProcCluiOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L case WM_HSCROLL:
{
char str[10];
- wsprintfA(str, "%d%%", 100 * SendDlgItemMessage(hwndDlg, IDC_TRANSINACTIVE, TBM_GETPOS, 0, 0) / 255);
+ mir_snprintf(str, SIZEOF(str), "%d%%", 100 * SendDlgItemMessage(hwndDlg, IDC_TRANSINACTIVE, TBM_GETPOS, 0, 0) / 255);
SetDlgItemTextA(hwndDlg, IDC_INACTIVEPERC, str);
- wsprintfA(str, "%d%%", 100 * SendDlgItemMessage(hwndDlg, IDC_TRANSACTIVE, TBM_GETPOS, 0, 0) / 255);
+ mir_snprintf(str, SIZEOF(str), "%d%%", 100 * SendDlgItemMessage(hwndDlg, IDC_TRANSACTIVE, TBM_GETPOS, 0, 0) / 255);
SetDlgItemTextA(hwndDlg, IDC_ACTIVEPERC, str);
}
if (wParam != 0x12345678)
diff --git a/src/core/stdfile/filexferdlg.cpp b/src/core/stdfile/filexferdlg.cpp index 593008551e..bb69fdd495 100644 --- a/src/core/stdfile/filexferdlg.cpp +++ b/src/core/stdfile/filexferdlg.cpp @@ -493,9 +493,10 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if ((pszFilename = _tcsrchr(szOriginalFilename, '\\')) == NULL) pszFilename = szOriginalFilename;
if ((pszExtension = _tcsrchr(pszFilename+1, '.')) == NULL) pszExtension = pszFilename+lstrlen(pszFilename);
if (pfr->szFilename) mir_free((TCHAR*)pfr->szFilename);
- pfr->szFilename = (TCHAR*)mir_alloc(sizeof(TCHAR)*((pszExtension-szOriginalFilename)+21+lstrlen(pszExtension)));
+ size_t size = (pszExtension-szOriginalFilename)+21+lstrlen(pszExtension);
+ pfr->szFilename = (TCHAR*)mir_alloc(sizeof(TCHAR)*size);
for (i = 1;;i++) {
- _stprintf((TCHAR*)pfr->szFilename, _T("%.*s (%u)%s"), pszExtension-szOriginalFilename, szOriginalFilename, i, pszExtension);
+ mir_sntprintf((TCHAR*)pfr->szFilename, size, _T("%.*s (%u)%s"), pszExtension-szOriginalFilename, szOriginalFilename, i, pszExtension);
if (_taccess(pfr->szFilename, 0) != 0)
break;
}
diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp index f2c82f8a9f..53f1ef7582 100644 --- a/src/core/stdmsg/src/msglog.cpp +++ b/src/core/stdmsg/src/msglog.cpp @@ -143,7 +143,7 @@ static int AppendToBufferWithRTF(char **buffer, int *cbBufferEnd, int *cbBufferA {
*tag = 0;
*tage = 0;
- d += sprintf(d, "{\\field{\\*\\fldinst HYPERLINK \"%s\"}{\\fldrslt %s}}", mir_t2a(tagu), mir_t2a(tag + 1));
+ d += sprintf(d, "{\\field{\\*\\fldinst HYPERLINK \"%s\"}{\\fldrslt %s}}", mir_t2a(tagu), mir_t2a(tag + 1)); //!!!!!!!!!!
line = tage + 5;
found = 1;
}
@@ -167,11 +167,11 @@ static int AppendToBufferWithRTF(char **buffer, int *cbBufferEnd, int *cbBufferA if (!found)
{
if (*line < 128) *d++ = (char) *line;
- else d += sprintf(d, "\\u%d ?", *line);
+ else d += sprintf(d, "\\u%d ?", *line); //!!!!!!!!!!
}
}
else if (*line < 128) *d++ = (char) *line;
- else d += sprintf(d, "\\u%d ?", *line);
+ else d += sprintf(d, "\\u%d ?", *line); //!!!!!!!!!!
}
*(d++) = '}';
@@ -239,7 +239,7 @@ static char *SetToStyle(int style) LOGFONT lf;
LoadMsgDlgFont(style, &lf, NULL);
- wsprintfA(szStyle, "\\f%u\\cf%u\\b%d\\i%d\\fs%u", style, style, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / logPixelSY);
+ mir_snprintf(szStyle, SIZEOF(szStyle), "\\f%u\\cf%u\\b%d\\i%d\\fs%u", style, style, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / logPixelSY);
return szStyle;
}
@@ -606,9 +606,10 @@ void LoadMsgLogIcons(void) for (i = 0; i < SIZEOF(pLogIconBmpBits); i++) {
hIcon = Skin_GetIconByHandle(iconList[i].hIcolib);
- pLogIconBmpBits[i] = (PBYTE) mir_alloc(RTFPICTHEADERMAXSIZE + (bih.biSize + widthBytes * bih.biHeight) * 2);
+ size_t size = RTFPICTHEADERMAXSIZE + (bih.biSize + widthBytes * bih.biHeight) * 2;
+ pLogIconBmpBits[i] = (PBYTE) mir_alloc(size);
//I can't seem to get binary mode working. No matter.
- rtfHeaderSize = sprintf((char*)pLogIconBmpBits[i], "{\\pict\\dibitmap0\\wbmbitspixel%u\\wbmplanes1\\wbmwidthbytes%u\\picw%u\\pich%u ", bih.biBitCount, widthBytes, bih.biWidth, bih.biHeight);
+ rtfHeaderSize = mir_snprintf((char*)pLogIconBmpBits[i], size, "{\\pict\\dibitmap0\\wbmbitspixel%u\\wbmplanes1\\wbmwidthbytes%u\\picw%u\\pich%u ", bih.biBitCount, widthBytes, bih.biWidth, bih.biHeight);
hoBmp = (HBITMAP) SelectObject(hdcMem, hBmp);
FillRect(hdcMem, &rc, hBkgBrush);
DrawIconEx(hdcMem, 0, 0, hIcon, bih.biWidth, bih.biHeight, 0, NULL, DI_NORMAL);
@@ -619,9 +620,9 @@ void LoadMsgLogIcons(void) {
int n;
for (n = 0; n < sizeof(BITMAPINFOHEADER); n++)
- sprintf((char*)pLogIconBmpBits[i] + rtfHeaderSize + n * 2, "%02X", ((PBYTE) & bih)[n]);
+ sprintf((char*)pLogIconBmpBits[i] + rtfHeaderSize + n * 2, "%02X", ((PBYTE) & bih)[n]); //!!!!!!!!!!!!!
for (n = 0; n < widthBytes * bih.biHeight; n += 4)
- sprintf((char*)pLogIconBmpBits[i] + rtfHeaderSize + (bih.biSize + n) * 2, "%02X%02X%02X%02X", pBmpBits[n], pBmpBits[n + 1], pBmpBits[n + 2], pBmpBits[n + 3]);
+ sprintf((char*)pLogIconBmpBits[i] + rtfHeaderSize + (bih.biSize + n) * 2, "%02X%02X%02X%02X", pBmpBits[n], pBmpBits[n + 1], pBmpBits[n + 2], pBmpBits[n + 3]); //!!!!!!!!!!!!!
}
logIconBmpSize[i] = rtfHeaderSize + (bih.biSize + widthBytes * bih.biHeight) * 2 + 1;
pLogIconBmpBits[i][logIconBmpSize[i] - 1] = '}';
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 016dcdc765..b8c1298ad8 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -516,7 +516,7 @@ STDMETHODIMP CREOleCallback::GetNewStorage(LPSTORAGE * lplpstg) {
WCHAR szwName[64];
char szName[64];
- wsprintfA(szName, "s%u", nextStgId++);
+ mir_snprintf(szName, SIZEOF(szName), "s%u", nextStgId++);
MultiByteToWideChar(CP_ACP, 0, szName, -1, szwName, SIZEOF(szwName));
if (pictStg == NULL)
return STG_E_MEDIUMFULL;
|