diff options
author | George Hazan <george.hazan@gmail.com> | 2014-12-01 23:27:22 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-12-01 23:27:22 +0000 |
commit | 15b4d00e919d97015c208fff867862ef028995de (patch) | |
tree | 153c71d62dac1a17eaf469f52a6c2dfe9f7a28ae /plugins/TabSRMM/src | |
parent | cc15bc68febf4de6cd357ea9192de2e876ab290e (diff) |
static mir_tstrncpy replaced with direct _tcsncpy_s calls
git-svn-id: http://svn.miranda-ng.org/main/trunk@11209 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TabSRMM/src')
-rw-r--r-- | plugins/TabSRMM/src/chat/log.cpp | 14 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/options.cpp | 6 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/services.cpp | 8 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/tools.cpp | 6 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/window.cpp | 12 | ||||
-rw-r--r-- | plugins/TabSRMM/src/container.cpp | 11 | ||||
-rw-r--r-- | plugins/TabSRMM/src/generic_msghandlers.cpp | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/mim.cpp | 12 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgs.cpp | 9 | ||||
-rw-r--r-- | plugins/TabSRMM/src/sendqueue.cpp | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/themeio.cpp | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/typingnotify.cpp | 16 |
12 files changed, 48 insertions, 58 deletions
diff --git a/plugins/TabSRMM/src/chat/log.cpp b/plugins/TabSRMM/src/chat/log.cpp index e1b7fd5525..7129dc6361 100644 --- a/plugins/TabSRMM/src/chat/log.cpp +++ b/plugins/TabSRMM/src/chat/log.cpp @@ -616,15 +616,15 @@ static void AddEventToBuffer(char **buffer, int *bufferEnd, int *bufferAlloced, if (streamData->lin->ptszNick) {
if (g_Settings.bLogLimitNames && mir_tstrlen(streamData->lin->ptszNick) > 20) {
- mir_tstrncpy(szTemp, streamData->lin->ptszNick, 20);
- mir_tstrncpy(szTemp + 20, _T("..."), 4);
+ _tcsncpy_s(szTemp, 20, streamData->lin->ptszNick, _TRUNCATE);
+ _tcsncpy_s(szTemp + 20, 4, _T("..."), _TRUNCATE);
}
- else mir_tstrncpy(szTemp, streamData->lin->ptszNick, 511);
+ else _tcsncpy_s(szTemp, streamData->lin->ptszNick, _TRUNCATE);
if (g_Settings.bClickableNicks)
mir_sntprintf(szTemp2, SIZEOF(szTemp2), _T("~~++#%s#++~~"), szTemp);
else
- _tcscpy(szTemp2, szTemp);
+ _tcsncpy_s(szTemp2, szTemp, _TRUNCATE);
if (streamData->lin->ptszUserInfo && streamData->lin->iType != GC_EVENT_TOPIC)
mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s (%s)"), szTemp2, streamData->lin->ptszUserInfo);
@@ -875,8 +875,8 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData) if (g_Settings.bShowTime) {
TCHAR szTimeStamp[30], szOldTimeStamp[30];
- mir_tstrncpy(szTimeStamp, pci->MakeTimeStamp(g_Settings.pszTimeStamp, lin->time), 30);
- mir_tstrncpy(szOldTimeStamp, pci->MakeTimeStamp(g_Settings.pszTimeStamp, streamData->si->LastTime), 30);
+ _tcsncpy_s(szTimeStamp, pci->MakeTimeStamp(g_Settings.pszTimeStamp, lin->time), _TRUNCATE);
+ _tcsncpy_s(szOldTimeStamp, pci->MakeTimeStamp(g_Settings.pszTimeStamp, streamData->si->LastTime), _TRUNCATE);
if (!g_Settings.bShowTimeIfChanged || streamData->si->LastTime == 0 || mir_tstrcmp(szTimeStamp, szOldTimeStamp)) {
streamData->si->LastTime = lin->time;
Log_AppendRTF(streamData, TRUE, &buffer, &bufferEnd, &bufferAlloced, _T("%s"), szTimeStamp);
@@ -898,7 +898,7 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData) if (g_Settings.bLogClassicIndicators)
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s", pszIndicator);
- mir_tstrncpy(pszTemp, lin->bIsMe ? g_Settings.pszOutgoingNick : g_Settings.pszIncomingNick, 299);
+ mir_tstrncpy(pszTemp, lin->bIsMe ? g_Settings.pszOutgoingNick : g_Settings.pszIncomingNick, SIZEOF(pszTemp));
p1 = _tcsstr(pszTemp, _T("%n"));
if (p1)
p1[1] = 's';
diff --git a/plugins/TabSRMM/src/chat/options.cpp b/plugins/TabSRMM/src/chat/options.cpp index 376357d673..dc89da275f 100644 --- a/plugins/TabSRMM/src/chat/options.cpp +++ b/plugins/TabSRMM/src/chat/options.cpp @@ -219,14 +219,14 @@ void LoadMsgDlgFont(int section, int i, LOGFONT *lf, COLORREF* colour, char *szM mir_snprintf(str, SIZEOF(str), "Font%d", i);
if ((i == 17 && !strcmp(szMod, CHATFONT_MODULE)) || ((i == 20 || i == 21) && !strcmp(szMod, FONTMODULE))) {
lf->lfCharSet = SYMBOL_CHARSET;
- mir_tstrncpy(lf->lfFaceName, _T("Webdings"), SIZEOF(lf->lfFaceName));
+ _tcsncpy_s(lf->lfFaceName, _T("Webdings"), _TRUNCATE);
}
else {
ptrT tszDefFace(db_get_tsa(NULL, szMod, str));
if (tszDefFace == NULL)
- mir_tstrcpy(lf->lfFaceName, fol[j].szDefFace);
+ _tcsncpy_s(lf->lfFaceName, fol[j].szDefFace, _TRUNCATE);
else
- mir_tstrncpy(lf->lfFaceName, tszDefFace, SIZEOF(lf->lfFaceName));
+ _tcsncpy_s(lf->lfFaceName, tszDefFace, _TRUNCATE);
}
}
}
diff --git a/plugins/TabSRMM/src/chat/services.cpp b/plugins/TabSRMM/src/chat/services.cpp index ee7bf778b3..a34b7d0896 100644 --- a/plugins/TabSRMM/src/chat/services.cpp +++ b/plugins/TabSRMM/src/chat/services.cpp @@ -56,12 +56,10 @@ HWND CreateNewRoom(TContainerData *pContainer, SESSION_INFO *si, BOOL bActivateT if (mir_tstrlen(contactName) > 0) {
if (M.GetByte("cuttitle", 0))
CutContactName(contactName, newcontactname, SIZEOF(newcontactname));
- else {
- mir_tstrncpy(newcontactname, contactName, SIZEOF(newcontactname));
- newcontactname[127] = 0;
- }
+ else
+ _tcsncpy_s(newcontactname, contactName, _TRUNCATE);
}
- else mir_tstrncpy(newcontactname, _T("_U_"), SIZEOF(newcontactname));
+ else _tcsncpy_s(newcontactname, _T("_U_"), _TRUNCATE);
newData.item.pszText = newcontactname;
newData.item.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM;
diff --git a/plugins/TabSRMM/src/chat/tools.cpp b/plugins/TabSRMM/src/chat/tools.cpp index 6a830c78fb..2803d8f87e 100644 --- a/plugins/TabSRMM/src/chat/tools.cpp +++ b/plugins/TabSRMM/src/chat/tools.cpp @@ -117,7 +117,7 @@ int ShowPopup(MCONTACT hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoNa (pa == NULL) ? _A2T(pszProtoName) : pa->tszAccountName,
pcli->pfnGetContactDisplayName(hContact, 0));
- mir_tstrncpy(pd.lptzText, TranslateTS(szBuf), MAX_SECONDLINE);
+ _tcsncpy_s(pd.lptzText, TranslateTS(szBuf), _TRUNCATE);
pd.iSeconds = g_Settings.iPopupTimeout;
if (g_Settings.iPopupStyle == 2) {
@@ -549,10 +549,10 @@ UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO if (pszWordText)
mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("&Message %s"), pszWordText);
else
- mir_tstrncpy(szTemp, TranslateT("&Message"), SIZEOF(szTemp) - 1);
+ _tcsncpy_s(szTemp, TranslateT("&Message"), _TRUNCATE);
if (mir_tstrlen(szTemp) > 40)
- mir_tstrncpy(szTemp + 40, _T("..."), 4);
+ _tcsncpy_s(szTemp + 40, 4, _T("..."), _TRUNCATE);
ModifyMenu(*hMenu, ID_MESS, MF_STRING | MF_BYCOMMAND, ID_MESS, szTemp);
gcmi.Type = MENU_ON_NICKLIST;
}
diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index a0e5e2e4f5..1d30b7af89 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -1993,10 +1993,8 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar if (mir_tstrlen(szNick) > 0) { if (M.GetByte("cuttitle", 0)) CutContactName(szNick, dat->newtitle, SIZEOF(dat->newtitle)); - else { - mir_tstrncpy(dat->newtitle, szNick, SIZEOF(dat->newtitle)); - dat->newtitle[129] = 0; - } + else + _tcsncpy_s(dat->newtitle, szNick, _TRUNCATE); } TCHAR szTemp[100]; @@ -2091,10 +2089,8 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar else { if (si->ptszStatusbarText) mir_sntprintf(szFinalStatusBarText, SIZEOF(szFinalStatusBarText), _T("%s %s"), mi->ptszModDispName, si->ptszStatusbarText); - else { - mir_tstrncpy(szFinalStatusBarText, mi->ptszModDispName, SIZEOF(szFinalStatusBarText)); - szFinalStatusBarText[511] = 0; - } + else + _tcsncpy_s(szFinalStatusBarText, mi->ptszModDispName, _TRUNCATE); } SendMessage(dat->pContainer->hwndStatus, SB_SETTEXT, 0, (LPARAM)szFinalStatusBarText); UpdateStatusBar(dat); diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp index 37f5c4a4d9..7239a16651 100644 --- a/plugins/TabSRMM/src/container.cpp +++ b/plugins/TabSRMM/src/container.cpp @@ -1990,15 +1990,12 @@ int TSAPI CutContactName(const TCHAR *oldname, TCHAR *newname, unsigned int size { int cutMax = PluginConfig.m_CutContactNameTo; - if (mir_tstrlen(oldname) <= cutMax) { - mir_tstrncpy(newname, oldname, size); - newname[size - 1] = 0; - } + if (mir_tstrlen(oldname) <= cutMax) + _tcsncpy_s(newname, size, oldname, _TRUNCATE); else { - TCHAR fmt[20]; - mir_sntprintf(fmt, 18, _T("%%%d.%ds..."), cutMax, cutMax); + TCHAR fmt[30]; + mir_sntprintf(fmt, SIZEOF(fmt), _T("%%%d.%ds..."), cutMax, cutMax); mir_sntprintf(newname, size, fmt, oldname); - newname[size - 1] = 0; } return 0; } diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index 14b48c5ec0..698704de1b 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -1763,7 +1763,7 @@ void TSAPI DM_UpdateTitle(TWindowData *dat, WPARAM wParam, LPARAM lParam) if (PluginConfig.m_CutContactNameOnTabs) CutContactName(szNick, newcontactname, SIZEOF(newcontactname)); else - mir_tstrncpy(newcontactname, szNick, SIZEOF(newcontactname)); + _tcsncpy_s(newcontactname, szNick, _TRUNCATE); Utils::DoubleAmpersands(newcontactname); @@ -1792,7 +1792,7 @@ void TSAPI DM_UpdateTitle(TWindowData *dat, WPARAM wParam, LPARAM lParam) SendMessage(GetDlgItem(hwndDlg, IDC_NAME), BUTTONADDTOOLTIP, (WPARAM)fulluin, BATF_TCHAR); } } - else mir_tstrncpy(newtitle, _T("Message Session"), SIZEOF(newtitle)); + else _tcsncpy_s(newtitle, _T("Message Session"), _TRUNCATE); if (dat->idle != dwOldIdle || lParam != 0) { if (item.mask & TCIF_TEXT) { diff --git a/plugins/TabSRMM/src/mim.cpp b/plugins/TabSRMM/src/mim.cpp index 10cb62cad9..90ee544ba8 100644 --- a/plugins/TabSRMM/src/mim.cpp +++ b/plugins/TabSRMM/src/mim.cpp @@ -132,9 +132,9 @@ const TCHAR* CMimAPI::getUserDir() { if (m_userDir[0] == 0) { if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) - mir_tstrncpy(m_userDir, L"%miranda_userdata%", SIZEOF(m_userDir)); + _tcsncpy_s(m_userDir, L"%miranda_userdata%", _TRUNCATE); else - mir_tstrncpy(m_userDir, VARST(_T("%miranda_userdata%")), SIZEOF(m_userDir)); + _tcsncpy_s(m_userDir, VARST(_T("%miranda_userdata%")), _TRUNCATE); Utils::ensureTralingBackslash(m_userDir); } @@ -151,12 +151,12 @@ void CMimAPI::InitPaths() mir_sntprintf(m_szProfilePath, MAX_PATH, _T("%stabSRMM"), szUserdataDir); if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) { - mir_tstrncpy(m_szChatLogsPath, _T("%miranda_logpath%"), MAX_PATH); - mir_tstrncpy(m_szSkinsPath, _T("%miranda_path%\\Skins\\TabSRMM"), MAX_PATH); + _tcsncpy_s(m_szChatLogsPath, _T("%miranda_logpath%"), _TRUNCATE); + _tcsncpy_s(m_szSkinsPath, _T("%miranda_path%\\Skins\\TabSRMM"), _TRUNCATE); } else { - mir_tstrncpy(m_szChatLogsPath, VARST(_T("%miranda_logpath%")), MAX_PATH); - mir_tstrncpy(m_szSkinsPath, VARST(_T("%miranda_path%\\Skins\\TabSRMM")), MAX_PATH); + _tcsncpy_s(m_szChatLogsPath, VARST(_T("%miranda_logpath%")), _TRUNCATE); + _tcsncpy_s(m_szSkinsPath, VARST(_T("%miranda_path%\\Skins\\TabSRMM")), _TRUNCATE); } Utils::ensureTralingBackslash(m_szChatLogsPath); diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp index 4deb3f4b22..bea7f95208 100644 --- a/plugins/TabSRMM/src/msgs.cpp +++ b/plugins/TabSRMM/src/msgs.cpp @@ -584,13 +584,12 @@ HWND TSAPI CreateNewTabForContact(TContainerData *pContainer, MCONTACT hContact, if (contactName && mir_tstrlen(contactName) > 0) { if (M.GetByte("cuttitle", 0)) CutContactName(contactName, newcontactname, SIZEOF(newcontactname)); - else { - mir_tstrncpy(newcontactname, contactName, SIZEOF(newcontactname)); - newcontactname[127] = 0; - } + else + _tcsncpy_s(newcontactname, contactName, _TRUNCATE); + Utils::DoubleAmpersands(newcontactname); } - else mir_tstrncpy(newcontactname, _T("_U_"), SIZEOF(newcontactname)); + else _tcsncpy_s(newcontactname, _T("_U_"), _TRUNCATE); WORD wStatus = (szProto == NULL ? ID_STATUS_OFFLINE : db_get_w(newData.hContact, szProto, "Status", ID_STATUS_OFFLINE)); TCHAR *szStatus = pcli->pfnGetStatusModeDescription(szProto == NULL ? ID_STATUS_OFFLINE : db_get_w(newData.hContact, szProto, "Status", ID_STATUS_OFFLINE), 0); diff --git a/plugins/TabSRMM/src/sendqueue.cpp b/plugins/TabSRMM/src/sendqueue.cpp index 49d77902f8..310d7717af 100644 --- a/plugins/TabSRMM/src/sendqueue.cpp +++ b/plugins/TabSRMM/src/sendqueue.cpp @@ -598,8 +598,8 @@ void SendQueue::NotifyDeliveryFailure(const TWindowData *dat) POPUPDATAT ppd = { 0 }; ppd.lchContact = dat->hContact; - mir_tstrncpy(ppd.lptzContactName, dat->cache->getNick(), MAX_CONTACTNAME); - mir_tstrncpy(ppd.lptzText, TranslateT("A message delivery has failed.\nClick to open the message window."), MAX_SECONDLINE); + _tcsncpy_s(ppd.lptzContactName, dat->cache->getNick(), _TRUNCATE); + _tcsncpy_s(ppd.lptzText, TranslateT("A message delivery has failed.\nClick to open the message window."), _TRUNCATE); if (!(BOOL)M.GetByte(MODULE, OPT_COLDEFAULT_ERR, TRUE)) { ppd.colorText = (COLORREF)M.GetDword(MODULE, OPT_COLTEXT_ERR, DEFAULT_COLTEXT); diff --git a/plugins/TabSRMM/src/themeio.cpp b/plugins/TabSRMM/src/themeio.cpp index fe7c19d874..de900af22d 100644 --- a/plugins/TabSRMM/src/themeio.cpp +++ b/plugins/TabSRMM/src/themeio.cpp @@ -134,7 +134,7 @@ static void TSAPI LoadLogfontFromINI(int i, char *szKey, LOGFONTA *lf, COLORREF lf->lfQuality = DEFAULT_QUALITY;
lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
if (i == MSGFONTID_SYMBOLS_IN || i == MSGFONTID_SYMBOLS_OUT) {
- mir_strncpy(lf->lfFaceName, "Webdings", LF_FACESIZE);
+ strncpy_s(lf->lfFaceName, "Webdings", _TRUNCATE);
lf->lfCharSet = SYMBOL_CHARSET;
} else
GetPrivateProfileStringA(szKey, "Face", "Tahoma", lf->lfFaceName, LF_FACESIZE - 1, szIniFilename);
@@ -286,7 +286,7 @@ void TSAPI ReadThemeFromINI(const TCHAR *szIniFilenameT, TContainerData *dat, in mir_snprintf(szAppname, SIZEOF(szAppname), fontBlocks[n].szIniTemp, firstIndex + i);
if (GetPrivateProfileStringA(szAppname, "Face", "Verdana", szBuf, sizeof(szBuf), szIniFilename) != 0) {
if (i == MSGFONTID_SYMBOLS_IN || i == MSGFONTID_SYMBOLS_OUT)
- mir_strncpy(szBuf, "Arial", sizeof(szBuf));
+ strncpy_s(szBuf, "Arial", _TRUNCATE);
db_set_s(NULL, szModule, szTemp, szBuf);
}
diff --git a/plugins/TabSRMM/src/typingnotify.cpp b/plugins/TabSRMM/src/typingnotify.cpp index 51a6d33086..414636501e 100644 --- a/plugins/TabSRMM/src/typingnotify.cpp +++ b/plugins/TabSRMM/src/typingnotify.cpp @@ -115,16 +115,16 @@ void TN_TypingMessage(MCONTACT hContact, int iMode) if (iMode == PROTOTYPE_CONTACTTYPING_OFF) {
if (StopDisabled)
return;
- mir_tstrncpy(ppd.lptzContactName, szContactName, MAX_CONTACTNAME);
- mir_tstrncpy(ppd.lptzText, szStop, MAX_SECONDLINE);
+ _tcsncpy_s(ppd.lptzContactName, szContactName, _TRUNCATE);
+ _tcsncpy_s(ppd.lptzText, szStop, _TRUNCATE);
ppd.hNotification = hntfStopped;
notyping = 1;
}
else {
if (StartDisabled)
return;
- mir_tstrncpy(ppd.lptzContactName, szContactName, MAX_CONTACTNAME);
- mir_tstrncpy(ppd.lptzText, szStart, MAX_SECONDLINE);
+ _tcsncpy_s(ppd.lptzContactName, szContactName, _TRUNCATE);
+ _tcsncpy_s(ppd.lptzText, szStart, _TRUNCATE);
ppd.hNotification = hntfStarted;
notyping = 0;
}
@@ -307,13 +307,13 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA for (i=0; i < 2; i++) {
int notyping;
if (i == PROTOTYPE_CONTACTTYPING_OFF) {
- mir_tstrcpy(ppd.lptzContactName, TranslateT("Contact"));
- mir_tstrncpy(ppd.lptzText, szStop, MAX_SECONDLINE);
+ _tcsncpy_s(ppd.lptzContactName, TranslateT("Contact"), _TRUNCATE);
+ _tcsncpy_s(ppd.lptzText, szStop, _TRUNCATE);
notyping = 1;
}
else {
- mir_tstrcpy(ppd.lptzContactName, TranslateT("Contact"));
- mir_tstrncpy(ppd.lptzText, szStart, MAX_SECONDLINE);
+ _tcsncpy_s(ppd.lptzContactName, TranslateT("Contact"), _TRUNCATE);
+ _tcsncpy_s(ppd.lptzText, szStart, _TRUNCATE);
notyping = 0;
}
|