summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2015-02-28 11:05:09 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2015-02-28 11:05:09 +0000
commitb1530a48bd67d19f6a18355e04a884b36c696e8b (patch)
tree539cc8c4387b586658898a146b8876cc133f8783
parent4e2a8eb11a9a4286eb0bcb3386bab58e87ae4b69 (diff)
Tipper:
- minor bugfixes git-svn-id: http://svn.miranda-ng.org/main/trunk@12284 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/TipperYM/src/mir_smileys.cpp14
-rw-r--r--plugins/TipperYM/src/options.cpp9
-rw-r--r--plugins/TipperYM/src/popwin.cpp10
-rw-r--r--plugins/TipperYM/src/skin_parser.cpp23
-rw-r--r--plugins/TipperYM/src/str_utils.cpp24
-rw-r--r--plugins/TipperYM/src/subst.cpp2
-rw-r--r--plugins/TipperYM/src/translations.cpp10
7 files changed, 35 insertions, 57 deletions
diff --git a/plugins/TipperYM/src/mir_smileys.cpp b/plugins/TipperYM/src/mir_smileys.cpp
index 9c55d8c5c9..ca94e5310c 100644
--- a/plugins/TipperYM/src/mir_smileys.cpp
+++ b/plugins/TipperYM/src/mir_smileys.cpp
@@ -335,28 +335,26 @@ void DestroySmileyList(SortedList* p_list)
// Generete the list of smileys / text to be drawn
SortedList *ReplaceSmileys(const TCHAR *text, int text_size, const char *protocol, int *max_smiley_height)
{
- SMADD_BATCHPARSE2 sp = {0};
- SMADD_BATCHPARSERES *spres;
- char smileyProto[64];
-
*max_smiley_height = 0;
if (!text || !text[0] || !ServiceExists(MS_SMILEYADD_BATCHPARSE))
return NULL;
+ char smileyProto[64];
if (protocol == NULL)
- strcpy(smileyProto, "tipper");
+ strncpy(smileyProto, "tipper", sizeof(smileyProto) - 1);
else if (strcmp(protocol, META_PROTO) == 0)
- strcpy(smileyProto, "tipper");
+ strncpy(smileyProto, "tipper", sizeof(smileyProto) - 1);
else
- strcpy(smileyProto, protocol);
+ strncpy(smileyProto, protocol, sizeof(smileyProto) - 1);
// Parse it!
+ SMADD_BATCHPARSE2 sp = {0};
sp.cbSize = sizeof(sp);
sp.str = (TCHAR *)text;
sp.flag = SAFL_TCHAR;
sp.Protocolname = (opt.iSmileyAddFlags & SMILEYADD_USEPROTO) ? smileyProto : "tipper";
- spres = (SMADD_BATCHPARSERES *)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&sp);
+ SMADD_BATCHPARSERES *spres = (SMADD_BATCHPARSERES *)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&sp);
if (!spres) // Did not find a smiley
return NULL;
diff --git a/plugins/TipperYM/src/options.cpp b/plugins/TipperYM/src/options.cpp
index 2fb412bfae..f65d2fdf5a 100644
--- a/plugins/TipperYM/src/options.cpp
+++ b/plugins/TipperYM/src/options.cpp
@@ -554,7 +554,7 @@ void LoadOptions()
{
if (!db_get_ts(NULL, MODULE, "SkinName", &dbv))
{
- _tcscpy(opt.szSkinName, dbv.ptszVal);
+ _tcsncpy(opt.szSkinName, dbv.ptszVal,SIZEOF(opt.szSkinName)-1);
db_free(&dbv);
}
}
@@ -989,10 +989,10 @@ INT_PTR CALLBACK DlgProcOptsContent(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
_tcscpy(ds_value->ds.swzName, subst->swzName);
if (ds_value->ds.type == DVT_DB && subst->szModuleName)
- strcpy(ds_value->ds.szModuleName, subst->szModuleName);
+ strncpy(ds_value->ds.szModuleName, subst->szModuleName, SIZEOF(ds_value->ds.szModuleName) - 1);
if (subst->szSettingName)
- strcpy(ds_value->ds.szSettingName, subst->szSettingName);
+ strncpy(ds_value->ds.szSettingName, subst->szSettingName, SIZEOF(ds_value->ds.szSettingName) - 1);
ds_value->ds.iTranslateFuncId = subst->iTranslateFuncId;
@@ -1474,8 +1474,7 @@ INT_PTR CALLBACK DlgProcOptsAppearance(HWND hwndDlg, UINT msg, WPARAM wParam, LP
if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY)
{
BOOL trans;
- int new_val;
- new_val = GetDlgItemInt(hwndDlg, IDC_ED_WIDTH, &trans, FALSE);
+ int new_val = GetDlgItemInt(hwndDlg, IDC_ED_WIDTH, &trans, FALSE);
if (trans) opt.iWinWidth = new_val;
new_val = GetDlgItemInt(hwndDlg, IDC_ED_MINWIDTH, &trans, FALSE);
if (trans) opt.iMinWidth = new_val;
diff --git a/plugins/TipperYM/src/popwin.cpp b/plugins/TipperYM/src/popwin.cpp
index b1bad12c69..18be576c2e 100644
--- a/plugins/TipperYM/src/popwin.cpp
+++ b/plugins/TipperYM/src/popwin.cpp
@@ -22,15 +22,17 @@ Boston, MA 02111-1307, USA.
__inline void AddRow(PopupWindowData *pwd, TCHAR *swzLabel, TCHAR *swzValue, char *szProto, bool bParseSmileys, bool bNewline, bool bLineAbove, bool bIsTitle = false, HICON hIcon = NULL)
{
- pwd->rows = (RowData *)mir_realloc(pwd->rows, sizeof(RowData) * (pwd->iRowCount + 1));
+ RowData *pRows = (RowData *)mir_realloc(pwd->rows, sizeof(RowData) * (pwd->iRowCount + 1));
+ if (pRows == NULL)
+ return;
+ pwd->rows = pRows;
pwd->rows[pwd->iRowCount].swzLabel = swzLabel ? mir_tstrdup(swzLabel) : NULL;
pwd->rows[pwd->iRowCount].swzValue = swzValue ? mir_tstrdup(swzValue) : NULL;
pwd->rows[pwd->iRowCount].spi = bParseSmileys ? Smileys_PreParse(swzValue, (int)_tcslen(swzValue), szProto) : NULL;
pwd->rows[pwd->iRowCount].bValueNewline = bNewline;
pwd->rows[pwd->iRowCount].bLineAbove = bLineAbove;
pwd->rows[pwd->iRowCount].bIsTitle = bIsTitle;
- pwd->rows[pwd->iRowCount].hIcon = hIcon;
- pwd->iRowCount++;
+ pwd->rows[pwd->iRowCount++].hIcon = hIcon;
}
LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
@@ -1141,7 +1143,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
}
// titlebar height
- if (!pwd->bIsTextTip && pwd->swzTitle && opt.bShowTitle) {
+ if (!pwd->bIsTextTip && opt.bShowTitle) {
smr.top = smr.bottom = 0;
smr.left = rc.left + opt.iPadding + pwd->iIndent;
smr.right = rc.right;
diff --git a/plugins/TipperYM/src/skin_parser.cpp b/plugins/TipperYM/src/skin_parser.cpp
index d5db13e01d..f93448d397 100644
--- a/plugins/TipperYM/src/skin_parser.cpp
+++ b/plugins/TipperYM/src/skin_parser.cpp
@@ -167,23 +167,22 @@ void ParseImagePart(FILE *fp, TCHAR *buff, int iPart)
}
}
-char *GetSettingName(TCHAR *szValue, char *szPostfix, char *buff)
+char *GetSettingName(TCHAR *szValue, char *szPostfix, char *buff, size_t buffsize)
{
buff[0] = 0;
if (_tcsstr(szValue, _T("traytitle")))
- mir_snprintf(buff, SIZEOF(buff), "FontTrayTitle%s", szPostfix);
+ mir_snprintf(buff, buffsize, "FontTrayTitle%s", szPostfix);
else if (_tcsstr(szValue, _T("title")))
- mir_snprintf(buff, SIZEOF(buff), "FontFirst%s", szPostfix);
+ mir_snprintf(buff, buffsize, "FontFirst%s", szPostfix);
else if (_tcsstr(szValue, _T("label")))
- mir_snprintf(buff, SIZEOF(buff), "FontLabels%s", szPostfix);
+ mir_snprintf(buff, buffsize, "FontLabels%s", szPostfix);
else if (_tcsstr(szValue, _T("value")))
- mir_snprintf(buff, SIZEOF(buff), "FontValues%s", szPostfix);
+ mir_snprintf(buff, buffsize, "FontValues%s", szPostfix);
else if (_tcsstr(szValue, _T("divider")))
- mir_snprintf(buff, SIZEOF(buff), "Divider%s", szPostfix);
+ mir_snprintf(buff, buffsize, "Divider%s", szPostfix);
- if (buff[0]) return buff;
- else return NULL;
+ return buff[0] ? buff : NULL;
}
void ParseFontPart(FILE *fp, TCHAR *buff)
@@ -205,7 +204,7 @@ void ParseFontPart(FILE *fp, TCHAR *buff)
{
if (_tcsstr(buff, _T("face")))
{
- if (GetSettingName(buff, "", szSetting))
+ if (GetSettingName(buff, "", szSetting, sizeof(szSetting) - 1))
{
if (_tcslen(pch) > 32)
pch[32] = 0;
@@ -215,7 +214,7 @@ void ParseFontPart(FILE *fp, TCHAR *buff)
}
else if (_tcsstr(buff, _T("color")))
{
- if (GetSettingName(buff, "Col", szSetting))
+ if (GetSettingName(buff, "Col", szSetting, sizeof(szSetting) - 1))
{
BYTE r = _ttoi(pch);
pch = _tcschr(pch, ' ');
@@ -234,7 +233,7 @@ void ParseFontPart(FILE *fp, TCHAR *buff)
}
else if (_tcsstr(buff, _T("size")))
{
- if (GetSettingName(buff, "Size", szSetting))
+ if (GetSettingName(buff, "Size", szSetting, sizeof(szSetting) - 1))
{
HDC hdc = GetDC(0);
int size = -MulDiv(_ttoi(pch), GetDeviceCaps(hdc, LOGPIXELSY), 72);
@@ -244,7 +243,7 @@ void ParseFontPart(FILE *fp, TCHAR *buff)
}
else if (_tcsstr(buff, _T("effect")))
{
- if (GetSettingName(buff, "Sty", szSetting))
+ if (GetSettingName(buff, "Sty", szSetting, sizeof(szSetting) - 1))
{
BYTE effect = 0;
if (_tcsstr(pch, _T("font_bold")))
diff --git a/plugins/TipperYM/src/str_utils.cpp b/plugins/TipperYM/src/str_utils.cpp
index 2189b34312..a79cb3b351 100644
--- a/plugins/TipperYM/src/str_utils.cpp
+++ b/plugins/TipperYM/src/str_utils.cpp
@@ -69,46 +69,34 @@ bool utf2a(const char *us, char *buff, int bufflen)
bool t2w(const TCHAR *ts, wchar_t *buff, int bufflen)
{
-
wcsncpy(buff, ts, bufflen);
return true;
-
}
bool w2t(const wchar_t *ws, TCHAR *buff, int bufflen)
{
-
wcsncpy(buff, ws, bufflen);
return true;
-
}
bool t2a(const TCHAR *ts, char *buff, int bufflen)
{
-
return w2a(ts, buff, bufflen);
-
}
bool a2t(const char *as, TCHAR *buff, int bufflen)
{
-
return a2w(as, buff, bufflen);
-
}
bool t2utf(const TCHAR *ts, char *buff, int bufflen)
{
-
return w2utf(ts, buff, bufflen);
-
}
bool utf2t(const char *us, TCHAR *buff, int bufflen)
{
-
return utf2w(us, buff, bufflen);
-
}
wchar_t *utf2w(const char *us)
@@ -175,49 +163,39 @@ char *a2utf(const char *as)
TCHAR *w2t(const wchar_t *ws)
{
-
return mir_wstrdup(ws);
-
}
wchar_t *t2w(const TCHAR *ts)
{
-
return mir_tstrdup(ts);
-
}
char *t2a(const TCHAR *ts)
{
-
return w2a(ts);
-
}
TCHAR *a2t(const char *as)
{
-
return a2w(as);
-
}
TCHAR *utf2t(const char *utfs)
{
-
return utf2w(utfs);
}
char *t2utf(const TCHAR *ts)
{
-
return w2utf(ts);
}
TCHAR *myfgets(TCHAR *Buf, int MaxCount, FILE *File)
{
_fgetts(Buf, MaxCount, File);
- for (size_t i = _tcslen(Buf) - 1; i >= 0; i--)
+ for (size_t i = _tcslen(Buf) - 1; ; i--)
{
if (Buf[i] == '\n' || Buf[i] == ' ')
Buf[i] = 0;
diff --git a/plugins/TipperYM/src/subst.cpp b/plugins/TipperYM/src/subst.cpp
index d5f9869211..b2765a9b3b 100644
--- a/plugins/TipperYM/src/subst.cpp
+++ b/plugins/TipperYM/src/subst.cpp
@@ -144,7 +144,7 @@ void FormatTimestamp(DWORD ts, char *szFormat, TCHAR *buff, int bufflen)
bool Uid(MCONTACT hContact, char *szProto, TCHAR *buff, int bufflen)
{
- char *tmpProto = (hContact) ? tmpProto = GetContactProto(hContact) : szProto;
+ char *tmpProto = (hContact ? GetContactProto(hContact) : szProto);
if (tmpProto) {
char *szUid = (char*)CallProtoService(tmpProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
if (szUid && (INT_PTR)szUid != CALLSERVICE_NOTFOUND)
diff --git a/plugins/TipperYM/src/translations.cpp b/plugins/TipperYM/src/translations.cpp
index a6d13cc0d1..85a0473c92 100644
--- a/plugins/TipperYM/src/translations.cpp
+++ b/plugins/TipperYM/src/translations.cpp
@@ -28,14 +28,16 @@ HANDLE hServiceAdd;
void AddTranslation(DBVTranslation *newTrans)
{
+ DBVTranslation *ptranslations = (DBVTranslation *)mir_realloc(translations, sizeof(DBVTranslation) * (iTransFuncsCount+1));
+ if (ptranslations == NULL)
+ return;
+ translations = ptranslations;
iTransFuncsCount++;
-
- translations = (DBVTranslation *)mir_realloc(translations, sizeof(DBVTranslation) * iTransFuncsCount);
translations[iTransFuncsCount - 1] = *newTrans;
char *szName = mir_t2a(newTrans->swzName);
- char szSetting[256] = "Trans_";
- strcat(szSetting, szName);
+ char szSetting[256];
+ mir_snprintf(szSetting, sizeof(szSetting),"Trans_%s",szName);
if (_tcscmp(newTrans->swzName, _T("[No translation]")) == 0)
{