summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRozhuk Ivan <rozhuk.im@gmail.com>2014-12-09 00:59:27 +0000
committerRozhuk Ivan <rozhuk.im@gmail.com>2014-12-09 00:59:27 +0000
commit36472b00443e23acf28b0dd26ddc2c2e6216d909 (patch)
treea526bbc6d309e05f1728b772620c9272f9ab8c4a /src
parent163ce5127e5c8244bccbdae72107ad101f70575f (diff)
code cleanup over mir_sntprintf + small bug fix
git-svn-id: http://svn.miranda-ng.org/main/trunk@11295 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r--src/core/stdchat/src/tools.cpp2
-rw-r--r--src/core/stdchat/src/window.cpp13
-rw-r--r--src/modules/chat/tools.cpp8
-rw-r--r--src/modules/database/database.cpp2
-rw-r--r--src/modules/icolib/skin2opts.cpp2
5 files changed, 14 insertions, 13 deletions
diff --git a/src/core/stdchat/src/tools.cpp b/src/core/stdchat/src/tools.cpp
index 61f4679a40..38301b960b 100644
--- a/src/core/stdchat/src/tools.cpp
+++ b/src/core/stdchat/src/tools.cpp
@@ -135,7 +135,7 @@ UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO
if (pszWordText && pszWordText[0]) {
TCHAR szMenuText[4096];
- mir_sntprintf(szMenuText, 4096, TranslateT("Look up '%s':"), pszWordText);
+ mir_sntprintf(szMenuText, SIZEOF(szMenuText), TranslateT("Look up '%s':"), pszWordText);
ModifyMenu(*hMenu, 4, MF_STRING | MF_BYPOSITION, 4, szMenuText);
}
else ModifyMenu(*hMenu, 4, MF_STRING | MF_GRAYED | MF_BYPOSITION, 4, TranslateT("No word to look up"));
diff --git a/src/core/stdchat/src/window.cpp b/src/core/stdchat/src/window.cpp
index 75be4f1bbc..4a73524523 100644
--- a/src/core/stdchat/src/window.cpp
+++ b/src/core/stdchat/src/window.cpp
@@ -2295,11 +2295,12 @@ LABEL_SHOWWINDOW:
if (GetKeyState(VK_SHIFT) & 0x8000) {
LRESULT lResult = (LRESULT)SendMessage(GetDlgItem(hwndDlg, IDC_MESSAGE), EM_GETSEL, 0, 0);
int start = LOWORD(lResult);
- TCHAR* pszName = (TCHAR*)alloca(sizeof(TCHAR)*(mir_tstrlen(ui->pszUID) + 3));
+ size_t dwNameLenMax = (mir_tstrlen(ui->pszUID) + 3);
+ TCHAR* pszName = (TCHAR*)alloca(sizeof(TCHAR) * dwNameLenMax);
if (start == 0)
- mir_sntprintf(pszName, mir_tstrlen(ui->pszUID) + 3, _T("%s: "), ui->pszUID);
+ mir_sntprintf(pszName, dwNameLenMax, _T("%s: "), ui->pszUID);
else
- mir_sntprintf(pszName, mir_tstrlen(ui->pszUID) + 2, _T("%s "), ui->pszUID);
+ mir_sntprintf(pszName, dwNameLenMax, _T("%s "), ui->pszUID);
SendMessage(GetDlgItem(hwndDlg, IDC_MESSAGE), EM_REPLACESEL, FALSE, (LPARAM)pszName);
PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0);
@@ -2390,11 +2391,11 @@ LABEL_SHOWWINDOW:
_tcsncpy_s(szName, (pInfo->ptszModDispName ? pInfo->ptszModDispName : _A2T(si->pszModule)), _TRUNCATE);
ValidateFilename(szName);
- mir_sntprintf(szFolder, MAX_PATH, _T("%s\\%s"), g_Settings.pszLogDir, szName);
- mir_sntprintf(szName, MAX_PATH, _T("%s.log"), si->ptszID);
+ mir_sntprintf(szFolder, SIZEOF(szFolder), _T("%s\\%s"), g_Settings.pszLogDir, szName);
+ mir_sntprintf(szName, SIZEOF(szName), _T("%s.log"), si->ptszID);
ValidateFilename(szName);
- mir_sntprintf(szFile, MAX_PATH, _T("%s\\%s"), szFolder, szName);
+ mir_sntprintf(szFile, SIZEOF(szFile), _T("%s\\%s"), szFolder, szName);
ShellExecute(hwndDlg, _T("open"), szFile, NULL, NULL, SW_SHOW);
}
}
diff --git a/src/modules/chat/tools.cpp b/src/modules/chat/tools.cpp
index ee64919f10..e18e40b3d0 100644
--- a/src/modules/chat/tools.cpp
+++ b/src/modules/chat/tools.cpp
@@ -182,11 +182,11 @@ int ShowPopup(MCONTACT hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoNa
pd.lchIcon = LoadIconEx("window", FALSE);
PROTOACCOUNT *pa = ProtoGetAccount(pszProtoName);
- mir_sntprintf(pd.lptzContactName, MAX_CONTACTNAME - 1, _T("%s - %s"),
+ mir_sntprintf(pd.lptzContactName, SIZEOF(pd.lptzContactName), _T("%s - %s"),
(pa == NULL) ? _A2T(pszProtoName) : pa->tszAccountName,
cli.pfnGetContactDisplayName(hContact, 0));
- mir_tstrncpy(pd.lptzText, TranslateTS(szBuf), MAX_SECONDLINE);
+ mir_tstrncpy(pd.lptzText, TranslateTS(szBuf), SIZEOF(pd.lptzText));
pd.iSeconds = g_Settings->iPopupTimeout;
if (g_Settings->iPopupStyle == 2) {
@@ -588,11 +588,11 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce)
_tsplitpath(si->pszLogFileName, tszDrive, tszDir, tszName, tszExt);
TCHAR tszNewPath[_MAX_DRIVE + _MAX_DIR + _MAX_FNAME + _MAX_EXT + 20];
- mir_sntprintf(tszNewPath, _MAX_DRIVE + _MAX_DIR + _MAX_FNAME + _MAX_EXT + 20, _T("%s%sarchived\\"), tszDrive, tszDir);
+ mir_sntprintf(tszNewPath, SIZEOF(tszNewPath), _T("%s%sarchived\\"), tszDrive, tszDir);
CreateDirectoryTreeT(tszNewPath);
TCHAR tszNewName[_MAX_DRIVE + _MAX_DIR + _MAX_FNAME + _MAX_EXT + 20];
- mir_sntprintf(tszNewName, _MAX_DRIVE + _MAX_DIR + _MAX_FNAME + _MAX_EXT + 20, _T("%s%s-%s%s"), tszNewPath, tszName, tszTimestamp, tszExt);
+ mir_sntprintf(tszNewName, SIZEOF(tszNewName), _T("%s%s-%s%s"), tszNewPath, tszName, tszTimestamp, tszExt);
fclose(hFile);
hFile = 0;
if (!PathFileExists(tszNewName))
diff --git a/src/modules/database/database.cpp b/src/modules/database/database.cpp
index f4f29460d0..f6b4c2d34b 100644
--- a/src/modules/database/database.cpp
+++ b/src/modules/database/database.cpp
@@ -251,7 +251,7 @@ static int getProfile1(TCHAR *szProfile, size_t cch, TCHAR *profiledir, BOOL * n
continue;
TCHAR newProfile[MAX_PATH];
- mir_sntprintf(newProfile, MAX_PATH, _T("%s\\%s\\%s.dat"), profiledir, ffd.cFileName, ffd.cFileName);
+ mir_sntprintf(newProfile, SIZEOF(newProfile), _T("%s\\%s\\%s.dat"), profiledir, ffd.cFileName, ffd.cFileName);
if (_taccess(newProfile, 0) != 0)
continue;
diff --git a/src/modules/icolib/skin2opts.cpp b/src/modules/icolib/skin2opts.cpp
index ad87d7d418..18f40a2215 100644
--- a/src/modules/icolib/skin2opts.cpp
+++ b/src/modules/icolib/skin2opts.cpp
@@ -551,7 +551,7 @@ INT_PTR CALLBACK DlgProcIconImport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
lvi.mask = LVIF_PARAM;
lvi.iItem = dragItem; lvi.iSubItem = 0;
ListView_GetItem(hPreview, &lvi);
- mir_sntprintf(path, MAX_PATH, _T("%s,%d"), filename, (int)lvi.lParam);
+ mir_sntprintf(path, SIZEOF(path), _T("%s,%d"), filename, (int)lvi.lParam);
SendMessage(hwndParent, DM_CHANGEICON, dropHiLite, (LPARAM)path);
ListView_SetItemState( GetDlgItem(hwndParent, IDC_PREVIEW), dropHiLite, 0, LVIS_DROPHILITED);
}