From d3fc13db1e7588df70dea2bd891f140d71b93051 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 2 Dec 2014 17:27:12 +0000 Subject: minus one unneeded mir_tstrlen git-svn-id: http://svn.miranda-ng.org/main/trunk@11219 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Scriver/src/msglog.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'plugins/Scriver/src') diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp index d67f117092..0ca661d1f2 100644 --- a/plugins/Scriver/src/msglog.cpp +++ b/plugins/Scriver/src/msglog.cpp @@ -253,12 +253,13 @@ static void freeEvent(EventData *evt) static int AppendUnicodeOrAnsiiToBufferL(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, const WCHAR *line, size_t maxLen, BOOL isAnsii) { - int textCharsCount = 0; - int wasEOL = 0; + if (maxLen == -1) + maxLen = wcslen(line); + const WCHAR *maxLine = line + maxLen; - int lineLen = (int)wcslen(line) * 9 + 8; + size_t lineLen = maxLen*9 + 8; if (*cbBufferEnd + lineLen > *cbBufferAlloced) { - cbBufferAlloced[0] += (lineLen + 1024 - lineLen % 1024); + cbBufferAlloced[0] += int(lineLen + 1024 - lineLen % 1024); *buffer = (char*)mir_realloc(*buffer, *cbBufferAlloced); } @@ -272,7 +273,8 @@ static int AppendUnicodeOrAnsiiToBufferL(char **buffer, int *cbBufferEnd, int *c d += 6; } - for (; *line && (maxLen == -1 || line < maxLine); line++, textCharsCount++) { + int wasEOL = 0, textCharsCount = 0; + for (; line < maxLine; line++, textCharsCount++) { wasEOL = 0; if (*line == '\r' && line[1] == '\n') { CopyMemory(d, "\\line ", 6); @@ -316,13 +318,12 @@ static int AppendUnicodeOrAnsiiToBufferL(char **buffer, int *cbBufferEnd, int *c static int AppendAnsiToBuffer(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, const char *line) { - ptrT tszLine(mir_a2t(line)); - return AppendUnicodeOrAnsiiToBufferL(buffer, cbBufferEnd, cbBufferAlloced, tszLine, mir_tstrlen(tszLine), TRUE); + return AppendUnicodeOrAnsiiToBufferL(buffer, cbBufferEnd, cbBufferAlloced, _A2T(line), -1, TRUE); } static int AppendUnicodeToBuffer(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, const WCHAR *line) { - return AppendUnicodeOrAnsiiToBufferL(buffer, cbBufferEnd, cbBufferAlloced, line, mir_wstrlen(line), FALSE); + return AppendUnicodeOrAnsiiToBufferL(buffer, cbBufferEnd, cbBufferAlloced, line, -1, FALSE); } // mir_free() the return value -- cgit v1.2.3