diff options
author | George Hazan <george.hazan@gmail.com> | 2016-07-26 09:20:25 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-07-26 09:20:25 +0000 |
commit | 6e53dfca72b932c4bdcd7aa02ca62bf8b2630eac (patch) | |
tree | 2e8bb660c908b54914abd562af8aafa4a486c846 /plugins/HistoryLinkListPlus/src/linklist_fct.cpp | |
parent | a61c8728b379057fe7f0a0d86fe0b037598229dd (diff) |
less TCHARs:
- TCHAR is replaced with wchar_t everywhere;
- LPGENT replaced with either LPGENW or LPGEN;
- fixes for ANSI plugins that improperly used _t functions;
- TCHAR *t removed from MAllStrings;
- ptszGroup, ptszTitle & ptszTab in OPTIONSDIALOGPAGE replaced with pwsz*
git-svn-id: http://svn.miranda-ng.org/main/trunk@17133 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/HistoryLinkListPlus/src/linklist_fct.cpp')
-rw-r--r-- | plugins/HistoryLinkListPlus/src/linklist_fct.cpp | 125 |
1 files changed, 62 insertions, 63 deletions
diff --git a/plugins/HistoryLinkListPlus/src/linklist_fct.cpp b/plugins/HistoryLinkListPlus/src/linklist_fct.cpp index 558a931e05..7517494115 100644 --- a/plugins/HistoryLinkListPlus/src/linklist_fct.cpp +++ b/plugins/HistoryLinkListPlus/src/linklist_fct.cpp @@ -45,11 +45,11 @@ int ExtractURI(DBEVENTINFO *dbei, MEVENT hEvent, LISTELEMENT *listStart) LISTELEMENT *newElement, *actualElement;
BYTE type = LINK_UNKNOWN;
int direction, isLink, linkFound = 0;
- TCHAR date[DATE_SIZE + 1];
- TCHAR time[TIME_SIZE + 1];
- TCHAR link[LINK_MAX + 1];
- TCHAR templink[LINK_MAX + 1];
- TCHAR dbdate[DATE_SIZE + TIME_SIZE];
+ wchar_t date[DATE_SIZE + 1];
+ wchar_t time[TIME_SIZE + 1];
+ wchar_t link[LINK_MAX + 1];
+ wchar_t templink[LINK_MAX + 1];
+ wchar_t dbdate[DATE_SIZE + TIME_SIZE];
if (listStart == NULL)
return -1;
@@ -66,26 +66,26 @@ int ExtractURI(DBEVENTINFO *dbei, MEVENT hEvent, LISTELEMENT *listStart) //hyperlinks are delimited by: <non-alphanumeric>"hyperlink"<whitespace>
//then all punctuation is stripped from the end of "hyperlink"
iLastAlphaNum = 0;
- while (msg[i] && !_istalnum(msg[i])) {
+ while (msg[i] && !iswalnum(msg[i])) {
// support for files
- if (msg[i] == _T('\\') && msg[i + 1] == _T('\\') && _istalnum(msg[i + 2]))
+ if (msg[i] == '\\' && msg[i + 1] == '\\' && iswalnum(msg[i + 2]))
break;
if(IsDBCSLeadByte(msg[i]) && msg[i + 1])
i ++;
i ++;
- if (msg[i] != _T('\n'))
+ if (msg[i] != '\n')
charCount ++;
}
- if (msg[i] == _T('\0'))
+ if (msg[i] == '\0')
break;
cpWordStart = charCount;
wordStart = i;
- while (msg[i] && !_istspace(msg[i])) {
+ while (msg[i] && !iswspace(msg[i])) {
if (IsDBCSLeadByte(msg[i]) && msg[i + 1]) {
i ++;
} else {
- if (_istalnum(msg[i]) || msg[i]==_T('/')) {
+ if (iswalnum(msg[i]) || msg[i]=='/') {
cpLastAlphaNum = charCount;
iLastAlphaNum = i;
}
@@ -102,8 +102,8 @@ int ExtractURI(DBEVENTINFO *dbei, MEVENT hEvent, LISTELEMENT *listStart) isLink = 0;
wordlen = (i - wordStart + 1);
- word = (LPTSTR)mir_alloc(wordlen * sizeof(TCHAR));
- wordsearch = (LPTSTR)mir_alloc(wordlen * sizeof(TCHAR));
+ word = (LPTSTR)mir_alloc(wordlen * sizeof(wchar_t));
+ wordsearch = (LPTSTR)mir_alloc(wordlen * sizeof(wchar_t));
if (word == NULL || wordsearch == NULL) {
mir_free(word);
mir_free(wordsearch);
@@ -111,26 +111,26 @@ int ExtractURI(DBEVENTINFO *dbei, MEVENT hEvent, LISTELEMENT *listStart) break;
}
- _tcsncpy_s(word, wordlen, msg + wordStart, (wordlen - 1));
- _tcsncpy_s(wordsearch, wordlen, msg + wordStart, (wordlen - 1));
+ wcsncpy_s(word, wordlen, msg + wordStart, (wordlen - 1));
+ wcsncpy_s(wordsearch, wordlen, msg + wordStart, (wordlen - 1));
CharLower(wordsearch);
for (j = 0; j < _countof(hyperlinkPrefixes); j ++) {
- if (!_tcsncmp(wordsearch, hyperlinkPrefixes[j], mir_tstrlen(hyperlinkPrefixes[j]))) {
+ if (!wcsncmp(wordsearch, hyperlinkPrefixes[j], mir_tstrlen(hyperlinkPrefixes[j]))) {
isLink = 1;
break;
}
}
if (!isLink) {
for (j = 0; j < _countof(hyperlinkSubstrings); j ++) {
- if (_tcsstr(wordsearch + 1,hyperlinkSubstrings[j])) {
+ if (wcsstr(wordsearch + 1,hyperlinkSubstrings[j])) {
isLink = 1;
break;
}
}
}
- if (_tcschr(wordsearch,_T('@')) && _tcschr(wordsearch,_T('.')) && !_tcschr(wordsearch,_T(':')) && !_tcschr(wordsearch,_T('/'))) {
+ if (wcschr(wordsearch,'@') && wcschr(wordsearch,'.') && !wcschr(wordsearch,':') && !wcschr(wordsearch,'/')) {
isLink = 1; //e-mail addresses
type = LINK_MAIL;
} else if (isLink) {
@@ -138,29 +138,28 @@ int ExtractURI(DBEVENTINFO *dbei, MEVENT hEvent, LISTELEMENT *listStart) }
if (isLink && wordlen <= LINK_MAX) {
- if (_tcsstr(wordsearch, L"www.") != NULL && _tcsstr(wordsearch, L"http://") == NULL && _tcsstr(wordsearch, L"https://") == NULL) {
- _tcsncpy_s(link, L"http://", LINK_MAX);
- _tcsncat_s(link, word, LINK_MAX);
+ if (wcsstr(wordsearch, L"www.") != NULL && wcsstr(wordsearch, L"http://") == NULL && wcsstr(wordsearch, L"https://") == NULL) {
+ wcsncpy_s(link, L"http://", LINK_MAX);
+ wcsncat_s(link, word, LINK_MAX);
} else {
- _tcsncpy_s(link, word, LINK_MAX);
+ wcsncpy_s(link, word, LINK_MAX);
}
TimeZone_ToStringT(dbei->timestamp, L"d-t", dbdate, _countof(dbdate));
- date_ptr = _tcstok_s(dbdate, L"-", &tok_ctx);
- time_ptr = _tcstok_s(NULL, L"-", &tok_ctx);
- _tcsncpy_s(date, date_ptr, _TRUNCATE);
- _tcsncpy_s(time, time_ptr, _TRUNCATE);
+ date_ptr = wcstok_s(dbdate, L"-", &tok_ctx);
+ time_ptr = wcstok_s(NULL, L"-", &tok_ctx);
+ wcsncpy_s(date, date_ptr, _TRUNCATE);
+ wcsncpy_s(time, time_ptr, _TRUNCATE);
- if (dbei->flags & DBEF_SENT) {
+ if (dbei->flags & DBEF_SENT)
direction = DIRECTION_OUT;
- } else {
+ else
direction = DIRECTION_IN;
- }
- if (type == LINK_MAIL && _tcsstr(link, L"mailto:") == NULL) {
- _tcsncpy_s(templink, link, _TRUNCATE);
- _tcsncpy_s(link, L"mailto:", _TRUNCATE);
- _tcsncpy_s((link + _mstrlen(L"mailto:")), (_countof(link) - _mstrlen(L"mailto:")), templink, _TRUNCATE);
+ if (type == LINK_MAIL && wcsstr(link, L"mailto:") == NULL) {
+ wcsncpy_s(templink, link, _TRUNCATE);
+ wcsncpy_s(link, L"mailto:", _TRUNCATE);
+ wcsncpy_s((link + _mstrlen(L"mailto:")), (_countof(link) - _mstrlen(L"mailto:")), templink, _TRUNCATE);
}
// Add new Element to list:
@@ -172,9 +171,9 @@ int ExtractURI(DBEVENTINFO *dbei, MEVENT hEvent, LISTELEMENT *listStart) memset(newElement, 0, sizeof(LISTELEMENT));
newElement->direction = direction;
newElement->type = type;
- _tcsncpy_s(newElement->date, date, _TRUNCATE);
- _tcsncpy_s(newElement->time, time, _TRUNCATE);
- _tcsncpy_s(newElement->link, link, _TRUNCATE);
+ wcsncpy_s(newElement->date, date, _TRUNCATE);
+ wcsncpy_s(newElement->time, time, _TRUNCATE);
+ wcsncpy_s(newElement->link, link, _TRUNCATE);
newElement->hEvent = hEvent;
actualElement = listStart;
@@ -249,10 +248,10 @@ void WriteLinkList(HWND hDlg, BYTE params, LISTELEMENT *listStart, LPCTSTR searc HWND hwndProgress = NULL;
RECT DesktopRect;
MYCOLOURSET colourSet;
- TCHAR textLine[LINK_MAX + DIR_SIZE + TIME_SIZE + TYPE_SIZE + 6];
- TCHAR searchText[320];
- TCHAR lastDate[11] = {0};
- TCHAR filter1, filter2, filter3;
+ wchar_t textLine[LINK_MAX + DIR_SIZE + TIME_SIZE + TYPE_SIZE + 6];
+ wchar_t searchText[320];
+ wchar_t lastDate[11] = {0};
+ wchar_t filter1, filter2, filter3;
size_t lineLen, listCount=0, realListCount=0, actCount=0, len, appCount = 0;
int linePos = -1;
LISTELEMENT *actualElement;
@@ -303,7 +302,7 @@ void WriteLinkList(HWND hDlg, BYTE params, LISTELEMENT *listStart, LPCTSTR searc cf.dwMask = CFM_ITALIC | CFM_BOLD | CFM_FACE | CFM_COLOR;
cf.dwEffects = CFE_BOLD;
cf.crTextColor = colourSet.text;
- _tcscpy_s(cf.szFaceName, L"Arial");
+ wcscpy_s(cf.szFaceName, L"Arial");
SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf);
mir_sntprintf(searchText, L"%s '%s': %d\n\n", TranslateT("Matches for searchtext"), searchString, listCount);
@@ -314,7 +313,7 @@ void WriteLinkList(HWND hDlg, BYTE params, LISTELEMENT *listStart, LPCTSTR searc memset(&cf, 0, sizeof(cf));
cf.cbSize = sizeof(cf);
cf.dwMask = CFM_FACE | CFM_BOLD;
- _tcscpy_s(cf.szFaceName, L"Courier");
+ wcscpy_s(cf.szFaceName, L"Courier");
SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
}
@@ -325,13 +324,13 @@ void WriteLinkList(HWND hDlg, BYTE params, LISTELEMENT *listStart, LPCTSTR searc linePos = GetLastLinePos(listStart);
if ((realListCount - append) == 1)
- _tcscpy_s(lastDate, actualElement->date);
+ wcscpy_s(lastDate, actualElement->date);
for(appCount = 1; appCount <= (realListCount - append); appCount++)
{
actualElement = actualElement->nextElement;
if(appCount == (realListCount - append - 1))
- _tcscpy_s(lastDate, actualElement->date);
+ wcscpy_s(lastDate, actualElement->date);
}
gtl.flags = GTL_PRECISE;
gtl.codepage = CP_ACP;
@@ -385,7 +384,7 @@ void WriteLinkList(HWND hDlg, BYTE params, LISTELEMENT *listStart, LPCTSTR searc db_event_get(actualElement->hEvent, &dbe);
dbe.pBlob[dbe.cbBlob] = 0;
LPTSTR msg = DbGetEventTextT(&dbe, CP_ACP);
- if ( _tcsstr(msg, searchString))
+ if ( wcsstr(msg, searchString))
filter3 = 1;
mir_free(dbe.pBlob);
@@ -393,7 +392,7 @@ void WriteLinkList(HWND hDlg, BYTE params, LISTELEMENT *listStart, LPCTSTR searc }
else filter3 = 0;
}
- else if ( _tcsstr(actualElement->link, searchString))
+ else if ( wcsstr(actualElement->link, searchString))
filter3 = 1;
}
else filter3 = 1;
@@ -415,7 +414,7 @@ void WriteLinkList(HWND hDlg, BYTE params, LISTELEMENT *listStart, LPCTSTR searc cf.cbSize = sizeof(cf);
cf.dwMask = CFM_ITALIC | CFM_BOLD | CFM_FACE;
cf.dwEffects = CFE_BOLD;
- _tcscpy_s(cf.szFaceName, L"Arial");
+ wcscpy_s(cf.szFaceName, L"Arial");
SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf);
if ( options.showDate != 0 )
{
@@ -423,11 +422,11 @@ void WriteLinkList(HWND hDlg, BYTE params, LISTELEMENT *listStart, LPCTSTR searc SendDlgItemMessage( hDlg, IDC_MAIN, EM_REPLACESEL, FALSE, (LPARAM) L"\n\n");
linePos += 3;
}
- _tcscpy_s(lastDate, actualElement->date);
+ wcscpy_s(lastDate, actualElement->date);
memset(&cf, 0, sizeof(cf));
cf.cbSize = sizeof cf;
cf.dwMask = CFM_ITALIC | CFM_BOLD | CFM_UNDERLINE | CFM_FACE;
- _tcscpy_s(cf.szFaceName, L"Courier");
+ wcscpy_s(cf.szFaceName, L"Courier");
SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf);
}
memset(&cf, 0, sizeof(cf));
@@ -485,7 +484,7 @@ void WriteLinkList(HWND hDlg, BYTE params, LISTELEMENT *listStart, LPCTSTR searc cf.cbSize = sizeof(cf);
cf.dwMask = CFM_ITALIC | CFM_BOLD | CFM_FACE;
cf.dwEffects = CFE_BOLD;
- _tcscpy_s(cf.szFaceName, L"Arial");
+ wcscpy_s(cf.szFaceName, L"Arial");
SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf);
SendDlgItemMessage( hDlg, IDC_MAIN, EM_REPLACESEL, FALSE, (LPARAM)TranslateT("No messages found!\nPlease change current filter options."));
SendDlgItemMessage( hDlg, IDC_MAIN, EM_REPLACESEL, FALSE, (LPARAM)L"\n");
@@ -525,7 +524,7 @@ int WriteOptionExample(HWND hDlg, DWORD InColourSel, DWORD OutColourSel, DWORD B memset(&cf, 0, sizeof(cf));
cf.cbSize = sizeof(cf);
cf.dwMask = CFM_FACE | CFM_BOLD | CFM_ITALIC | CFM_COLOR;
- _tcscpy_s(cf.szFaceName, L"Courier");
+ wcscpy_s(cf.szFaceName, L"Courier");
cf.crTextColor = TxtColourSel;
SendDlgItemMessage( hDlg, IDC_OPTIONS_RE, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf);
if ( options->showLine == 1 )
@@ -537,7 +536,7 @@ int WriteOptionExample(HWND hDlg, DWORD InColourSel, DWORD OutColourSel, DWORD B cf.cbSize = sizeof(cf);
cf.dwMask = CFM_BOLD | CFM_FACE | CFM_COLOR;
cf.dwEffects = CFE_BOLD;
- _tcscpy_s(cf.szFaceName, L"Arial");
+ wcscpy_s(cf.szFaceName, L"Arial");
cf.crTextColor = TxtColourSel;
SendDlgItemMessage( hDlg, IDC_OPTIONS_RE, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf);
@@ -549,7 +548,7 @@ int WriteOptionExample(HWND hDlg, DWORD InColourSel, DWORD OutColourSel, DWORD B memset(&cf, 0, sizeof(cf));
cf.cbSize = sizeof(cf);
cf.dwMask = CFM_ITALIC | CFM_BOLD | CFM_UNDERLINE | CFM_FACE;
- _tcscpy_s(cf.szFaceName, L"Courier");
+ wcscpy_s(cf.szFaceName, L"Courier");
SendDlgItemMessage( hDlg, IDC_OPTIONS_RE, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf);
// incoming
@@ -557,7 +556,7 @@ int WriteOptionExample(HWND hDlg, DWORD InColourSel, DWORD OutColourSel, DWORD B cf.cbSize = sizeof(cf);
cf.dwMask = CFM_COLOR | CFM_FACE;
cf.crTextColor = InColourSel;
- _tcscpy_s(cf.szFaceName, L"Courier");
+ wcscpy_s(cf.szFaceName, L"Courier");
SendDlgItemMessage(hDlg, IDC_OPTIONS_RE, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf );
if ( options->showDirection == 1 )
@@ -580,7 +579,7 @@ int WriteOptionExample(HWND hDlg, DWORD InColourSel, DWORD OutColourSel, DWORD B cf.cbSize = sizeof(cf);
cf.dwMask = CFM_COLOR | CFM_FACE;
cf.crTextColor = OutColourSel;
- _tcscpy_s(cf.szFaceName, L"Courier");
+ wcscpy_s(cf.szFaceName, L"Courier");
SendDlgItemMessage(hDlg, IDC_OPTIONS_RE, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
@@ -718,13 +717,13 @@ Little helper function to draw a horizontal line */
void DrawLine(HWND hDlg, size_t lineLen)
{
- TCHAR line[LINK_MAX + 18];
+ wchar_t line[LINK_MAX + 18];
size_t i;
for (i=0; (i<lineLen+18)&&(i<LINK_MAX+18); i++ )
{
- line[i] = _T('_');
+ line[i] = '_';
}
- line[lineLen+18] = _T('\0');
+ line[lineLen+18] = '\0';
SendDlgItemMessage( hDlg, IDC_MAIN, EM_REPLACESEL, FALSE, (LPARAM)line);
SendDlgItemMessage( hDlg, IDC_MAIN, EM_REPLACESEL, FALSE, (LPARAM)L"\n");
return;
@@ -775,7 +774,7 @@ void GetListInfo(BYTE params, LISTELEMENT *listStart, LPCTSTR searchString, siz dbe.pBlob = (PBYTE)mir_alloc(dbe.cbBlob+1);
db_event_get(actualElement->hEvent, &dbe);
dbe.pBlob[dbe.cbBlob] = 0;
- if ( _tcsstr((LPTSTR)dbe.pBlob, searchString))
+ if ( wcsstr((LPTSTR)dbe.pBlob, searchString))
filter3 = 1;
mir_free(dbe.pBlob);
@@ -785,7 +784,7 @@ void GetListInfo(BYTE params, LISTELEMENT *listStart, LPCTSTR searchString, siz }
else
{
- if(_tcsstr(actualElement->link, searchString))
+ if(wcsstr(actualElement->link, searchString))
filter3 = 1;
}
}
@@ -1238,15 +1237,15 @@ BOOL SaveEditAsStream( HWND hDlg ) LONG lOut;
OPENFILENAME ofn;
HANDLE hFile;
- TCHAR szFilename[MAX_PATH];
+ wchar_t szFilename[MAX_PATH];
// Initialize filename field
- _tcscpy_s(szFilename, L"*.rtf");
+ wcscpy_s(szFilename, L"*.rtf");
// Fill in OPENFILENAME struct
memset(&ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hDlg;
- TCHAR temp[MAX_PATH];
+ wchar_t temp[MAX_PATH];
mir_sntprintf(temp, L"%s (*.rtf)%c*.rtf%c%s (*.*)%c*.*%c%c", TranslateT("RTF file"), 0, 0, TranslateT("All files"), 0, 0, 0);
ofn.lpstrFilter = temp;
ofn.lpstrFile = szFilename;
|