delete[] m_pcLine;
m_pcLine = new TCHAR[m_nMax];
ZeroMemory(m_pcLine, m_nMax * sizeof(TCHAR));
- size_t dwLen = sizeof (TCHAR) * m_nLength;
+ const size_t dwLen = sizeof (TCHAR) * m_nLength;
CopyMemory (m_pcLine, pszLine, dwLen);
m_pcLine[m_nLength] = '\0';
pCmdUI->Enable (IsSelection ());
}
-long str_pos (LPCTSTR whole, LPCTSTR piece);
+size_t str_pos (LPCTSTR whole, LPCTSTR piece);
void CCrystalEditView::
OnToolsCharCoding ()
size_t nPos = ::FindStringHelper(p, marker.second.sFindWhat, marker.second.dwFlags | FIND_NO_WRAP, nMatchLen, node, &matches);
if (nPos == -1)
break;
+ ASSERT(((p - pszChars) + nPos) < INT_MAX);
blocks[nBlocks].m_nCharPos = static_cast<int>((p - pszChars) + nPos);
blocks[nBlocks].m_nBgColorIndex = marker.second.nBgColorIndex | COLORINDEX_APPLYFORCE;
blocks[nBlocks].m_nColorIndex = COLORINDEX_NONE;
++nBlocks;
+ ASSERT(((p - pszChars) + nPos + nMatchLen) < INT_MAX);
blocks[nBlocks].m_nCharPos = static_cast<int>((p - pszChars) + nPos + nMatchLen);
blocks[nBlocks].m_nBgColorIndex = COLORINDEX_NONE;
blocks[nBlocks].m_nColorIndex = COLORINDEX_NONE;
if (rxnode && RxExec (rxnode, pszFindWhere, _tcslen (pszFindWhere), pszFindWhere, rxmatch))
{
pos = rxmatch->Open[0];
+ ASSERT((rxmatch->Close[0] - rxmatch->Open[0]) < INT_MAX);
nLen = static_cast<int>(rxmatch->Close[0] - rxmatch->Open[0]);
}
else
*s = _T ('\0');
}
-long
+size_t
str_pos (LPCTSTR whole, LPCTSTR piece)
{
LPCTSTR s = whole;
while (*s)
if (!_tcsnicmp (s++, piece, l))
- return static_cast<long>(s - whole - 1);
+ return (s - whole - 1);
return -2;
}
size_t
get_coding (LPCTSTR name, type_codes *codes, int *coding)
{
- long i, pos;
+ size_t pos;
- for (i = 0; i < codes_count; i++)
+ for (int i = 0; i < codes_count; i++)
if ((pos = str_pos (name, codes[i].name)) >= 0)
{
*coding = i;
int
iconvert (LPTSTR string, int source_coding, int destination_coding, bool alphabet_only)
{
- size_t posit = -2, i, j;
+ size_t posit = -2;
LPCTSTR source_chars, destination_chars, cod_pos = NULL;
TCHAR ch;
LPTSTR s = string;
if (destination_coding < 0)
return -2;
- const size_t chars_count = alphabet_only ? chars_alphabet_count : chars_all_count;
+ int chars_count = alphabet_only ? chars_alphabet_count : chars_all_count;
source_chars = source_codes[source_coding].codes;
destination_chars = destination_codes[destination_coding].codes;
for (;;)
if (cod_pos == s)
{
+ size_t i, j;
i = _tcslen (source_codes[source_coding].name);
j = _tcslen (destination_codes[destination_coding].name);
if (i != j)
ch = *s;
if (!ch)
break;
- i = chars_count;
+ int i = chars_count;
if ((unsigned) ch > 127)
for (i = 0; i < chars_count; i++)
if (ch == source_chars[i])
_address(0)
{
LARGE_INTEGER mySize;
- mySize.QuadPart = size;
+ mySize.QuadPart = _size;
if (mode == SharedMemory::AM_WRITE)
_mode = PAGE_READWRITE;
TCHAR ext[_MAX_EXT] = {0};
TCHAR dir[_MAX_DIR] = {0};
TCHAR drive[_MAX_DRIVE] = {0};
- _tsplitpath_s(s.c_str(), drive, sizeof(drive), dir, sizeof(dir), file, sizeof(file), ext, sizeof(ext));
+ _tsplitpath_s(s.c_str(), drive, _MAX_DRIVE, dir, _MAX_DIR, file, _MAX_FNAME, ext, _MAX_EXT);
if (_tcslen(ext) == 0)
{
s += FileFilterExt;
#include "diff.h"
+#include <cassert>
struct group
{
return 0;
value = 8 * value + digit;
}
+ assert((p - lit - 2) < INT_MAX);
digits = (int)(p - lit - 2);
if (! (1 <= digits && digits <= 3))
return 0;
current->buffer = xrealloc (current->buffer, current->bufsize);
#endif /*__MSDOS__*/
}
+ assert((current->bufsize - current->buffered_chars) < UINT_MAX);
cc = read (current->desc,
current->buffer + current->buffered_chars,
(unsigned int)(current->bufsize - current->buffered_chars));
for (prefix_count = 1; prefix_count < context + 1; prefix_count *= 2)
;
prefix_mask = prefix_count - 1;
+ assert((p0 - (char HUGE *)filevec[0].prefix_end) < INT_MAX);
ttt = (int)(p0 - (char HUGE *)filevec[0].prefix_end);
alloc_lines0
= prefix_count
/* Allocate line buffer 1. */
tem = prefix_count ? filevec[1].suffix_begin - buffer1 : n1;
+ assert((filevec[1].prefix_end - buffer1) < INT_MAX);
ttt = (int)(filevec[1].prefix_end - buffer1);
alloc_lines1
= (buffered_prefix
filevec[0].linbuf = linbuf0 + buffered_prefix;
filevec[1].linbuf = linbuf1 + buffered_prefix;
filevec[0].linbuf_base = filevec[1].linbuf_base = - buffered_prefix;
+ assert((alloc_lines0 - buffered_prefix) < INT_MAX);
+ assert((alloc_lines1 - buffered_prefix) < INT_MAX);
filevec[0].alloc_lines = (int)(alloc_lines0 - buffered_prefix);
filevec[1].alloc_lines = (int)(alloc_lines1 - buffered_prefix);
filevec[0].prefix_lines = filevec[1].prefix_lines = lines;
char *p, *q = &ret[0];
while (*(p = q))
{
- char *value = 0;
+ char *value = nullptr;
switch (*p)
{
case '&': value = "&"; break;
case '>' : value = ">"; break;
}
++q;
- if (value)
+ if (value != nullptr)
{
- size_t i = p - &ret[0];
- size_t j = q - &ret[0];
size_t cchValue = strlen(value);
if (cchValue > 1)
{
+ ptrdiff_t i = p - &ret[0];
+ ptrdiff_t j = q - &ret[0];
size_t b = v.length();
ret.resize(b + cchValue - 1);
p = &ret[0] + i;