From 4c814798c7bc7f6a0f92c21b027b26290622aa2f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 19 Jun 2015 19:35:42 +0000 Subject: SIZEOF replaced with more secure analog - _countof git-svn-id: http://svn.miranda-ng.org/main/trunk@14270 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/src/chat/log.cpp | 10 ++-- plugins/TabSRMM/src/chat/main.cpp | 4 +- plugins/TabSRMM/src/chat/options.cpp | 102 +++++++++++++++++----------------- plugins/TabSRMM/src/chat/services.cpp | 2 +- plugins/TabSRMM/src/chat/tools.cpp | 6 +- plugins/TabSRMM/src/chat/window.cpp | 30 +++++----- 6 files changed, 77 insertions(+), 77 deletions(-) (limited to 'plugins/TabSRMM/src/chat') diff --git a/plugins/TabSRMM/src/chat/log.cpp b/plugins/TabSRMM/src/chat/log.cpp index 86cb4817cc..0b6fadcd20 100644 --- a/plugins/TabSRMM/src/chat/log.cpp +++ b/plugins/TabSRMM/src/chat/log.cpp @@ -537,7 +537,7 @@ static void AddEventToBuffer(CMStringA &str, LOGSTREAMDATA *streamData) else _tcsncpy_s(szTemp, streamData->lin->ptszNick, _TRUNCATE); if (g_Settings.bClickableNicks) - mir_sntprintf(szTemp2, SIZEOF(szTemp2), _T("~~++#%s#++~~"), szTemp); + mir_sntprintf(szTemp2, _countof(szTemp2), _T("~~++#%s#++~~"), szTemp); else _tcsncpy_s(szTemp2, szTemp, _TRUNCATE); @@ -723,7 +723,7 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData) if (streamData->dat->dwFlags & MWF_DIVIDERWANTED || lin->dwFlags & MWF_DIVIDERWANTED) { static char szStyle_div[128] = "\0"; if (szStyle_div[0] == 0) - mir_snprintf(szStyle_div, SIZEOF(szStyle_div), "\\f%u\\cf%u\\ul0\\b%d\\i%d\\fs%u", 17, 18, 0, 0, 5); + mir_snprintf(szStyle_div, _countof(szStyle_div), "\\f%u\\cf%u\\ul0\\b%d\\i%d\\fs%u", 17, 18, 0, 0, 5); lin->dwFlags |= MWF_DIVIDERWANTED; if (lin->prev || !streamData->bRedraw) @@ -750,13 +750,13 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData) int iii; if (lin->ptszNick && lin->iType == GC_EVENT_MESSAGE) { iii = lin->bIsHighlighted ? 16 : (lin->bIsMe ? 2 : 1); - mir_snprintf(szStyle, SIZEOF(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\ul%d\\fs%u", + mir_snprintf(szStyle, _countof(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\ul%d\\fs%u", iii + 1, F.lfWeight >= FW_BOLD ? 1 : 0, F.lfItalic, F.lfUnderline, 2 * abs(F.lfHeight) * 74 / pci->logPixelSY); str.Append(szStyle); } else { iii = lin->bIsHighlighted ? 16 : EventToIndex(lin); - mir_snprintf(szStyle, SIZEOF(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\ul%d\\fs%u", + mir_snprintf(szStyle, _countof(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\ul%d\\fs%u", iii + 1, F.lfWeight >= FW_BOLD ? 1 : 0, F.lfItalic, F.lfUnderline, 2 * abs(F.lfHeight) * 74 / pci->logPixelSY); str.Append(szStyle); } @@ -982,7 +982,7 @@ void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, bool bRedra // this uses hidden marks in the rich text to find the events which should be deleted if (si->bTrimmed) { TCHAR szPattern[50]; - mir_sntprintf(szPattern, SIZEOF(szPattern), _T("~-+%d+-~"), si->pLogEnd); + mir_sntprintf(szPattern, _countof(szPattern), _T("~-+%d+-~"), si->pLogEnd); FINDTEXTEX fi; fi.lpstrText = szPattern; diff --git a/plugins/TabSRMM/src/chat/main.cpp b/plugins/TabSRMM/src/chat/main.cpp index e41c697c29..2831e517d7 100644 --- a/plugins/TabSRMM/src/chat/main.cpp +++ b/plugins/TabSRMM/src/chat/main.cpp @@ -184,7 +184,7 @@ static void OnLoadSettings() for (int i = 0; i < 5; i++) { char szBuf[40]; - mir_snprintf(szBuf, SIZEOF(szBuf), "NickColor%d", i); + mir_snprintf(szBuf, _countof(szBuf), "NickColor%d", i); g_Settings.nickColors[i] = M.GetDword(CHAT_MODULE, szBuf, g_Settings.UserListColors[0]); } g_Settings.nickColors[5] = M.GetDword(CHAT_MODULE, "NickColor5", GetSysColor(COLOR_HIGHLIGHT)); @@ -311,7 +311,7 @@ int Chat_Unload(void) if (g_Settings.SelectionBGBrush) DeleteObject(g_Settings.SelectionBGBrush); - for (int i = 0; i < SIZEOF(g_Settings.UserListFonts); i++) + for (int i = 0; i < _countof(g_Settings.UserListFonts); i++) if (g_Settings.UserListFonts[i]) DeleteObject(g_Settings.UserListFonts[i]); diff --git a/plugins/TabSRMM/src/chat/options.cpp b/plugins/TabSRMM/src/chat/options.cpp index 094579efa5..791b695f5b 100644 --- a/plugins/TabSRMM/src/chat/options.cpp +++ b/plugins/TabSRMM/src/chat/options.cpp @@ -337,8 +337,8 @@ static IconItem _logicons[] = // add icons to the skinning module void Chat_AddIcons(void) { - Icon_Register(g_hIconDLL, LPGEN("Message Sessions")"/"LPGEN("Group chat windows"), _icons, SIZEOF(_icons)); - Icon_Register(g_hIconDLL, LPGEN("Message Sessions")"/"LPGEN("Group chat log"), _logicons, SIZEOF(_logicons)); + Icon_Register(g_hIconDLL, LPGEN("Message Sessions")"/"LPGEN("Group chat windows"), _icons, _countof(_icons)); + Icon_Register(g_hIconDLL, LPGEN("Message Sessions")"/"LPGEN("Group chat log"), _logicons, _countof(_logicons)); pci->MM_IconsChanged(); } @@ -406,8 +406,8 @@ INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM hListHeading1 = InsertBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), TranslateT("Appearance and functionality of chat room windows"), TRUE); hListHeading2 = InsertBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), TranslateT("Appearance of the message log"), TRUE); - FillBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading1, branch1, SIZEOF(branch1), 0x0000); - FillBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading2, branch2, SIZEOF(branch2), 0x0000); + FillBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading1, branch1, _countof(branch1), 0x0000); + FillBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading2, branch2, _countof(branch2), 0x0000); TCHAR* pszGroup = NULL; InitSetting(pszGroup, "AddToGroup", _T("Chat rooms")); @@ -449,8 +449,8 @@ INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM mir_free(pszText); b = M.GetByte(CHAT_MODULE, "Tabs", 1); - SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch1, SIZEOF(branch1)); - SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch2, SIZEOF(branch2)); + SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch1, _countof(branch1)); + SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch2, _countof(branch2)); pci->ReloadSettings(); pci->MM_IconsChanged(); @@ -494,62 +494,62 @@ void RegisterFontServiceFonts() fid.cbSize = sizeof(FontIDT); cid.cbSize = sizeof(ColourIDT); - strncpy(fid.dbSettingsGroup, FONTMODULE, SIZEOF(fid.dbSettingsGroup)); + strncpy(fid.dbSettingsGroup, FONTMODULE, _countof(fid.dbSettingsGroup)); - for (int i = 0; i < SIZEOF(IM_fontOptionsList); i++) { + for (int i = 0; i < _countof(IM_fontOptionsList); i++) { fid.flags = FIDF_DEFAULTVALID | FIDF_ALLOWEFFECTS; LoadMsgDlgFont(FONTSECTION_IM, i, &lf, &fontOptionsList[i].colour, FONTMODULE); mir_snprintf(szTemp, "Font%d", i); - strncpy(fid.prefix, szTemp, SIZEOF(fid.prefix)); + strncpy(fid.prefix, szTemp, _countof(fid.prefix)); fid.order = i; - _tcsncpy(fid.name, fontOptionsList[i].szDescr, SIZEOF(fid.name)); + _tcsncpy(fid.name, fontOptionsList[i].szDescr, _countof(fid.name)); fid.deffontsettings.colour = fontOptionsList[i].colour; fid.deffontsettings.size = (char)lf.lfHeight; fid.deffontsettings.style = (lf.lfWeight >= FW_BOLD ? FONTF_BOLD : 0) | (lf.lfItalic ? FONTF_ITALIC : 0); fid.deffontsettings.charset = lf.lfCharSet; fid.flags = fid.flags & ~FIDF_CLASSMASK | (fid.deffontsettings.style&FONTF_BOLD ? FIDF_CLASSHEADER : FIDF_CLASSGENERAL); _tcsncpy(fid.deffontsettings.szFace, lf.lfFaceName, LF_FACESIZE); - _tcsncpy(fid.backgroundGroup, LPGENT("Message Sessions")_T("/")LPGENT("Single Messaging"), SIZEOF(fid.backgroundGroup)); - _tcsncpy(fid.group, LPGENT("Message Sessions")_T("/")LPGENT("Single Messaging"), SIZEOF(fid.group)); + _tcsncpy(fid.backgroundGroup, LPGENT("Message Sessions")_T("/")LPGENT("Single Messaging"), _countof(fid.backgroundGroup)); + _tcsncpy(fid.group, LPGENT("Message Sessions")_T("/")LPGENT("Single Messaging"), _countof(fid.group)); switch (i) { case MSGFONTID_MYMSG: case 1: case MSGFONTID_MYNAME: case MSGFONTID_MYTIME: case 21: - _tcsncpy(fid.backgroundName, LPGENT("Outgoing background"), SIZEOF(fid.backgroundName)); + _tcsncpy(fid.backgroundName, LPGENT("Outgoing background"), _countof(fid.backgroundName)); break; case 8: case 9: case 12: case 13: - _tcsncpy(fid.backgroundName, LPGENT("Outgoing background(old)"), SIZEOF(fid.backgroundName)); + _tcsncpy(fid.backgroundName, LPGENT("Outgoing background(old)"), _countof(fid.backgroundName)); break; case 10: case 11: case 14: case 15: - _tcsncpy(fid.backgroundName, LPGENT("Incoming background(old)"), SIZEOF(fid.backgroundName)); + _tcsncpy(fid.backgroundName, LPGENT("Incoming background(old)"), _countof(fid.backgroundName)); break; case MSGFONTID_MESSAGEAREA: - _tcsncpy(fid.group, LPGENT("Message Sessions"), SIZEOF(fid.group)); - _tcsncpy(fid.backgroundGroup, LPGENT("Message Sessions"), SIZEOF(fid.backgroundGroup)); - _tcsncpy(fid.backgroundName, LPGENT("Input area background"), SIZEOF(fid.backgroundName)); + _tcsncpy(fid.group, LPGENT("Message Sessions"), _countof(fid.group)); + _tcsncpy(fid.backgroundGroup, LPGENT("Message Sessions"), _countof(fid.backgroundGroup)); + _tcsncpy(fid.backgroundName, LPGENT("Input area background"), _countof(fid.backgroundName)); fid.flags |= FIDF_DISABLESTYLES; fid.flags &= ~FIDF_ALLOWEFFECTS; break; case 17: - _tcsncpy(fid.backgroundName, LPGENT("Status background"), SIZEOF(fid.backgroundName)); + _tcsncpy(fid.backgroundName, LPGENT("Status background"), _countof(fid.backgroundName)); break; case 18: - _tcsncpy(fid.backgroundGroup, LPGENT("Message Sessions"), SIZEOF(fid.backgroundGroup)); - _tcsncpy(fid.backgroundName, LPGENT("Log background"), SIZEOF(fid.backgroundName)); + _tcsncpy(fid.backgroundGroup, LPGENT("Message Sessions"), _countof(fid.backgroundGroup)); + _tcsncpy(fid.backgroundName, LPGENT("Log background"), _countof(fid.backgroundName)); break; case 19: - _tcsncpy(fid.backgroundName, _T(""), SIZEOF(fid.backgroundName)); + _tcsncpy(fid.backgroundName, _T(""), _countof(fid.backgroundName)); break; default: - _tcsncpy(fid.backgroundName, LPGENT("Incoming background"), SIZEOF(fid.backgroundName)); + _tcsncpy(fid.backgroundName, LPGENT("Incoming background"), _countof(fid.backgroundName)); break; } FontRegisterT(&fid); @@ -557,15 +557,15 @@ void RegisterFontServiceFonts() fontOptionsList = IP_fontOptionsList; fid.flags = FIDF_DEFAULTVALID | FIDF_ALLOWEFFECTS; - _tcsncpy(fid.group, LPGENT("Message Sessions")_T("/")LPGENT("Info Panel"), SIZEOF(fid.group)); - _tcsncpy(fid.backgroundGroup, LPGENT("Message Sessions")_T("/")LPGENT("Info Panel"), SIZEOF(fid.backgroundGroup)); - _tcsncpy(fid.backgroundName, LPGENT("Fields background"), SIZEOF(fid.backgroundName)); + _tcsncpy(fid.group, LPGENT("Message Sessions")_T("/")LPGENT("Info Panel"), _countof(fid.group)); + _tcsncpy(fid.backgroundGroup, LPGENT("Message Sessions")_T("/")LPGENT("Info Panel"), _countof(fid.backgroundGroup)); + _tcsncpy(fid.backgroundName, LPGENT("Fields background"), _countof(fid.backgroundName)); for (int i = 0; i < IPFONTCOUNT; i++) { LoadMsgDlgFont(FONTSECTION_IP, i + 100, &lf, &fontOptionsList[i].colour, FONTMODULE); mir_snprintf(szTemp, "Font%d", i + 100); - strncpy(fid.prefix, szTemp, SIZEOF(fid.prefix)); + strncpy(fid.prefix, szTemp, _countof(fid.prefix)); fid.order = i + 100; - _tcsncpy(fid.name, fontOptionsList[i].szDescr, SIZEOF(fid.name)); + _tcsncpy(fid.name, fontOptionsList[i].szDescr, _countof(fid.name)); fid.deffontsettings.colour = fontOptionsList[i].colour; fid.deffontsettings.size = (char)lf.lfHeight; fid.deffontsettings.style = (lf.lfWeight >= FW_BOLD ? FONTF_BOLD : 0) | (lf.lfItalic ? FONTF_ITALIC : 0); @@ -574,20 +574,20 @@ void RegisterFontServiceFonts() fid.deffontsettings.charset = lf.lfCharSet; _tcsncpy(fid.deffontsettings.szFace, lf.lfFaceName, LF_FACESIZE); if (i == IPFONTCOUNT - 1) { - _tcsncpy(fid.backgroundGroup, _T(""), SIZEOF(fid.backgroundGroup)); - _tcsncpy(fid.backgroundName, _T(""), SIZEOF(fid.backgroundName)); - _tcsncpy(fid.group, LPGENT("Message Sessions"), SIZEOF(fid.group)); + _tcsncpy(fid.backgroundGroup, _T(""), _countof(fid.backgroundGroup)); + _tcsncpy(fid.backgroundName, _T(""), _countof(fid.backgroundName)); + _tcsncpy(fid.group, LPGENT("Message Sessions"), _countof(fid.group)); } FontRegisterT(&fid); } - _tcsncpy(cid.group, LPGENT("Message Sessions")_T("/")LPGENT("Group chats"), SIZEOF(cid.group)); - strncpy(cid.dbSettingsGroup, CHAT_MODULE, SIZEOF(cid.dbSettingsGroup)); + _tcsncpy(cid.group, LPGENT("Message Sessions")_T("/")LPGENT("Group chats"), _countof(cid.group)); + strncpy(cid.dbSettingsGroup, CHAT_MODULE, _countof(cid.dbSettingsGroup)); for (int i = 0; i <= 7; i++) { mir_snprintf(szTemp, "NickColor%d", i); - _tcsncpy(cid.name, chatcolorsnames[i], SIZEOF(cid.name)); + _tcsncpy(cid.name, chatcolorsnames[i], _countof(cid.name)); cid.order = i + 1; - strncpy(cid.setting, szTemp, SIZEOF(cid.setting)); + strncpy(cid.setting, szTemp, _countof(cid.setting)); switch (i) { case 5: cid.defcolour = GetSysColor(COLOR_HIGHLIGHT); @@ -613,14 +613,14 @@ void RegisterFontServiceFonts() ColourRegisterT(&cid); // static colors (info panel, tool bar background etc...) - strncpy(fid.dbSettingsGroup, FONTMODULE, SIZEOF(fid.dbSettingsGroup)); - strncpy(cid.dbSettingsGroup, FONTMODULE, SIZEOF(fid.dbSettingsGroup)); + strncpy(fid.dbSettingsGroup, FONTMODULE, _countof(fid.dbSettingsGroup)); + strncpy(cid.dbSettingsGroup, FONTMODULE, _countof(fid.dbSettingsGroup)); - for (int i = 0; i < SIZEOF(_clrs); i++) { + for (int i = 0; i < _countof(_clrs); i++) { cid.order = _clrs[i].order; - _tcsncpy(cid.group, _clrs[i].tszGroup, SIZEOF(fid.group)); - _tcsncpy(cid.name, _clrs[i].tszName, SIZEOF(cid.name)); - strncpy(cid.setting, _clrs[i].szSetting, SIZEOF(cid.setting)); + _tcsncpy(cid.group, _clrs[i].tszGroup, _countof(fid.group)); + _tcsncpy(cid.name, _clrs[i].tszName, _countof(cid.name)); + strncpy(cid.setting, _clrs[i].szSetting, _countof(cid.setting)); if (_clrs[i].def & 0xff000000) cid.defcolour = GetSysColor(_clrs[i].def & 0x000000ff); else @@ -628,14 +628,14 @@ void RegisterFontServiceFonts() ColourRegisterT(&cid); } - strncpy(cid.dbSettingsGroup, SRMSGMOD_T, SIZEOF(fid.dbSettingsGroup)); + strncpy(cid.dbSettingsGroup, SRMSGMOD_T, _countof(fid.dbSettingsGroup)); // text and background colors for tabs - for (int i = 0; i < SIZEOF(_tabclrs); i++) { + for (int i = 0; i < _countof(_tabclrs); i++) { cid.order = _tabclrs[i].order; - _tcsncpy(cid.group, _tabclrs[i].tszGroup, SIZEOF(fid.group)); - _tcsncpy(cid.name, _tabclrs[i].tszName, SIZEOF(cid.name)); - strncpy(cid.setting, _tabclrs[i].szSetting, SIZEOF(cid.setting)); + _tcsncpy(cid.group, _tabclrs[i].tszGroup, _countof(fid.group)); + _tcsncpy(cid.name, _tabclrs[i].tszName, _countof(cid.name)); + strncpy(cid.setting, _tabclrs[i].szSetting, _countof(cid.setting)); if (_tabclrs[i].def & 0xff000000) cid.defcolour = GetSysColor(_tabclrs[i].def & 0x000000ff); else @@ -692,7 +692,7 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM if (ServiceExists(MS_UTILS_REPLACEVARS)) { TCHAR tszTooltipText[2048]; - mir_sntprintf(tszTooltipText, SIZEOF(tszTooltipText), + mir_sntprintf(tszTooltipText, _countof(tszTooltipText), _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n\n") _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n\n") _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s"), @@ -759,12 +759,12 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM *p1 = 0; TCHAR tszInitialDir[_MAX_DRIVE + _MAX_PATH + 10]; - mir_sntprintf(tszInitialDir, SIZEOF(tszInitialDir), _T("%s%s"), M.getChatLogPath(), p); + mir_sntprintf(tszInitialDir, _countof(tszInitialDir), _T("%s%s"), M.getChatLogPath(), p); if (!PathFileExists(tszInitialDir)) _tcsncpy_s(tszInitialDir, M.getChatLogPath(), _TRUNCATE); TCHAR tszReturnName[MAX_PATH]; tszReturnName[0] = 0; - mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("%s%c*.*%c%c"), TranslateT("All files"), 0, 0, 0); + mir_sntprintf(tszTemp, _countof(tszTemp), _T("%s%c*.*%c%c"), TranslateT("All files"), 0, 0, 0); OPENFILENAME ofn = { 0 }; ofn.lpstrInitialDir = tszInitialDir; @@ -955,7 +955,7 @@ INT_PTR CALLBACK DlgProcOptions3(HWND hwndDlg, UINT uMsg, WPARAM, LPARAM lParam) DWORD dwPopupFlags = M.GetDword(CHAT_MODULE, "PopupFlags", GC_EVENT_HIGHLIGHT); DWORD dwLogFlags = M.GetDword(CHAT_MODULE, "DiskLogFlags", GC_EVENT_ALL); - for (int i = 0; i < SIZEOF(_eventorder); i++) { + for (int i = 0; i < _countof(_eventorder); i++) { if (_eventorder[i] != GC_EVENT_HIGHLIGHT) { CheckDlgButton(hwndDlg, IDC_1 + i, dwFilterFlags & _eventorder[i] ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_L1 + i, dwLogFlags & _eventorder[i] ? BST_CHECKED : BST_UNCHECKED); @@ -987,7 +987,7 @@ INT_PTR CALLBACK DlgProcOptions3(HWND hwndDlg, UINT uMsg, WPARAM, LPARAM lParam) DWORD dwFilterFlags = 0, dwTrayFlags = 0, dwPopupFlags = 0, dwLogFlags = 0; - for (int i = 0; i < SIZEOF(_eventorder); i++) { + for (int i = 0; i < _countof(_eventorder); i++) { if (_eventorder[i] != GC_EVENT_HIGHLIGHT) { dwFilterFlags |= (IsDlgButtonChecked(hwndDlg, IDC_1 + i) ? _eventorder[i] : 0); dwLogFlags |= (IsDlgButtonChecked(hwndDlg, IDC_L1 + i) ? _eventorder[i] : 0); diff --git a/plugins/TabSRMM/src/chat/services.cpp b/plugins/TabSRMM/src/chat/services.cpp index e26797e999..a638836b7e 100644 --- a/plugins/TabSRMM/src/chat/services.cpp +++ b/plugins/TabSRMM/src/chat/services.cpp @@ -55,7 +55,7 @@ HWND CreateNewRoom(TContainerData *pContainer, SESSION_INFO *si, BOOL bActivateT TCHAR newcontactname[128]; if (mir_tstrlen(contactName) > 0) { if (M.GetByte("cuttitle", 0)) - CutContactName(contactName, newcontactname, SIZEOF(newcontactname)); + CutContactName(contactName, newcontactname, _countof(newcontactname)); else _tcsncpy_s(newcontactname, contactName, _TRUNCATE); } diff --git a/plugins/TabSRMM/src/chat/tools.cpp b/plugins/TabSRMM/src/chat/tools.cpp index fa3c09ec13..9ffc5e7bc1 100644 --- a/plugins/TabSRMM/src/chat/tools.cpp +++ b/plugins/TabSRMM/src/chat/tools.cpp @@ -102,7 +102,7 @@ int ShowPopup(MCONTACT hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoNa return 0; va_start(marker, fmt); - mir_vsntprintf(szBuf, SIZEOF(szBuf), fmt, marker); + mir_vsntprintf(szBuf, _countof(szBuf), fmt, marker); va_end(marker); pd.lchContact = hContact; @@ -113,7 +113,7 @@ int ShowPopup(MCONTACT hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoNa pd.lchIcon = LoadIconEx("window"); PROTOACCOUNT *pa = Proto_GetAccount(pszProtoName); - mir_sntprintf(pd.lptzContactName, SIZEOF(pd.lptzContactName), _T("%s - %s"), + mir_sntprintf(pd.lptzContactName, _countof(pd.lptzContactName), _T("%s - %s"), (pa == NULL) ? _A2T(pszProtoName) : pa->tszAccountName, pcli->pfnGetContactDisplayName(hContact, 0)); @@ -536,7 +536,7 @@ UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO if (pszWordText && pszWordText[0]) { TCHAR szMenuText[4096]; - mir_sntprintf(szMenuText, SIZEOF(szMenuText), TranslateT("Look up '%s':"), pszWordText); + mir_sntprintf(szMenuText, _countof(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/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index 2f3063c880..4d5835d9d6 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -1031,7 +1031,7 @@ static INT_PTR CALLBACK FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP DWORD dwTrayMask = db_get_dw(si->hContact, CHAT_MODULE, "TrayIconMask", 0); DWORD dwTrayFlags = db_get_dw(si->hContact, CHAT_MODULE, "TrayIconFlags", 0); - for (int i = 0; i < SIZEOF(_eventorder); i++) { + for (int i = 0; i < _countof(_eventorder); i++) { CheckDlgButton(hwndDlg, IDC_1 + i, dwMask & _eventorder[i] ? (dwFlags & _eventorder[i] ? BST_CHECKED : BST_UNCHECKED) : BST_INDETERMINATE); CheckDlgButton(hwndDlg, IDC_P1 + i, dwPopupMask & _eventorder[i] ? (dwPopupFlags & _eventorder[i] ? BST_CHECKED : BST_UNCHECKED) : BST_INDETERMINATE); CheckDlgButton(hwndDlg, IDC_T1 + i, dwTrayMask & _eventorder[i] ? (dwTrayFlags & _eventorder[i] ? BST_CHECKED : BST_UNCHECKED) : BST_INDETERMINATE); @@ -1050,7 +1050,7 @@ static INT_PTR CALLBACK FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP int iFlags = 0, i; DWORD dwMask = 0; - for (i = 0; i < SIZEOF(_eventorder); i++) { + for (i = 0; i < _countof(_eventorder); i++) { int result = IsDlgButtonChecked(hwndDlg, IDC_1 + i); dwMask |= (result != BST_INDETERMINATE ? _eventorder[i] : 0); iFlags |= (result == BST_CHECKED ? _eventorder[i] : 0); @@ -1072,7 +1072,7 @@ static INT_PTR CALLBACK FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP dwMask = iFlags = 0; - for (i = 0; i < SIZEOF(_eventorder); i++) { + for (i = 0; i < _countof(_eventorder); i++) { int result = IsDlgButtonChecked(hwndDlg, IDC_P1 + i); dwMask |= (result != BST_INDETERMINATE ? _eventorder[i] : 0); iFlags |= (result == BST_CHECKED ? _eventorder[i] : 0); @@ -1094,7 +1094,7 @@ static INT_PTR CALLBACK FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP dwMask = iFlags = 0; - for (i = 0; i < SIZEOF(_eventorder); i++) { + for (i = 0; i < _countof(_eventorder); i++) { int result = IsDlgButtonChecked(hwndDlg, IDC_T1 + i); dwMask |= (result != BST_INDETERMINATE ? _eventorder[i] : 0); iFlags |= (result == BST_CHECKED ? _eventorder[i] : 0); @@ -1323,7 +1323,7 @@ static void ProcessNickListHovering(HWND hwnd, int hoveredItem, SESSION_INFO *pa } if (tszBuf[0] == 0) - mir_sntprintf(tszBuf, SIZEOF(tszBuf), _T("%s: %s\r\n%s: %s\r\n%s: %s"), + mir_sntprintf(tszBuf, _countof(tszBuf), _T("%s: %s\r\n%s: %s\r\n%s: %s"), TranslateT("Nickname"), ui1->pszNick, TranslateT("Unique ID"), ui1->pszUID, TranslateT("Status"), pci->TM_WordToString(parentdat->pStatuses, ui1->Status)); @@ -1458,7 +1458,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, else if (wParam < ' ') break; else { - if (mir_tstrlen(si->szSearch) >= SIZEOF(si->szSearch) - 2) { + if (mir_tstrlen(si->szSearch) >= _countof(si->szSearch) - 2) { MessageBeep(MB_OK); break; } @@ -1671,7 +1671,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, } } if (tszBuf[0] == 0) - mir_sntprintf(tszBuf, SIZEOF(tszBuf), _T("%s:\t%s\n%s:\t%s\n%s:\t%s"), + mir_sntprintf(tszBuf, _countof(tszBuf), _T("%s:\t%s\n%s:\t%s\n%s:\t%s"), TranslateT("Nick"), ui1->pszNick, TranslateT("Unique ID"), ui1->pszUID, TranslateT("Status"), pci->TM_WordToString(parentdat->pStatuses, ui1->Status)); @@ -1890,7 +1890,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar const TCHAR *szNick = dat->cache->getNick(); if (mir_tstrlen(szNick) > 0) { if (M.GetByte("cuttitle", 0)) - CutContactName(szNick, dat->newtitle, SIZEOF(dat->newtitle)); + CutContactName(szNick, dat->newtitle, _countof(dat->newtitle)); else _tcsncpy_s(dat->newtitle, szNick, _TRUNCATE); } @@ -1976,17 +1976,17 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar else if (diff > 59) { DWORD hours = diff / 60; DWORD minutes = diff % 60; - mir_sntprintf(mi->tszIdleMsg, SIZEOF(mi->tszIdleMsg), TranslateT(", %d %s, %d %s idle"), hours, hours > 1 ? + mir_sntprintf(mi->tszIdleMsg, _countof(mi->tszIdleMsg), TranslateT(", %d %s, %d %s idle"), hours, hours > 1 ? TranslateT("hours") : TranslateT("hour"), minutes, minutes > 1 ? TranslateT("minutes") : TranslateT("minute")); } - else mir_sntprintf(mi->tszIdleMsg, SIZEOF(mi->tszIdleMsg), TranslateT(", %d %s idle"), diff, diff > 1 ? TranslateT("minutes") : TranslateT("minute")); + else mir_sntprintf(mi->tszIdleMsg, _countof(mi->tszIdleMsg), TranslateT(", %d %s idle"), diff, diff > 1 ? TranslateT("minutes") : TranslateT("minute")); } - mir_sntprintf(szFinalStatusBarText, SIZEOF(szFinalStatusBarText), TranslateT("%s on %s%s"), dat->szMyNickname, mi->ptszModDispName, mi->tszIdleMsg); + mir_sntprintf(szFinalStatusBarText, _countof(szFinalStatusBarText), TranslateT("%s on %s%s"), dat->szMyNickname, mi->ptszModDispName, mi->tszIdleMsg); } else { if (si->ptszStatusbarText) - mir_sntprintf(szFinalStatusBarText, SIZEOF(szFinalStatusBarText), _T("%s %s"), mi->ptszModDispName, si->ptszStatusbarText); + mir_sntprintf(szFinalStatusBarText, _countof(szFinalStatusBarText), _T("%s %s"), mi->ptszModDispName, si->ptszStatusbarText); else _tcsncpy_s(szFinalStatusBarText, mi->ptszModDispName, _TRUNCATE); } @@ -2570,7 +2570,7 @@ LABEL_SHOWWINDOW: case ID_SEARCH_GOOGLE: if (pszWord[0]) { TCHAR szURL[4096]; - mir_sntprintf(szURL, SIZEOF(szURL), _T("http://www.google.com/search?q=%s"), pszWord); + mir_sntprintf(szURL, _countof(szURL), _T("http://www.google.com/search?q=%s"), pszWord); CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW | OUF_TCHAR, (LPARAM)szURL); } PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0); @@ -2579,7 +2579,7 @@ LABEL_SHOWWINDOW: case ID_SEARCH_WIKIPEDIA: if (pszWord[0]) { TCHAR szURL[4096]; - mir_sntprintf(szURL, SIZEOF(szURL), _T("http://en.wikipedia.org/wiki/%s"), pszWord); + mir_sntprintf(szURL, _countof(szURL), _T("http://en.wikipedia.org/wiki/%s"), pszWord); CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW | OUF_TCHAR, (LPARAM)szURL); } PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0); @@ -3176,7 +3176,7 @@ LABEL_SHOWWINDOW: DBVARIANT dbv = { 0 }; char szIndex[10]; char *szKey = "TAB_ContainersW"; - mir_snprintf(szIndex, SIZEOF(szIndex), "%d", iSelection - IDM_CONTAINERMENU); + mir_snprintf(szIndex, _countof(szIndex), "%d", iSelection - IDM_CONTAINERMENU); if (iSelection - IDM_CONTAINERMENU >= 0) { if (!db_get_ts(NULL, szKey, szIndex, &dbv)) { SendMessage(hwndDlg, DM_CONTAINERSELECTED, 0, (LPARAM)dbv.ptszVal); -- cgit v1.2.3