diff options
author | George Hazan <george.hazan@gmail.com> | 2014-12-02 20:19:18 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-12-02 20:19:18 +0000 |
commit | aeae01dc50a5adea8fe003c8195540b1f2b2169f (patch) | |
tree | 2c8f055fc562f9365e00577147fefb1a609b51c8 /plugins/Scriver | |
parent | 7cc46e2ce850957887aa75146585bca56b10695d (diff) |
more transparent implementation of AppendToBuffer
git-svn-id: http://svn.miranda-ng.org/main/trunk@11222 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Scriver')
-rw-r--r-- | plugins/Scriver/src/globals.h | 2 | ||||
-rw-r--r-- | plugins/Scriver/src/msglog.cpp | 143 | ||||
-rw-r--r-- | plugins/Scriver/src/msgwindow.cpp | 15 | ||||
-rw-r--r-- | plugins/Scriver/src/utils.cpp | 10 | ||||
-rw-r--r-- | plugins/Scriver/src/utils.h | 2 |
5 files changed, 85 insertions, 87 deletions
diff --git a/plugins/Scriver/src/globals.h b/plugins/Scriver/src/globals.h index 58c94545c7..8fa58f6d4f 100644 --- a/plugins/Scriver/src/globals.h +++ b/plugins/Scriver/src/globals.h @@ -87,7 +87,7 @@ struct GlobalMessageData HANDLE hParentWindowList;
ParentWindowData *lastParent;
ParentWindowData *lastChatParent;
- int limitNamesLength;
+ DWORD limitNamesLength;
int activeAlpha;
int inactiveAlpha;
HMENU hMenuANSIEncoding;
diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp index 0ca661d1f2..f29db42b95 100644 --- a/plugins/Scriver/src/msglog.cpp +++ b/plugins/Scriver/src/msglog.cpp @@ -251,19 +251,19 @@ static void freeEvent(EventData *evt) mir_free(evt);
}
-static int AppendUnicodeOrAnsiiToBufferL(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, const WCHAR *line, size_t maxLen, BOOL isAnsii)
+static int AppendUnicodeOrAnsiiToBufferL(char *&buffer, size_t &cbBufferEnd, size_t &cbBufferAlloced, const WCHAR *line, size_t maxLen, BOOL isAnsii)
{
if (maxLen == -1)
maxLen = wcslen(line);
const WCHAR *maxLine = line + maxLen;
size_t lineLen = maxLen*9 + 8;
- if (*cbBufferEnd + lineLen > *cbBufferAlloced) {
- cbBufferAlloced[0] += int(lineLen + 1024 - lineLen % 1024);
- *buffer = (char*)mir_realloc(*buffer, *cbBufferAlloced);
+ if (cbBufferEnd + lineLen > cbBufferAlloced) {
+ cbBufferAlloced += lineLen + 1024 - lineLen % 1024;
+ buffer = (char*)mir_realloc(buffer, cbBufferAlloced);
}
- char *d = *buffer + *cbBufferEnd;
+ char *d = buffer + cbBufferEnd;
if (isAnsii) {
strcpy(d, "{");
d++;
@@ -312,16 +312,16 @@ static int AppendUnicodeOrAnsiiToBufferL(char **buffer, int *cbBufferEnd, int *c strcpy(d, "}");
d++;
- *cbBufferEnd = (int)(d - *buffer);
+ cbBufferEnd = (int)(d - buffer);
return textCharsCount;
}
-static int AppendAnsiToBuffer(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, const char *line)
+static int AppendAnsiToBuffer(char *&buffer, size_t &cbBufferEnd, size_t &cbBufferAlloced, const char *line)
{
return AppendUnicodeOrAnsiiToBufferL(buffer, cbBufferEnd, cbBufferAlloced, _A2T(line), -1, TRUE);
}
-static int AppendUnicodeToBuffer(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, const WCHAR *line)
+static int AppendUnicodeToBuffer(char *&buffer, size_t &cbBufferEnd, size_t &cbBufferAlloced, const WCHAR *line)
{
return AppendUnicodeOrAnsiiToBufferL(buffer, cbBufferEnd, cbBufferAlloced, line, -1, FALSE);
}
@@ -333,47 +333,46 @@ static char *CreateRTFHeader(SrmmWindowData *dat, struct GlobalMessageData *gdat logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
ReleaseDC(NULL, hdc);
- int bufferEnd = 0;
- int bufferAlloced = 1024;
+ size_t bufferEnd = 0, bufferAlloced = 1024;
char *buffer = (char*)mir_alloc(bufferAlloced);
buffer[0] = '\0';
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced,"{\\rtf1\\ansi\\deff0{\\fonttbl");
+
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced,"{\\rtf1\\ansi\\deff0{\\fonttbl");
for (int i = 0; i < fontOptionsListSize; i++) {
LOGFONT lf;
LoadMsgDlgFont(i, &lf, NULL);
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "{\\f%u\\fnil\\fcharset%u %S;}", i, lf.lfCharSet, lf.lfFaceName);
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "{\\f%u\\fnil\\fcharset%u %S;}", i, lf.lfCharSet, lf.lfFaceName);
}
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "}{\\colortbl ");
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "}{\\colortbl ");
COLORREF colour;
for (int i = 0; i < fontOptionsListSize; i++) {
LoadMsgDlgFont(i, NULL, &colour);
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(colour), GetGValue(colour), GetBValue(colour));
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(colour), GetGValue(colour), GetBValue(colour));
}
if (GetSysColorBrush(COLOR_HOTLIGHT) == NULL)
colour = RGB(0, 0, 255);
else
colour = GetSysColor(COLOR_HOTLIGHT);
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(colour), GetGValue(colour), GetBValue(colour));
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(colour), GetGValue(colour), GetBValue(colour));
colour = db_get_dw(NULL, SRMMMOD, SRMSGSET_BKGCOLOUR, SRMSGDEFSET_BKGCOLOUR);
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(colour), GetGValue(colour), GetBValue(colour));
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(colour), GetGValue(colour), GetBValue(colour));
colour = db_get_dw(NULL, SRMMMOD, SRMSGSET_INCOMINGBKGCOLOUR, SRMSGDEFSET_INCOMINGBKGCOLOUR);
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(colour), GetGValue(colour), GetBValue(colour));
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(colour), GetGValue(colour), GetBValue(colour));
colour = db_get_dw(NULL, SRMMMOD, SRMSGSET_OUTGOINGBKGCOLOUR, SRMSGDEFSET_OUTGOINGBKGCOLOUR);
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(colour), GetGValue(colour), GetBValue(colour));
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(colour), GetGValue(colour), GetBValue(colour));
colour = db_get_dw(NULL, SRMMMOD, SRMSGSET_LINECOLOUR, SRMSGDEFSET_LINECOLOUR);
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(colour), GetGValue(colour), GetBValue(colour));
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "}");
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(colour), GetGValue(colour), GetBValue(colour));
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "}");
return buffer;
}
// mir_free() the return value
static char* CreateRTFTail()
{
- int bufferAlloced = 1024, bufferEnd = 0;
- char *buffer = (char*)mir_alloc(bufferAlloced);
- buffer[0] = '\0';
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "}");
+ size_t bufferAlloced = 1024, bufferEnd = 0;
+ char *buffer = (char*)mir_alloc(bufferAlloced); buffer[0] = '\0';
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "}");
return buffer;
}
@@ -489,7 +488,7 @@ static int DetectURL(wchar_t *text, BOOL firstChar) { return 0;
}
-static void AppendWithCustomLinks(EventData *evt, int style, char **buffer, int *bufferEnd, int *bufferAlloced)
+static void AppendWithCustomLinks(EventData *evt, int style, char *&buffer, size_t &bufferEnd, size_t &bufferAlloced)
{
if (evt->pszText == NULL)
return;
@@ -544,8 +543,8 @@ static char* CreateRTFFromEvent(SrmmWindowData *dat, EventData *evt, struct Glob int style, showColon = 0;
int isGroupBreak = TRUE;
int highlight = 0;
- int bufferEnd = 0;
- int bufferAlloced = 1024;
+
+ size_t bufferEnd = 0, bufferAlloced = 1024;
char *buffer = (char*)mir_alloc(bufferAlloced); buffer[0] = '\0';
if ((gdat->flags & SMF_GROUPMESSAGES) && evt->dwFlags == LOWORD(dat->lastEventType) &&
@@ -557,47 +556,47 @@ static char* CreateRTFFromEvent(SrmmWindowData *dat, EventData *evt, struct Glob if (!streamData->isFirst && !dat->isMixed) {
if (isGroupBreak || gdat->flags & SMF_MARKFOLLOWUPS)
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\par");
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\par");
else
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\line");
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\line");
}
if (evt->dwFlags & IEEDF_RTL)
dat->isMixed = 1;
if (!streamData->isFirst && isGroupBreak && (gdat->flags & SMF_DRAWLINES))
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\sl-1\\slmult0\\highlight%d\\cf%d\\fs1 \\par\\sl0", fontOptionsListSize + 4, fontOptionsListSize + 4);
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\sl-1\\slmult0\\highlight%d\\cf%d\\fs1 \\par\\sl0", fontOptionsListSize + 4, fontOptionsListSize + 4);
if (streamData->isFirst) {
if (evt->dwFlags & IEEDF_RTL)
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\rtlpar");
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\rtlpar");
else
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\ltrpar");
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\ltrpar");
}
else {
if (evt->dwFlags & IEEDF_RTL)
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\rtlpar");
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\rtlpar");
else
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\ltrpar");
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\ltrpar");
}
if (evt->eventType == EVENTTYPE_MESSAGE)
highlight = fontOptionsListSize + 2 + ((evt->dwFlags & IEEDF_SENT) ? 1 : 0);
else
highlight = fontOptionsListSize + 1;
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\highlight%d\\cf%d", highlight, highlight);
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\highlight%d\\cf%d", highlight, highlight);
if (!streamData->isFirst && dat->isMixed) {
if (isGroupBreak)
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\sl-1 \\par\\sl0");
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\sl-1 \\par\\sl0");
else
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\sl-1 \\line\\sl0");
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\sl-1 \\line\\sl0");
}
streamData->isFirst = FALSE;
if (dat->isMixed) {
if (evt->dwFlags & IEEDF_RTL)
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\ltrch\\rtlch");
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\ltrch\\rtlch");
else
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\rtlch\\ltrch");
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\rtlch\\ltrch");
}
if ((gdat->flags & SMF_SHOWICONS) && isGroupBreak) {
int i = LOGICON_MSG_NOTICE;
@@ -615,13 +614,13 @@ static char* CreateRTFFromEvent(SrmmWindowData *dat, EventData *evt, struct Glob break;
}
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\fs1 ");
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\fs1 ");
while (bufferAlloced - bufferEnd < logIconBmpSize[i])
bufferAlloced += 1024;
buffer = (char*)mir_realloc(buffer, bufferAlloced);
CopyMemory(buffer + bufferEnd, pLogIconBmpBits[i], logIconBmpSize[i]);
bufferEnd += logIconBmpSize[i];
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, " ");
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, " ");
}
if (gdat->flags & SMF_SHOWTIME && (evt->eventType != EVENTTYPE_MESSAGE ||
@@ -640,47 +639,47 @@ static char* CreateRTFFromEvent(SrmmWindowData *dat, EventData *evt, struct Glob else timestampString = TimestampToString(gdat->flags, evt->time, 0);
if (timestampString != NULL) {
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s ", SetToStyle(evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYTIME : MSGFONTID_YOURTIME));
- AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, timestampString);
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "%s ", SetToStyle(evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYTIME : MSGFONTID_YOURTIME));
+ AppendUnicodeToBuffer(buffer, bufferEnd, bufferAlloced, timestampString);
}
if (evt->eventType != EVENTTYPE_MESSAGE)
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s: ", SetToStyle(evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYCOLON : MSGFONTID_YOURCOLON));
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "%s: ", SetToStyle(evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYCOLON : MSGFONTID_YOURCOLON));
showColon = 1;
}
if ((!(gdat->flags & SMF_HIDENAMES) && evt->eventType == EVENTTYPE_MESSAGE && isGroupBreak) || evt->eventType == EVENTTYPE_JABBER_CHATSTATES || evt->eventType == EVENTTYPE_JABBER_PRESENCE) {
if (evt->eventType == EVENTTYPE_MESSAGE) {
if (showColon)
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, " %s ", SetToStyle(evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYNAME : MSGFONTID_YOURNAME));
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, " %s ", SetToStyle(evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYNAME : MSGFONTID_YOURNAME));
else
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s ", SetToStyle(evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYNAME : MSGFONTID_YOURNAME));
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "%s ", SetToStyle(evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYNAME : MSGFONTID_YOURNAME));
}
- else AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s ", SetToStyle(MSGFONTID_NOTICE));
+ else AppendToBuffer(buffer, bufferEnd, bufferAlloced, "%s ", SetToStyle(MSGFONTID_NOTICE));
if (evt->dwFlags & IEEDF_UNICODE_NICK)
- AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, evt->pszNickW);
+ AppendUnicodeToBuffer(buffer, bufferEnd, bufferAlloced, evt->pszNickW);
else
- AppendAnsiToBuffer(&buffer, &bufferEnd, &bufferAlloced, evt->pszNick);
+ AppendAnsiToBuffer(buffer, bufferEnd, bufferAlloced, evt->pszNick);
showColon = 1;
if (evt->eventType == EVENTTYPE_MESSAGE && gdat->flags & SMF_GROUPMESSAGES) {
if (gdat->flags & SMF_MARKFOLLOWUPS)
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\par");
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\par");
else
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\line");
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\line");
showColon = 0;
}
}
if ((gdat->flags & SMF_AFTERMASK) == SMF_AFTERMASK && evt->eventType == EVENTTYPE_MESSAGE && isGroupBreak) {
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, " %s ", SetToStyle(evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYTIME : MSGFONTID_YOURTIME));
- AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, TimestampToString(gdat->flags, evt->time, 2));
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, " %s ", SetToStyle(evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYTIME : MSGFONTID_YOURTIME));
+ AppendUnicodeToBuffer(buffer, bufferEnd, bufferAlloced, TimestampToString(gdat->flags, evt->time, 2));
showColon = 1;
}
if (showColon && evt->eventType == EVENTTYPE_MESSAGE) {
if (evt->dwFlags & IEEDF_RTL)
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\~%s: ", SetToStyle(evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYCOLON : MSGFONTID_YOURCOLON));
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\~%s: ", SetToStyle(evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYCOLON : MSGFONTID_YOURCOLON));
else
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s: ", SetToStyle(evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYCOLON : MSGFONTID_YOURCOLON));
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "%s: ", SetToStyle(evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYCOLON : MSGFONTID_YOURCOLON));
}
switch (evt->eventType) {
case EVENTTYPE_JABBER_CHATSTATES:
@@ -688,49 +687,49 @@ static char* CreateRTFFromEvent(SrmmWindowData *dat, EventData *evt, struct Glob case EVENTTYPE_URL:
case EVENTTYPE_FILE:
style = MSGFONTID_NOTICE;
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s ", SetToStyle(style));
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "%s ", SetToStyle(style));
if (evt->eventType == EVENTTYPE_FILE) {
if (evt->dwFlags & IEEDF_SENT)
- AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, TranslateT("File sent"));
+ AppendUnicodeToBuffer(buffer, bufferEnd, bufferAlloced, TranslateT("File sent"));
else
- AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, TranslateT("File received"));
- AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, _T(":"));
+ AppendUnicodeToBuffer(buffer, bufferEnd, bufferAlloced, TranslateT("File received"));
+ AppendUnicodeToBuffer(buffer, bufferEnd, bufferAlloced, _T(":"));
}
else if (evt->eventType == EVENTTYPE_URL) {
if (evt->dwFlags & IEEDF_SENT)
- AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, TranslateT("URL sent"));
+ AppendUnicodeToBuffer(buffer, bufferEnd, bufferAlloced, TranslateT("URL sent"));
else
- AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, TranslateT("URL received"));
- AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, _T(":"));
+ AppendUnicodeToBuffer(buffer, bufferEnd, bufferAlloced, TranslateT("URL received"));
+ AppendUnicodeToBuffer(buffer, bufferEnd, bufferAlloced, _T(":"));
}
- AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, _T(" "));
+ AppendUnicodeToBuffer(buffer, bufferEnd, bufferAlloced, _T(" "));
if (evt->pszTextW != NULL) {
if (evt->dwFlags & IEEDF_UNICODE_TEXT)
- AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, evt->pszTextW);
+ AppendUnicodeToBuffer(buffer, bufferEnd, bufferAlloced, evt->pszTextW);
else
- AppendAnsiToBuffer(&buffer, &bufferEnd, &bufferAlloced, evt->pszText);
+ AppendAnsiToBuffer(buffer, bufferEnd, bufferAlloced, evt->pszText);
}
if (evt->pszText2W != NULL) {
- AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, _T(" ("));
+ AppendUnicodeToBuffer(buffer, bufferEnd, bufferAlloced, _T(" ("));
if (evt->dwFlags & IEEDF_UNICODE_TEXT2)
- AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, evt->pszText2W);
+ AppendUnicodeToBuffer(buffer, bufferEnd, bufferAlloced, evt->pszText2W);
else
- AppendAnsiToBuffer(&buffer, &bufferEnd, &bufferAlloced, evt->pszText2);
- AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, _T(")"));
+ AppendAnsiToBuffer(buffer, bufferEnd, bufferAlloced, evt->pszText2);
+ AppendUnicodeToBuffer(buffer, bufferEnd, bufferAlloced, _T(")"));
}
break;
default:
if (gdat->flags & SMF_MSGONNEWLINE && showColon)
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\line");
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\line");
style = evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYMSG : MSGFONTID_YOURMSG;
- AppendWithCustomLinks(evt, style, &buffer, &bufferEnd, &bufferAlloced);
+ AppendWithCustomLinks(evt, style, buffer, bufferEnd, bufferAlloced);
break;
}
if (dat->isMixed)
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\par");
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\par");
dat->lastEventTime = evt->time;
dat->lastEventType = MAKELONG(evt->dwFlags, evt->eventType);
diff --git a/plugins/Scriver/src/msgwindow.cpp b/plugins/Scriver/src/msgwindow.cpp index 1504e4a8e5..bec26597d2 100644 --- a/plugins/Scriver/src/msgwindow.cpp +++ b/plugins/Scriver/src/msgwindow.cpp @@ -39,14 +39,11 @@ static const TCHAR *titleTokenNames[] = {_T("%name%"), _T("%status%"), _T("%stat TCHAR* GetWindowTitle(MCONTACT hContact, const char *szProto)
{
- int isTemplate;
- int i, j;
TCHAR* tokens[4] = { 0 };
size_t tokenLen[4] = { 0 };
TCHAR *p, *tmplt, *title;
- char *accModule;
TCHAR *pszNewTitleEnd = mir_tstrdup(TranslateT("Message Session"));
- isTemplate = 0;
+ int isTemplate = 0;
if (hContact && szProto) {
tokens[0] = GetNickname(hContact, szProto);
tokenLen[0] = mir_tstrlen(tokens[0]);
@@ -55,7 +52,8 @@ TCHAR* GetWindowTitle(MCONTACT hContact, const char *szProto) tokens[2] = db_get_tsa(hContact, "CList", "StatusMsg");
if (tokens[2] != NULL) {
tokenLen[2] = mir_tstrlen(tokens[2]);
- for (i = j = 0; i < tokenLen[2]; i++) {
+ size_t j = 0;
+ for (size_t i = 0; i < tokenLen[2]; i++) {
if (tokens[2][i] == '\r')
continue;
if (tokens[2][i] == '\n')
@@ -67,7 +65,7 @@ TCHAR* GetWindowTitle(MCONTACT hContact, const char *szProto) tokenLen[2] = j;
}
- accModule = (char*)CallService(MS_PROTO_GETCONTACTBASEACCOUNT, hContact, 0);
+ char *accModule = (char*)CallService(MS_PROTO_GETCONTACTBASEACCOUNT, hContact, 0);
if (accModule != NULL) {
PROTOACCOUNT* proto = (PROTOACCOUNT*)CallService(MS_PROTO_GETACCOUNT, 0, (LPARAM)accModule);
if (proto != NULL) {
@@ -87,7 +85,7 @@ TCHAR* GetWindowTitle(MCONTACT hContact, const char *szProto) }
else tmplt = _T("");
- size_t len;
+ size_t i, len;
for (len = 0, p = tmplt; *p; p++, len++) {
if (*p == '%') {
for (i = 0; i < SIZEOF(titleTokenNames); i++) {
@@ -117,7 +115,8 @@ TCHAR* GetWindowTitle(MCONTACT hContact, const char *szProto) break;
}
}
- if (i < SIZEOF(titleTokenNames)) continue;
+ if (i < SIZEOF(titleTokenNames))
+ continue;
}
title[len++] = *p;
}
diff --git a/plugins/Scriver/src/utils.cpp b/plugins/Scriver/src/utils.cpp index c3b663bd3f..1f6b99e682 100644 --- a/plugins/Scriver/src/utils.cpp +++ b/plugins/Scriver/src/utils.cpp @@ -269,21 +269,21 @@ TCHAR *GetRichEditSelection(HWND hwnd) return NULL;
}
-void AppendToBuffer(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, const char *fmt, ...)
+void AppendToBuffer(char *&buffer, size_t &cbBufferEnd, size_t &cbBufferAlloced, const char *fmt, ...)
{
va_list va;
int charsDone;
va_start(va, fmt);
for (;;) {
- charsDone = mir_vsnprintf(*buffer + *cbBufferEnd, *cbBufferAlloced - *cbBufferEnd, fmt, va);
+ charsDone = mir_vsnprintf(buffer + cbBufferEnd, cbBufferAlloced - cbBufferEnd, fmt, va);
if (charsDone >= 0)
break;
- *cbBufferAlloced += 1024;
- *buffer = (char*)mir_realloc(*buffer, *cbBufferAlloced);
+ cbBufferAlloced += 1024;
+ buffer = (char*)mir_realloc(buffer, cbBufferAlloced);
}
va_end(va);
- *cbBufferEnd += charsDone;
+ cbBufferEnd += charsDone;
}
diff --git a/plugins/Scriver/src/utils.h b/plugins/Scriver/src/utils.h index 5f9f4afee8..bcb81d4a49 100644 --- a/plugins/Scriver/src/utils.h +++ b/plugins/Scriver/src/utils.h @@ -48,7 +48,7 @@ int SetRichTextEncoded(HWND hwnd, const char *text, int codepage); void SearchWord(TCHAR * word, int engine);
HDWP ResizeToolbar(HWND hwnd, HDWP hdwp, int width, int vPos, int height, int cControls, const ToolbarButton * buttons, int controlVisibility);
void ShowToolbarControls(HWND hwndDlg, int cControls, const ToolbarButton * buttons, int controlVisibility, int state);
-void AppendToBuffer(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, const char *fmt, ...);
+void AppendToBuffer(char *&buffer, size_t &cbBufferEnd, size_t &cbBufferAlloced, const char *fmt, ...);
int MeasureMenuItem(WPARAM wParam, LPARAM lParam);
int DrawMenuItem(WPARAM wParam, LPARAM lParam);
void SetSearchEngineIcons(HMENU hMenu, HIMAGELIST hImageList);
|