BOOL bDecIndex = FALSE;
BOOL bOneWord = TRUE;
int nIdentBegin = -1;
- for (int I = 0;; I++)
+ int nPrevI = -1;
+ for (int I = 0;; nPrevI = I, I = ::CharNext(pszChars+I) - pszChars)
{
if (bRedefineBlock)
{
int nPos = I;
if (bDecIndex)
- nPos--;
+ nPos = nPrevI;
if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
{
DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
// String constant "...."
if (dwCookie & COOKIE_STRING)
{
- if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_STRING;
bRedefineBlock = TRUE;
// Char constant '..'
if (dwCookie & COOKIE_CHAR)
{
- if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_CHAR;
bRedefineBlock = TRUE;
if (pszChars[I] == '\'')
{
// if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
- if (!I || !xisalnum (pszChars[I - 1]))
+ if (!I || !xisalnum (pszChars[nPrevI]))
{
DEFINE_BLOCK (I, COLORINDEX_STRING);
dwCookie |= COOKIE_CHAR;
}
if (dwCookie & COOKIE_EXT_COMMENT)
continue;
- if (nLength >= I + 3 && !_tcsnicmp (pszChars + I, _T ("REM"), 3) && (_istspace (pszChars[I + 3]) || nLength == I + 3))
+ if (nLength >= I + 3 && !_tcsnicmp (pszChars + I, _T ("REM"), 3) && (xisspace (pszChars[I + 3]) || nLength == I + 3))
{
DEFINE_BLOCK (I, COLORINDEX_COMMENT);
dwCookie |= COOKIE_COMMENT;
if (pszChars[I] == ':')
{
- if (nLength > I + 2 && !(xisalnum (pszChars[I+1]) || isspace (pszChars[I+1])))
+ if (nLength > I + 2 && !(xisalnum (pszChars[I+1]) || xisspace (pszChars[I+1])))
{
DEFINE_BLOCK (I, COLORINDEX_COMMENT);
dwCookie |= COOKIE_COMMENT;
dwCookie |= COOKIE_PREPROCESSOR;
continue;
}
- if (!_istspace (pszChars[I]))
+ if (!xisspace (pszChars[I]))
bFirstChar = FALSE;
}
else // If Caret Not At SOL
{
- ptCursorPos.x--; // Decrement Position
+ if (ptCursorPos.x > 1 && m_pTextBuffer->IsMBSTrail (ptCursorPos.y, ptCursorPos.x-1)) ptCursorPos.x--; /* MULTIBYTES */
+ ptCursorPos.x--; // Decrement Position
//yuyunyi
if (ptCursorPos.x > 0 && m_pTextBuffer->IsMBSTrail (ptCursorPos.y, ptCursorPos.x))
int nLength = m_pTextBuffer->GetLineLength (ptCursorPos.y - 1);
LPCTSTR pszLineChars = m_pTextBuffer->GetLineChars (ptCursorPos.y - 1);
int nPos = 0;
- while (nPos < nLength && _istspace (pszLineChars[nPos]))
+ while (nPos < nLength && xisspace (pszLineChars[nPos]))
nPos++;
if (nPos > 0)
int nLength = m_pTextBuffer->GetLineLength (ptCursorPos.y);
LPCTSTR pszLineChars = m_pTextBuffer->GetLineChars (ptCursorPos.y );
int nPos = 0;
- while (nPos < nLength && _istspace (pszLineChars[nPos]))
+ while (nPos < nLength && xisspace (pszLineChars[nPos]))
nPos++;
if (nPos == nLength - 1)
{
int nLength = m_pTextBuffer->GetLineLength (ptCursorPos.y);
LPCTSTR pszLineChars = m_pTextBuffer->GetLineChars (ptCursorPos.y );
int nPos = 0;
- while (nPos < nLength && _istspace (pszLineChars[nPos]))
+ while (nPos < nLength && xisspace (pszLineChars[nPos]))
nPos++;
if (ptCursorPos.y > 0 && nPos && nPos == nLength - 1)
{
bool bCapitalize = true;
while (*pszText)
{
- if (_istspace (*pszText))
+ if (xisspace (*pszText))
bCapitalize = true;
else if (_istalpha (*pszText))
if (bCapitalize)
bool bCapitalize = true;
while (*pszText)
{
- if (!_istspace (*pszText))
+ if (!xisspace (*pszText))
if (*pszText == _T ('.'))
{
if (pszText[1] && !_istdigit (pszText[1]))
LPCTSTR pszChars = GetLineChars (m_ptCursorPos.y);
int nPos = m_ptCursorPos.x;
- while (nPos > 0 && _istspace (pszChars[nPos - 1]))
- nPos--;
+ int nPrevPos;
+ while (nPos > 0 && xisspace (pszChars[nPrevPos = ::CharPrev(pszChars, pszChars + nPos) - pszChars]))
+ nPos = nPrevPos;
if (nPos > 0)
{
- nPos--;
+ int nPrevPos = ::CharPrev(pszChars, pszChars + nPos) - pszChars;
+ nPos = nPrevPos;
if (xisalnum (pszChars[nPos]))
{
- while (nPos > 0 && xisalnum (pszChars[nPos - 1]))
- nPos--;
+ while (nPos > 0 && (xisalnum (pszChars[nPrevPos = ::CharPrev(pszChars, pszChars + nPos) - pszChars])))
+ nPos = nPrevPos;
}
else
{
- while (nPos > 0 && !xisalnum (pszChars[nPos - 1])
- && !_istspace (pszChars[nPos - 1]))
- nPos--;
+ while (nPos > 0 && !xisalnum (pszChars[nPrevPos = ::CharPrev(pszChars, pszChars + nPos) - pszChars])
+ && !xisspace (pszChars[nPrevPos]))
+ nPos = nPrevPos;
}
}
if (xisalnum (pszChars[nPos]))
{
while (nPos < nLength && xisalnum (pszChars[nPos]))
- nPos++;
+ nPos = ::CharNext(pszChars + nPos) - pszChars;
}
else
{
while (nPos < nLength && !xisalnum (pszChars[nPos])
- && !_istspace (pszChars[nPos]))
- nPos++;
+ && !xisspace (pszChars[nPos]))
+ nPos = ::CharNext(pszChars + nPos) - pszChars;
}
- while (nPos < nLength && _istspace (pszChars[nPos]))
- nPos++;
+ while (nPos < nLength && xisspace (pszChars[nPos]))
+ nPos = ::CharNext(pszChars + nPos) - pszChars;
m_ptCursorPos.x = nPos;
m_nIdealCharPos = CalculateActualOffset (m_ptCursorPos.y, m_ptCursorPos.x);
/*ORIGINAL
int nHomePos = 0;
*///END SW
- while (nHomePos < nLength && _istspace (pszChars[nHomePos]))
+ while (nHomePos < nLength && xisspace (pszChars[nHomePos]))
nHomePos++;
if (nHomePos == nLength || m_ptCursorPos.x == nHomePos)
//BEGIN SW
{
if (!xisalnum (pszChars[pt.x]))
break;
- pt.x++;
+ pt.x += ::CharNext (&pszChars[pt.x]) - &pszChars[pt.x];
}
ASSERT_VALIDTEXTPOS (pt);
return pt;
{
ASSERT_VALIDTEXTPOS (pt);
LPCTSTR pszChars = GetLineChars (pt.y);
+ int nPrevX = pt.x;
while (pt.x > 0)
{
- if (!xisalnum (pszChars[pt.x - 1]))
+ nPrevX -= &pszChars[pt.x] - ::CharPrev (pszChars, &pszChars[pt.x]);
+ if (!xisalnum (pszChars[nPrevX]))
break;
- pt.x--;
+ pt.x = nPrevX;
}
ASSERT_VALIDTEXTPOS (pt);
return pt;
#include "stdafx.h"
#include "ccrystaltextview.h"
+#include "ccrystaltextbuffer.h"
#ifdef _DEBUG
#define new DEBUG_NEW
BOOL bWasCommentStart = FALSE;
BOOL bDecIndex = FALSE;
int nIdentBegin = -1;
- for (int I = 0;; I++)
+ int nPrevI = -1;
+ for (int I = 0;; nPrevI = I, I = CharNext(pszChars+I) - pszChars)
{
if (bRedefineBlock)
{
int nPos = I;
if (bDecIndex)
- nPos--;
+ nPos = nPrevI;
if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
{
DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
}
else
{
- if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (pszChars[nPos - 1]) && !xisalpha (pszChars[nPos + 1])))
+ if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (*::CharPrev(pszChars, pszChars + nPos)) && !xisalpha (*::CharNext(pszChars + nPos))))
{
DEFINE_BLOCK (nPos, COLORINDEX_NORMALTEXT);
}
// String constant "...."
if (dwCookie & COOKIE_STRING)
{
- if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_STRING;
bRedefineBlock = TRUE;
// Char constant '..'
if (dwCookie & COOKIE_CHAR)
{
- if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_CHAR;
bRedefineBlock = TRUE;
// Extended comment /*....*/
if (dwCookie & COOKIE_EXT_COMMENT)
{
- // if (I > 0 && pszChars[I] == '/' && pszChars[I - 1] == '*')
- if ((I > 1 && pszChars[I] == '/' && pszChars[I - 1] == '*' /*&& pszChars[I - 2] != '/'*/ && !bWasCommentStart) || (I == 1 && pszChars[I] == '/' && pszChars[I - 1] == '*'))
+ // if (I > 0 && pszChars[I] == '/' && pszChars[nPrevI] == '*')
+ if ((I > 1 && pszChars[I] == '/' && pszChars[nPrevI] == '*' /*&& *::CharPrev(pszChars, pszChars + nPrevI) != '/'*/ && !bWasCommentStart) || (I == 1 && pszChars[I] == '/' && pszChars[nPrevI] == '*'))
{
dwCookie &= ~COOKIE_EXT_COMMENT;
bRedefineBlock = TRUE;
continue;
}
- if (I > 0 && pszChars[I] == '/' && pszChars[I - 1] == '/')
+ if (I > 0 && pszChars[I] == '/' && pszChars[nPrevI] == '/')
{
- DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
+ DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_COMMENT;
break;
}
// Preprocessor directive #....
if (dwCookie & COOKIE_PREPROCESSOR)
{
- if (I > 0 && pszChars[I] == '*' && pszChars[I - 1] == '/')
+ if (I > 0 && pszChars[I] == '*' && pszChars[nPrevI] == '/')
{
- DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
+ DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_EXT_COMMENT;
}
continue;
if (pszChars[I] == '\'')
{
// if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
- if (!I || !xisalnum (pszChars[I - 1]))
+ if (!I || !xisalnum (pszChars[nPrevI]))
{
DEFINE_BLOCK (I, COLORINDEX_STRING);
dwCookie |= COOKIE_CHAR;
continue;
}
}
- if (I > 0 && pszChars[I] == '*' && pszChars[I - 1] == '/')
+ if (I > 0 && pszChars[I] == '*' && pszChars[nPrevI] == '/')
{
- DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
+ DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_EXT_COMMENT;
bWasCommentStart = TRUE;
continue;
dwCookie |= COOKIE_PREPROCESSOR;
continue;
}
- if (!_istspace (pszChars[I]))
+ if (!xisspace (pszChars[I]))
bFirstChar = FALSE;
}
continue; // We don't need to extract keywords,
// for faster parsing skip the rest of loop
- if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[I - 1]) && !xisalpha (pszChars[I + 1])))
+ if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[nPrevI]) && !xisalpha (pszChars[I + 1])))
{
if (nIdentBegin == -1)
nIdentBegin = I;
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
}
}
- if (pszChars[nLength - 1] != '\\')
+ if (pszChars[nLength - 1] != '\\' || m_pTextBuffer->IsMBSTrail(nLineIndex, nLength - 1))
dwCookie &= COOKIE_EXT_COMMENT;
return dwCookie;
}
//#define DEBUG
+#ifdef _UNICODE
+#define mytcsnextc(p) (*p)
+#else
+__inline unsigned int mytcsnextc(LPCSTR p) {
+ int ch = 0;
+ if (_ismbblead((unsigned char)*p))
+ ch = ((unsigned char)*p++<<8);
+ ch += (unsigned char)*p;
+ return ch;
+}
+#endif
+
static int RegCount = 0;
#ifdef DEBUG
return N;
}
-static RxNode *NewChar(TCHAR Ch) {
+static RxNode *NewChar(unsigned int Ch) {
RxNode *A = NewNode(RE_CHAR);
if (A) {
- A->fChar = (LPTSTR) malloc(1);
+#ifdef _UNICODE
+ A->fChar = (LPTSTR) malloc(2);
A->fLen = 1;
A->fChar[0] = Ch;
+#else
+ if (Ch > 0xff) {
+ A->fChar = (LPTSTR) malloc(2);
+ A->fLen = 2;
+ A->fChar[0] = (unsigned char)(Ch >> 8);
+ A->fChar[1] = (unsigned char)(Ch & 0xff);
+ } else {
+ A->fChar = (LPTSTR) malloc(1);
+ A->fLen = 1;
+ A->fChar[0] = (unsigned char)Ch;
+ }
+#endif
}
return A;
}
static RxNode *NewEscape(LPCTSTR *const Regexp) {
- TCHAR Ch = **Regexp;
- ++*Regexp;
+ unsigned int Ch = mytcsnextc(*Regexp);
+ *Regexp = _tcsinc(*Regexp);
switch (Ch) {
case 0: return 0;
case _T('a'): Ch = _T('\a'); break;
}
-#define NNN 32 // 8 * 32 = 256 (match set)
+#define NNN 8192 // 8 * 8192 = 65536 (match set)
#ifdef _UNICODE
#define SETOP(set,n) \
#else // _UNICODE
#define SETOP(set,n) \
do { \
- set[(unsigned char)(n) >> 3] |= (unsigned char)(1 << ((unsigned char)(n) & 7)); \
+ set[(unsigned int)(n) >> 3] |= (unsigned char)(1 << ((unsigned char)(n) & 7)); \
} while (0)
#endif // _UNICODE
#ifdef _UNICODE
TCHAR Ch, C1 = 0, C2 = 0;
#else // _UNICODE
- unsigned char Ch, C1 = 0, C2 = 0;
+ unsigned int Ch, C1 = 0, C2 = 0;
#endif // _UNICODE
int doset = 0;
c = 0;
while (**Regexp) {
- switch (Ch = *((*Regexp)++)) {
+ Ch = mytcsnextc(*Regexp);
+ *Regexp = _tcsinc(*Regexp);
+ switch (Ch) {
case _T(']'):
if (doset == 1) return 0;
{
return N;
}
case _T('\\'):
- switch (Ch = *((*Regexp)++)) {
+ Ch = mytcsnextc(*Regexp);
+ *Regexp = _tcsinc(*Regexp);
+ switch (Ch) {
case 0: return 0;
case _T('a'): Ch = _T('\a'); break;
case _T('b'): Ch = _T('\b'); break;
case _T('>'): CHECK(AddNode(&F, &N, NewNode(RE_ATEOW))); break;
default:
--*Regexp;
- CHECK(AddNode(&F, &N, NewChar(**Regexp)));
- ++*Regexp;
+ CHECK(AddNode(&F, &N, NewChar(mytcsnextc(*Regexp))));
+ *Regexp = _tcsinc(*Regexp);
break;
}
}
break;
case RE_ANY:
if (rex == eop) return 0;
- rex++;
+ rex = _tcsinc(rex);
break;
case RE_WSPACE:
if (rex == eop) return 0;
if (*rex != _T(' ') && *rex != _T('\n') && *rex != _T('\r') && *rex != _T('\t')) return 0;
- rex++;
+ rex = _tcsinc(rex);
break;
case RE_NWSPACE:
if (rex == eop) return 0;
if (*rex == _T(' ') || *rex == _T('\n') || *rex == _T('\r') || *rex == _T('\t')) return 0;
- rex++;
+ rex = _tcsinc(rex);
break;
case RE_WORD:
if (rex == eop) return 0;
if (!_istalnum(*rex)) return 0;
- rex++;
+ rex = _tcsinc(rex);
break;
case RE_NWORD:
if (rex == eop) return 0;
if (_istalnum(*rex)) return 0;
- rex++;
+ rex = _tcsinc(rex);
break;
case RE_DIGIT:
if (rex == eop) return 0;
if (!_istdigit(*rex)) return 0;
- rex++;
+ rex = _tcsinc(rex);
break;
case RE_NDIGIT:
if (rex == eop) return 0;
if (_istdigit(*rex)) return 0;
- rex++;
+ rex = _tcsinc(rex);
break;
case RE_UPPER:
if (rex == eop) return 0;
if (!_istupper(*rex)) return 0;
- rex++;
+ rex = _tcsinc(rex);
break;
case RE_LOWER:
if (rex == eop) return 0;
if (!_istlower(*rex)) return 0;
- rex++;
+ rex = _tcsinc(rex);
break;
case RE_ATBOW:
if (rex >= eop) return 0;
if (*n->fChar != *rex) return 0;
if (memcmp(rex, n->fChar, n->fLen) != 0) return 0;
} else {
- for (int i = 0; i < n->fLen; i++)
- if (_totupper(rex[i]) != _totupper(n->fChar[i]))
+ for (int i = 0; i < n->fLen; i+= _tcsinc(&rex[i]) - &rex[i])
+ if (_totupper(mytcsnextc(&rex[i])) != _totupper(mytcsnextc(&n->fChar[i])))
return 0;
}
rex += n->fLen;
#ifdef _UNICODE
if ((n->fChar[(TCHAR)(*rex) >> 3] & (1 << ((TCHAR)(*rex) & 7))) == 0) return 0;
#else // _UNICODE
- if ((n->fChar[(unsigned char)(*rex) >> 3] & (1 << ((unsigned char)(*rex) & 7))) == 0) return 0;
+ {
+ unsigned int ch = mytcsnextc(rex);
+ if ((n->fChar[ch >> 3] & (1 << ((unsigned char)(ch) & 7))) == 0) return 0;
+ }
#endif // _UNICODE
- rex++;
+ rex = _tcsinc(rex);
break;
case RE_NOTINSET:
if (rex == eop) return 0;
#ifdef _UNICODE
if (n->fChar[(TCHAR)(*rex) >> 3] & (1 << ((TCHAR)(*rex) & 7))) return 0;
#else // _UNICODE
- if (n->fChar[(unsigned char)(*rex) >> 3] & (1 << ((unsigned char)(*rex) & 7))) return 0;
+ {
+ unsigned int ch = mytcsnextc(rex);
+ if (n->fChar[ch >> 3] & (1 << ((unsigned char)(ch) & 7))) return 0;
+ }
#endif // _UNICODE
- rex++;
+ rex = _tcsinc(rex);
break;
case RE_JUMP:
n = n->fPtr;
if (flags & RX_CASE) {
while (1) {
while (Start < eop && *Start != Ch)
- Start++;
+ Start = _tcsinc(Start);
if (Start == eop)
break;
if (RxTry(Regexp, Start))
return 1;
- if (++Start == eop)
+ if ((Start = _tcsinc(Start)) == eop)
break;
}
} else {
Ch = (TCHAR)_totupper(Ch);
while (1) {
- while (Start < eop && (TCHAR) _totupper(*Start) != Ch)
- Start++;
+ while (Start < eop && (TCHAR) _totupper(*Start) != Ch) {
+ Start = _tcsinc(Start);
+ }
if (Start == eop)
break;
if (RxTry(Regexp, Start))
return 1;
- if (++Start == eop)
+ if ((Start = _tcsinc(Start)) == eop)
break;
}
}
default: // (slow)
do {
if (RxTry(Regexp, Start)) return 1;
- } while (Start++ < eop);
+ } while ((Start = _tcsinc(Start)) < eop);
break;
}
return 0;
#include "stdafx.h"
#include "ccrystaltextview.h"
+#include "ccrystaltextbuffer.h"
#ifdef _DEBUG
#define new DEBUG_NEW
BOOL bWasCommentStart = FALSE;
BOOL bDecIndex = FALSE;
int nIdentBegin = -1;
- for (int I = 0;; I++)
+ int nPrevI = -1;
+ for (int I = 0;; nPrevI = I, I = ::CharNext(pszChars+I) - pszChars)
{
if (bRedefineBlock)
{
int nPos = I;
if (bDecIndex)
- nPos--;
+ nPos = nPrevI;
if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
{
DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
}
else
{
- if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (pszChars[nPos - 1]) && !xisalpha (pszChars[nPos + 1])))
+ if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (*::CharPrev(pszChars, pszChars + nPos)) && !xisalpha (*::CharNext(pszChars + nPos))))
{
DEFINE_BLOCK (nPos, COLORINDEX_NORMALTEXT);
}
// String constant "...."
if (dwCookie & COOKIE_STRING)
{
- if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_STRING;
bRedefineBlock = TRUE;
// Char constant '..'
if (dwCookie & COOKIE_CHAR)
{
- if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_CHAR;
bRedefineBlock = TRUE;
// Extended comment /*....*/
if (dwCookie & COOKIE_EXT_COMMENT)
{
- // if (I > 0 && pszChars[I] == '/' && pszChars[I - 1] == '*')
- if ((I > 1 && pszChars[I] == '/' && pszChars[I - 1] == '*' /*&& pszChars[I - 2] != '/'*/ && !bWasCommentStart) || (I == 1 && pszChars[I] == '/' && pszChars[I - 1] == '*'))
+ // if (I > 0 && pszChars[I] == '/' && pszChars[nPrevI] == '*')
+ if ((I > 1 && pszChars[I] == '/' && pszChars[nPrevI] == '*' /*&& *::CharPrev(pszChars, pszChars + nPrevI) != '/'*/ && !bWasCommentStart) || (I == 1 && pszChars[I] == '/' && pszChars[nPrevI] == '*'))
{
dwCookie &= ~COOKIE_EXT_COMMENT;
bRedefineBlock = TRUE;
continue;
}
- if (I > 0 && pszChars[I] == '/' && pszChars[I - 1] == '/')
+ if (I > 0 && pszChars[I] == '/' && pszChars[nPrevI] == '/')
{
- DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
+ DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_COMMENT;
break;
}
// Preprocessor directive #....
if (dwCookie & COOKIE_PREPROCESSOR)
{
- if (I > 0 && pszChars[I] == '*' && pszChars[I - 1] == '/')
+ if (I > 0 && pszChars[I] == '*' && pszChars[nPrevI] == '/')
{
- DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
+ DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_EXT_COMMENT;
}
continue;
if (pszChars[I] == '\'')
{
// if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
- if (!I || !xisalnum (pszChars[I - 1]))
+ if (!I || !xisalnum (pszChars[nPrevI]))
{
DEFINE_BLOCK (I, COLORINDEX_STRING);
dwCookie |= COOKIE_CHAR;
continue;
}
}
- if (I > 0 && pszChars[I] == '*' && pszChars[I - 1] == '/')
+ if (I > 0 && pszChars[I] == '*' && pszChars[nPrevI] == '/')
{
- DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
+ DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_EXT_COMMENT;
bWasCommentStart = TRUE;
continue;
dwCookie |= COOKIE_PREPROCESSOR;
continue;
}
- if (!_istspace (pszChars[I]))
+ if (!xisspace (pszChars[I]))
bFirstChar = FALSE;
}
continue; // We don't need to extract keywords,
// for faster parsing skip the rest of loop
- if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[I - 1]) && !xisalpha (pszChars[I + 1])))
+ if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[nPrevI]) && !xisalpha (pszChars[I + 1])))
{
if (nIdentBegin == -1)
nIdentBegin = I;
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
}
}
- if (pszChars[nLength - 1] != '\\')
+ if (pszChars[nLength - 1] != '\\' || m_pTextBuffer->IsMBSTrail(nLineIndex, nLength - 1))
dwCookie &= COOKIE_EXT_COMMENT;
return dwCookie;
}
BOOL bWasCommentStart = FALSE;
BOOL bDecIndex = FALSE;
int nIdentBegin = -1;
- for (int I = 0;; I++)
+ int nPrevI = -1;
+ for (int I = 0;; nPrevI = I, I = CharNext(pszChars+I) - pszChars)
{
if (bRedefineBlock)
{
int nPos = I;
if (bDecIndex)
- nPos--;
+ nPos = nPrevI;
if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
{
DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
// String constant "...."
if (dwCookie & COOKIE_STRING)
{
- if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_STRING;
bRedefineBlock = TRUE;
// Char constant '..'
if (dwCookie & COOKIE_CHAR)
{
- if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_CHAR;
bRedefineBlock = TRUE;
// Extended comment /*....*/
if (dwCookie & COOKIE_EXT_COMMENT)
{
- // if (I > 0 && pszChars[I] == '/' && pszChars[I - 1] == '*')
- if ((I > 1 && pszChars[I] == '/' && pszChars[I - 1] == '*' /*&& pszChars[I - 2] != '/'*/ && !bWasCommentStart) || (I == 1 && pszChars[I] == '/' && pszChars[I - 1] == '*'))
+ // if (I > 0 && pszChars[I] == '/' && pszChars[nPrevI] == '*')
+ if ((I > 1 && pszChars[I] == '/' && pszChars[nPrevI] == '*' /*&& *::CharPrev(pszChars, pszChars + nPrevI) != '/'*/ && !bWasCommentStart) || (I == 1 && pszChars[I] == '/' && pszChars[nPrevI] == '*'))
{
dwCookie &= ~COOKIE_EXT_COMMENT;
bRedefineBlock = TRUE;
continue;
}
- if (I > 0 && pszChars[I] == '/' && pszChars[I - 1] == '/')
+ if (I > 0 && pszChars[I] == '/' && pszChars[nPrevI] == '/')
{
- DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
+ DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_COMMENT;
break;
}
if (pszChars[I] == '\'')
{
// if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
- if (!I || !xisalnum (pszChars[I - 1]))
+ if (!I || !xisalnum (pszChars[nPrevI]))
{
DEFINE_BLOCK (I, COLORINDEX_STRING);
dwCookie |= COOKIE_CHAR;
continue;
}
}
- if (I > 0 && pszChars[I] == '*' && pszChars[I - 1] == '/')
+ if (I > 0 && pszChars[I] == '*' && pszChars[nPrevI] == '/')
{
- DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
+ DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_EXT_COMMENT;
bWasCommentStart = TRUE;
continue;
if (bFirstChar)
{
- if (!_istspace (pszChars[I]))
+ if (!xisspace (pszChars[I]))
bFirstChar = FALSE;
}
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '{' || pszChars[j] == ':')
{
{
for (int j = nIdentBegin; --j >= 0;)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == ':')
{
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '{' || pszChars[j] == ':')
{
{
for (int j = nIdentBegin; --j >= 0;)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == ':')
{
do
if ((test = sString.GetAt (--posit)) == _T ('.'))
return posit;
+#ifdef _UNICODE
while (posit && test != _T ('\\') && test != _T (':'));
+#else
+ while (posit && (test != _T ('\\') || _ismbstrail((unsigned char *)pszString, (unsigned char *)pszString + posit)) && test != _T (':'));
+#endif
return len;
}
int posit = sString.GetLength ();
TCHAR test;
do
+#ifdef _UNICODE
if ((test = sString.GetAt (--posit)) == _T ('\\') || test == _T (':'))
+#else
+ if (((test = sString.GetAt (--posit)) == _T ('\\') && !_ismbstrail((unsigned char *)pszString, (unsigned char *)pszString + posit)) || test == _T (':'))
+#endif
return posit + 1;
while (posit);
return posit;
TCHAR test = sString.GetAt (posit - 1);
+#ifdef _UNICODE
if (test == _T (':') || test == _T ('\\') && (posit == 1 || posit != 1 && sString.GetAt (posit - 2) == _T (':')))
+#else
+ if (test == _T (':') || (test == _T ('\\') && !_ismbstrail((unsigned char *)(LPCTSTR)sString, (unsigned char *)(LPCTSTR)sString + posit)) && (posit == 1 || posit != 1 && sString.GetAt (posit - 2) == _T (':')))
+#endif
return sString.Left (posit);
return sString.Left (bClose ? posit : test == _T (':') ? posit : posit - 1);
}
#include "stdafx.h"
#include "ccrystaltextview.h"
+#include "ccrystaltextbuffer.h"
#ifdef _DEBUG
#define new DEBUG_NEW
BOOL bRedefineBlock = TRUE;
BOOL bDecIndex = FALSE;
int nIdentBegin = -1;
- for (int I = 0;; I++)
+ int nPrevI = -1;
+ for (int I = 0;; nPrevI = I, I = CharNext(pszChars+I) - pszChars)
{
if (bRedefineBlock)
{
int nPos = I;
if (bDecIndex)
- nPos--;
+ nPos = nPrevI;
if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
{
DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
}
else
{
- if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (pszChars[nPos - 1]) && !xisalpha (pszChars[nPos + 1])))
+ if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (*::CharPrev(pszChars, pszChars + nPos)) && !xisalpha (*::CharNext(pszChars + nPos))))
{
DEFINE_BLOCK (nPos, COLORINDEX_NORMALTEXT);
}
// String constant "...."
if (dwCookie & COOKIE_STRING)
{
- if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_STRING;
bRedefineBlock = TRUE;
// Char constant '..'
if (dwCookie & COOKIE_CHAR)
{
- if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_CHAR;
bRedefineBlock = TRUE;
if (pszChars[I] == '\'')
{
// if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
- if (!I || !xisalnum (pszChars[I - 1]))
+ if (!I || !xisalnum (pszChars[nPrevI]))
{
DEFINE_BLOCK (I, COLORINDEX_STRING);
dwCookie |= COOKIE_CHAR;
if (bFirstChar)
{
- if (!_istspace (pszChars[I]))
+ if (!xisspace (pszChars[I]))
bFirstChar = FALSE;
}
continue; // We don't need to extract keywords,
// for faster parsing skip the rest of loop
- if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[I - 1]) && !xisalpha (pszChars[I + 1])))
+ if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[nPrevI]) && !xisalpha (pszChars[I + 1])))
{
if (nIdentBegin == -1)
nIdentBegin = I;
}
}
- if (pszChars[nLength - 1] != '\\')
+ if (pszChars[nLength - 1] != '\\' || m_pTextBuffer->IsMBSTrail(nLineIndex, nLength - 1))
dwCookie &= COOKIE_EXT_COMMENT;
return dwCookie;
}
BOOL bRedefineBlock = TRUE;
BOOL bDecIndex = FALSE;
int nIdentBegin = -1;
- for (int I = 0;; I++)
+ int nPrevI = -1;
+ for (int I = 0;; nPrevI = I, I = CharNext(pszChars+I) - pszChars)
{
if (bRedefineBlock)
{
int nPos = I;
if (bDecIndex)
- nPos--;
+ nPos = nPrevI;
if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
{
DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
// String constant "...."
if (dwCookie & COOKIE_STRING)
{
- if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_STRING;
bRedefineBlock = TRUE;
// Char constant '..'
if (dwCookie & COOKIE_CHAR)
{
- if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_CHAR;
bRedefineBlock = TRUE;
// Extended comment <!--....-->
if (dwCookie & COOKIE_EXT_COMMENT)
{
- if (I > 1 && pszChars[I] == '>' && pszChars[I - 1] == '-' && pszChars[I - 2] == '-')
+ if (I > 1 && pszChars[I] == '>' && pszChars[nPrevI] == '-' && *::CharPrev(pszChars, pszChars + nPrevI) == '-')
{
dwCookie &= ~COOKIE_EXT_COMMENT;
bRedefineBlock = TRUE;
// Extended comment <?....?>
if (dwCookie & COOKIE_EXT_USER1)
{
- if (I > 0 && pszChars[I] == '>' && (pszChars[I - 1] == '?' || pszChars[I - 1] == '%'))
+ if (I > 0 && pszChars[I] == '>' && (pszChars[nPrevI] == '?' || pszChars[nPrevI] == '%'))
{
dwCookie &= ~COOKIE_EXT_USER1;
bRedefineBlock = TRUE;
if ((dwCookie & COOKIE_PREPROCESSOR) && pszChars[I] == '\'')
{
// if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
- if (!I || !xisalnum (pszChars[I - 1]))
+ if (!I || !xisalnum (pszChars[nPrevI]))
{
DEFINE_BLOCK (I, COLORINDEX_STRING);
dwCookie |= COOKIE_CHAR;
if (bFirstChar)
{
- if (!_istspace (pszChars[I]))
+ if (!xisspace (pszChars[I]))
bFirstChar = FALSE;
}
// User1 end: ?>
if (dwCookie & COOKIE_EXT_USER1)
{
- if (I > 0 && pszChars[I] == '>' && (pszChars[I - 1] == '?' || pszChars[I - 1] == '%'))
+ if (I > 0 && pszChars[I] == '>' && (pszChars[nPrevI] == '?' || pszChars[nPrevI] == '%'))
{
dwCookie &= ~COOKIE_EXT_USER1;
nIdentBegin = -1;
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
// User1 end: ?>
if (dwCookie & COOKIE_EXT_USER1)
{
- if (I > 0 && pszChars[I] == '>' && (pszChars[I - 1] == '?' || pszChars[I - 1] == '%'))
+ if (I > 0 && pszChars[I] == '>' && (pszChars[nPrevI] == '?' || pszChars[nPrevI] == '%'))
{
dwCookie &= ~COOKIE_EXT_USER1;
nIdentBegin = -1;
#include "stdafx.h"
#include "ccrystaltextview.h"
+#include "ccrystaltextbuffer.h"
#ifdef _DEBUG
#define new DEBUG_NEW
BOOL bWasCommentStart = FALSE;
BOOL bDecIndex = FALSE;
int nIdentBegin = -1;
- for (int I = 0;; I++)
+ int nPrevI = -1;
+ for (int I = 0;; nPrevI = I, I = CharNext(pszChars+I) - pszChars)
{
if (bRedefineBlock)
{
int nPos = I;
if (bDecIndex)
- nPos--;
+ nPos = nPrevI;
if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
{
DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
}
else
{
- if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (pszChars[nPos - 1]) && !xisalpha (pszChars[nPos + 1])))
+ if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (*::CharPrev(pszChars, pszChars + nPos)) && !xisalpha (*::CharNext(pszChars + nPos))))
{
DEFINE_BLOCK (nPos, COLORINDEX_NORMALTEXT);
}
// String constant "...."
if (dwCookie & COOKIE_STRING)
{
- if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_STRING;
bRedefineBlock = TRUE;
// Char constant '..'
if (dwCookie & COOKIE_CHAR)
{
- if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_CHAR;
bRedefineBlock = TRUE;
// Extended comment /*....*/
if (dwCookie & COOKIE_EXT_COMMENT)
{
- // if (I > 0 && pszChars[I] == '/' && pszChars[I - 1] == '*')
- if ((I > 1 && pszChars[I] == '/' && pszChars[I - 1] == '*' /*&& pszChars[I - 2] != '/'*/ && !bWasCommentStart) || (I == 1 && pszChars[I] == '/' && pszChars[I - 1] == '*'))
+ // if (I > 0 && pszChars[I] == '/' && pszChars[nPrevI] == '*')
+ if ((I > 1 && pszChars[I] == '/' && pszChars[nPrevI] == '*' /*&& *::CharPrev(pszChars, pszChars + nPrevI) != '/'*/ && !bWasCommentStart) || (I == 1 && pszChars[I] == '/' && pszChars[nPrevI] == '*'))
{
dwCookie &= ~COOKIE_EXT_COMMENT;
bRedefineBlock = TRUE;
continue;
}
- if (I > 0 && pszChars[I] == '/' && pszChars[I - 1] == '/')
+ if (I > 0 && pszChars[I] == '/' && pszChars[nPrevI] == '/')
{
- DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
+ DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_COMMENT;
break;
}
// Preprocessor directive #....
if (dwCookie & COOKIE_PREPROCESSOR)
{
- if (I > 0 && pszChars[I] == '*' && pszChars[I - 1] == '/')
+ if (I > 0 && pszChars[I] == '*' && pszChars[nPrevI] == '/')
{
- DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
+ DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_EXT_COMMENT;
}
continue;
if (pszChars[I] == '\'')
{
// if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
- if (!I || !xisalnum (pszChars[I - 1]))
+ if (!I || !xisalnum (pszChars[nPrevI]))
{
DEFINE_BLOCK (I, COLORINDEX_STRING);
dwCookie |= COOKIE_CHAR;
continue;
}
}
- if (I > 0 && pszChars[I] == '*' && pszChars[I - 1] == '/')
+ if (I > 0 && pszChars[I] == '*' && pszChars[nPrevI] == '/')
{
- DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
+ DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_EXT_COMMENT;
bWasCommentStart = TRUE;
continue;
dwCookie |= COOKIE_PREPROCESSOR;
continue;
}
- if (!_istspace (pszChars[I]))
+ if (!xisspace (pszChars[I]))
bFirstChar = FALSE;
}
continue; // We don't need to extract keywords,
// for faster parsing skip the rest of loop
- if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[I - 1]) && !xisalpha (pszChars[I + 1])))
+ if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[nPrevI]) && !xisalpha (pszChars[I + 1])))
{
if (nIdentBegin == -1)
nIdentBegin = I;
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
}
}
- if (pszChars[nLength - 1] != '\\')
+ if (pszChars[nLength - 1] != '\\' || m_pTextBuffer->IsMBSTrail(nLineIndex, nLength - 1))
dwCookie &= COOKIE_EXT_COMMENT;
return dwCookie;
}
#include "stdafx.h"
#include "ccrystaltextview.h"
+#include "ccrystaltextbuffer.h"
#ifdef _DEBUG
#define new DEBUG_NEW
BOOL bWasCommentStart = FALSE;
BOOL bDecIndex = FALSE;
int nIdentBegin = -1;
- for (int I = 0;; I++)
+ int nPrevI = -1;
+ for (int I = 0;; nPrevI = I, I = CharNext(pszChars+I) - pszChars)
{
if (bRedefineBlock)
{
int nPos = I;
if (bDecIndex)
- nPos--;
+ nPos = nPrevI;
if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
{
DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
}
else
{
- if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (pszChars[nPos - 1]) && !xisalpha (pszChars[nPos + 1])))
+ if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (*::CharPrev(pszChars, pszChars + nPos)) && !xisalpha (*::CharNext(pszChars + nPos))))
{
DEFINE_BLOCK (nPos, COLORINDEX_NORMALTEXT);
}
// String constant "...."
if (dwCookie & COOKIE_STRING)
{
- if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_STRING;
bRedefineBlock = TRUE;
// Char constant '..'
if (dwCookie & COOKIE_CHAR)
{
- if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_CHAR;
bRedefineBlock = TRUE;
// Extended comment /*....*/
if (dwCookie & COOKIE_EXT_COMMENT)
{
- // if (I > 0 && pszChars[I] == '/' && pszChars[I - 1] == '*')
- if ((I > 1 && pszChars[I] == '/' && pszChars[I - 1] == '*' /*&& pszChars[I - 2] != '/'*/ && !bWasCommentStart) || (I == 1 && pszChars[I] == '/' && pszChars[I - 1] == '*'))
+ // if (I > 0 && pszChars[I] == '/' && pszChars[nPrevI] == '*')
+ if ((I > 1 && pszChars[I] == '/' && pszChars[nPrevI] == '*' /*&& *::CharPrev(pszChars, pszChars + nPrevI) != '/'*/ && !bWasCommentStart) || (I == 1 && pszChars[I] == '/' && pszChars[nPrevI] == '*'))
{
dwCookie &= ~COOKIE_EXT_COMMENT;
bRedefineBlock = TRUE;
continue;
}
- if (I > 0 && pszChars[I] == '/' && pszChars[I - 1] == '/')
+ if (I > 0 && pszChars[I] == '/' && pszChars[nPrevI] == '/')
{
- DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
+ DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_COMMENT;
break;
}
// Preprocessor directive #....
if (dwCookie & COOKIE_PREPROCESSOR)
{
- if (I > 0 && pszChars[I] == '*' && pszChars[I - 1] == '/')
+ if (I > 0 && pszChars[I] == '*' && pszChars[nPrevI] == '/')
{
- DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
+ DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_EXT_COMMENT;
}
continue;
if (pszChars[I] == '\'')
{
// if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
- if (!I || !xisalnum (pszChars[I - 1]))
+ if (!I || !xisalnum (pszChars[nPrevI]))
{
DEFINE_BLOCK (I, COLORINDEX_STRING);
dwCookie |= COOKIE_CHAR;
continue;
}
}
- if (I > 0 && pszChars[I] == '*' && pszChars[I - 1] == '/')
+ if (I > 0 && pszChars[I] == '*' && pszChars[nPrevI] == '/')
{
- DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
+ DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_EXT_COMMENT;
bWasCommentStart = TRUE;
continue;
dwCookie |= COOKIE_PREPROCESSOR;
continue;
}
- if (!_istspace (pszChars[I]))
+ if (!xisspace (pszChars[I]))
bFirstChar = FALSE;
}
continue; // We don't need to extract keywords,
// for faster parsing skip the rest of loop
- if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[I - 1]) && !xisalpha (pszChars[I + 1])))
+ if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[nPrevI]) && !xisalpha (pszChars[I + 1])))
{
if (nIdentBegin == -1)
nIdentBegin = I;
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
}
}
- if (pszChars[nLength - 1] != '\\')
+ if (pszChars[nLength - 1] != '\\' || m_pTextBuffer->IsMBSTrail(nLineIndex, nLength - 1))
dwCookie &= COOKIE_EXT_COMMENT;
return dwCookie;
}
int nIdentBegin = -1;
BOOL bDefun = FALSE;
- for (int I = 0;; I++)
+ int nPrevI = -1;
+ for (int I = 0;; nPrevI = I, I = CharNext(pszChars+I) - pszChars)
{
if (bRedefineBlock)
{
int nPos = I;
if (bDecIndex)
- nPos--;
+ nPos = nPrevI;
if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
{
DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
// String constant "...."
if (dwCookie & COOKIE_STRING)
{
- if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_STRING;
bRedefineBlock = TRUE;
// Char constant '..'
if (dwCookie & COOKIE_CHAR)
{
- if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_CHAR;
bRedefineBlock = TRUE;
// Extended comment /*....*/
if (dwCookie & COOKIE_EXT_COMMENT)
{
- // if (I > 0 && pszChars[I] == ';' && pszChars[I - 1] == '|')
- if ((I > 1 && pszChars[I] == ';' && pszChars[I - 1] == '|' /*&& pszChars[I - 2] != ';'*/ && !bWasCommentStart) || (I == 1 && pszChars[I] == ';' && pszChars[I - 1] == '|'))
+ // if (I > 0 && pszChars[I] == ';' && pszChars[nPrevI] == '|')
+ if ((I > 1 && pszChars[I] == ';' && pszChars[nPrevI] == '|' /*&& *::CharPrev(pszChars, pszChars + nPrevI) != ';'*/ && !bWasCommentStart) || (I == 1 && pszChars[I] == ';' && pszChars[nPrevI] == '|'))
{
dwCookie &= ~COOKIE_EXT_COMMENT;
bRedefineBlock = TRUE;
continue;
}
- if (I > 0 && pszChars[I] != '|' && pszChars[I - 1] == ';')
+ if (I > 0 && pszChars[I] != '|' && pszChars[nPrevI] == ';')
{
DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
dwCookie |= COOKIE_COMMENT;
if (pszChars[I] == '\'')
{
// if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
- if (!I || !xisalnum (pszChars[I - 1]))
+ if (!I || !xisalnum (pszChars[nPrevI]))
{
DEFINE_BLOCK (I, COLORINDEX_STRING);
dwCookie |= COOKIE_CHAR;
continue;
}
}
- if (I > 0 && pszChars[I] == '|' && pszChars[I - 1] == ';')
+ if (I > 0 && pszChars[I] == '|' && pszChars[nPrevI] == ';')
{
DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
dwCookie |= COOKIE_EXT_COMMENT;
if (bFirstChar)
{
- if (!_istspace (pszChars[I]))
+ if (!xisspace (pszChars[I]))
bFirstChar = FALSE;
}
{
for (int j = nIdentBegin; --j >= 0;)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
{
for (int j = I; j >= 0; j--)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
{
for (int j = nIdentBegin; --j >= 0;)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
{
for (int j = I; j >= 0; j--)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
#include "stdafx.h"
#include "ccrystaltextview.h"
+#include "ccrystaltextbuffer.h"
#ifdef _DEBUG
#define new DEBUG_NEW
BOOL bRedefineBlock = TRUE;
BOOL bDecIndex = FALSE;
int nIdentBegin = -1;
- for (int I = 0;; I++)
+ int nPrevI = -1;
+ for (int I = 0;; nPrevI = I, I = CharNext(pszChars+I) - pszChars)
{
if (bRedefineBlock)
{
int nPos = I;
if (bDecIndex)
- nPos--;
+ nPos = nPrevI;
if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT | COOKIE_EXT_COMMENT2))
{
DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
}
else
{
- if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (pszChars[nPos - 1]) && !xisalpha (pszChars[nPos + 1])))
+ if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (*::CharPrev(pszChars, pszChars + nPos)) && !xisalpha (*::CharNext(pszChars + nPos))))
{
DEFINE_BLOCK (nPos, COLORINDEX_NORMALTEXT);
}
// String constant "...."
if (dwCookie & COOKIE_STRING)
{
- if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_STRING;
bRedefineBlock = TRUE;
// Char constant '..'
if (dwCookie & COOKIE_CHAR)
{
- if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_CHAR;
bRedefineBlock = TRUE;
// Extended comment /*....*/
if (dwCookie & COOKIE_EXT_COMMENT)
{
- // if (I > 0 && pszChars[I] == ')' && pszChars[I - 1] == '*')
- if ((I > 1 && pszChars[I] == ')' && pszChars[I - 1] == '*' && pszChars[I - 2] != '(') || (I == 1 && pszChars[I] == ')' && pszChars[I - 1] == '*'))
+ // if (I > 0 && pszChars[I] == ')' && pszChars[nPrevI] == '*')
+ if ((I > 1 && pszChars[I] == ')' && pszChars[nPrevI] == '*' && *::CharPrev(pszChars, pszChars + nPrevI) != '(') || (I == 1 && pszChars[I] == ')' && pszChars[nPrevI] == '*'))
{
dwCookie &= ~COOKIE_EXT_COMMENT;
bRedefineBlock = TRUE;
continue;
}
- if (I > 0 && pszChars[I] == '/' && pszChars[I - 1] == '/')
+ if (I > 0 && pszChars[I] == '/' && pszChars[nPrevI] == '/')
{
- DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
+ DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_COMMENT;
break;
}
if (pszChars[I] == '\'')
{
// if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
- if (!I || !xisalnum (pszChars[I - 1]))
+ if (!I || !xisalnum (pszChars[nPrevI]))
{
DEFINE_BLOCK (I, COLORINDEX_STRING);
dwCookie |= COOKIE_CHAR;
continue;
}
}
- if (I > 0 && pszChars[I] == '*' && pszChars[I - 1] == '(')
+ if (I > 0 && pszChars[I] == '*' && pszChars[nPrevI] == '(')
{
- DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
+ DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_EXT_COMMENT;
continue;
}
if (bFirstChar)
{
- if (!_istspace (pszChars[I]))
+ if (!xisspace (pszChars[I]))
bFirstChar = FALSE;
}
continue; // We don't need to extract keywords,
// for faster parsing skip the rest of loop
- if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[I - 1]) && !xisalpha (pszChars[I + 1])))
+ if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[nPrevI]) && !xisalpha (pszChars[I + 1])))
{
if (nIdentBegin == -1)
nIdentBegin = I;
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
}
}
- if (pszChars[nLength - 1] != '\\')
+ if (pszChars[nLength - 1] != '\\' || m_pTextBuffer->IsMBSTrail(nLineIndex, nLength - 1))
dwCookie &= (COOKIE_EXT_COMMENT | COOKIE_EXT_COMMENT2);
return dwCookie;
}
#include "stdafx.h"
#include "ccrystaltextview.h"
+#include "ccrystaltextbuffer.h"
#ifdef _DEBUG
#define new DEBUG_NEW
BOOL bRedefineBlock = TRUE;
BOOL bDecIndex = FALSE;
int nIdentBegin = -1;
- for (int I = 0;; I++)
+ int nPrevI = -1;
+ for (int I = 0;; nPrevI = I, I = CharNext(pszChars+I) - pszChars)
{
if (bRedefineBlock)
{
int nPos = I;
if (bDecIndex)
- nPos--;
+ nPos = nPrevI;
if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
{
DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
}
else
{
- if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (pszChars[nPos - 1]) && !xisalpha (pszChars[nPos + 1])))
+ if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (*::CharPrev(pszChars, pszChars + nPos)) && !xisalpha (*::CharNext(pszChars + nPos))))
{
DEFINE_BLOCK (nPos, COLORINDEX_NORMALTEXT);
}
// String constant "...."
if (dwCookie & COOKIE_STRING)
{
- if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_STRING;
bRedefineBlock = TRUE;
// Char constant '..'
if (dwCookie & COOKIE_CHAR)
{
- if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_CHAR;
bRedefineBlock = TRUE;
if (pszChars[I] == '\'')
{
// if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
- if (!I || !xisalnum (pszChars[I - 1]))
+ if (!I || !xisalnum (pszChars[nPrevI]))
{
DEFINE_BLOCK (I, COLORINDEX_STRING);
dwCookie |= COOKIE_CHAR;
if (bFirstChar)
{
- if (!_istspace (pszChars[I]))
+ if (!xisspace (pszChars[I]))
bFirstChar = FALSE;
}
continue; // We don't need to extract keywords,
// for faster parsing skip the rest of loop
- if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[I - 1]) && !xisalpha (pszChars[I + 1])))
+ if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[nPrevI]) && !xisalpha (pszChars[I + 1])))
{
if (nIdentBegin == -1)
nIdentBegin = I;
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
}
}
- if (pszChars[nLength - 1] != '\\')
+ if (pszChars[nLength - 1] != '\\' || m_pTextBuffer->IsMBSTrail(nLineIndex, nLength - 1))
dwCookie &= COOKIE_EXT_COMMENT;
return dwCookie;
}
BOOL bWasCommentStart = FALSE;
BOOL bDecIndex = FALSE;
int nIdentBegin = -1;
- for (int I = 0;; I++)
+ int nPrevI = -1;
+ for (int I = 0;; nPrevI = I, I = CharNext(pszChars+I) - pszChars)
{
if (bRedefineBlock)
{
int nPos = I;
if (bDecIndex)
- nPos--;
+ nPos = nPrevI;
if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
{
DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
// String constant "...."
if (dwCookie & COOKIE_STRING)
{
- if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_STRING;
bRedefineBlock = TRUE;
// Char constant '..'
if (dwCookie & COOKIE_CHAR)
{
- if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_CHAR;
bRedefineBlock = TRUE;
{
if (dwCookie & COOKIE_EXT_USER1)
{
- if ((I > 1 && pszChars[I] == '/' && pszChars[I - 1] == '*' /*&& pszChars[I - 2] != '/'*/ && !bWasCommentStart) || (I == 1 && pszChars[I] == '/' && pszChars[I - 1] == '*'))
+ if ((I > 1 && pszChars[I] == '/' && pszChars[nPrevI] == '*' /*&& *::CharPrev(pszChars, pszChars + nPrevI) != '/'*/ && !bWasCommentStart) || (I == 1 && pszChars[I] == '/' && pszChars[nPrevI] == '*'))
{
dwCookie &= ~COOKIE_EXT_COMMENT;
bRedefineBlock = TRUE;
}
else
{
- if (I > 1 && pszChars[I] == '>' && pszChars[I - 1] == '-' && pszChars[I - 2] == '-')
+ if (I > 1 && pszChars[I] == '>' && pszChars[nPrevI] == '-' && *::CharPrev(pszChars, pszChars + nPrevI) == '-')
{
dwCookie &= ~COOKIE_EXT_COMMENT;
bRedefineBlock = TRUE;
continue;
}
- if ((dwCookie & COOKIE_EXT_USER1) && I > 0 && pszChars[I] == '/' && pszChars[I - 1] == '/')
+ if ((dwCookie & COOKIE_EXT_USER1) && I > 0 && pszChars[I] == '/' && pszChars[nPrevI] == '/')
{
- DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
+ DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_COMMENT;
break;
}
// Extended comment <?....?>
if (dwCookie & COOKIE_EXT_USER1)
{
- if (I > 0 && pszChars[I] == '>' && (pszChars[I - 1] == '?' || pszChars[I - 1] == '%'))
+ if (I > 0 && pszChars[I] == '>' && (pszChars[nPrevI] == '?' || pszChars[nPrevI] == '%'))
{
dwCookie &= ~COOKIE_EXT_USER1;
bRedefineBlock = TRUE;
if ((dwCookie & (COOKIE_PREPROCESSOR|COOKIE_EXT_USER1)) && pszChars[I] == '\'')
{
// if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
- if (!I || !xisalnum (pszChars[I - 1]))
+ if (!I || !xisalnum (pszChars[nPrevI]))
{
DEFINE_BLOCK (I, COLORINDEX_STRING);
dwCookie |= COOKIE_CHAR;
if (dwCookie & COOKIE_EXT_USER1)
{
- if (I > 0 && pszChars[I] == '*' && pszChars[I - 1] == '/')
+ if (I > 0 && pszChars[I] == '*' && pszChars[nPrevI] == '/')
{
- DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
+ DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_EXT_COMMENT;
bWasCommentStart = TRUE;
continue;
if (bFirstChar)
{
- if (!_istspace (pszChars[I]))
+ if (!xisspace (pszChars[I]))
bFirstChar = FALSE;
}
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
// User1 end: ?>
if (dwCookie & COOKIE_EXT_USER1)
{
- if (I > 0 && pszChars[I] == '>' && (pszChars[I - 1] == '?' || pszChars[I - 1] == '%'))
+ if (I > 0 && pszChars[I] == '>' && (pszChars[nPrevI] == '?' || pszChars[nPrevI] == '%'))
{
dwCookie &= ~COOKIE_EXT_USER1;
nIdentBegin = -1;
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
// User1 end: ?>
if (dwCookie & COOKIE_EXT_USER1)
{
- if (I > 0 && pszChars[I] == '>' && (pszChars[I - 1] == '?' || pszChars[I - 1] == '%'))
+ if (I > 0 && pszChars[I] == '>' && (pszChars[nPrevI] == '?' || pszChars[nPrevI] == '%'))
{
dwCookie &= ~COOKIE_EXT_USER1;
nIdentBegin = -1;
#include "stdafx.h"
#include "ccrystaltextview.h"
+#include "ccrystaltextbuffer.h"
#ifdef _DEBUG
#define new DEBUG_NEW
BOOL bRedefineBlock = TRUE;
BOOL bDecIndex = FALSE;
int nIdentBegin = -1;
- for (int I = 0;; I++)
+ int nPrevI = -1;
+ for (int I = 0;; nPrevI = I, I = CharNext(pszChars+I) - pszChars)
{
if (bRedefineBlock)
{
int nPos = I;
if (bDecIndex)
- nPos--;
+ nPos = nPrevI;
if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
{
DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
}
else
{
- if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (pszChars[nPos - 1]) && !xisalpha (pszChars[nPos + 1])))
+ if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (*::CharPrev(pszChars, pszChars + nPos)) && !xisalpha (*::CharNext(pszChars + nPos))))
{
DEFINE_BLOCK (nPos, COLORINDEX_NORMALTEXT);
}
// String constant "...."
if (dwCookie & COOKIE_STRING)
{
- if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_STRING;
bRedefineBlock = TRUE;
// Char constant '..'
if (dwCookie & COOKIE_CHAR)
{
- if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_CHAR;
bRedefineBlock = TRUE;
if (pszChars[I] == '\'')
{
// if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
- if (!I || !xisalnum (pszChars[I - 1]))
+ if (!I || !xisalnum (pszChars[nPrevI]))
{
DEFINE_BLOCK (I, COLORINDEX_STRING);
dwCookie |= COOKIE_CHAR;
if (bFirstChar)
{
- if (!_istspace (pszChars[I]))
+ if (!xisspace (pszChars[I]))
bFirstChar = FALSE;
}
continue; // We don't need to extract keywords,
// for faster parsing skip the rest of loop
- if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[I - 1]) && !xisalpha (pszChars[I + 1])))
+ if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[nPrevI]) && !xisalpha (pszChars[I + 1])))
{
if (nIdentBegin == -1)
nIdentBegin = I;
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
}
}
- if (pszChars[nLength - 1] != '\\')
+ if (pszChars[nLength - 1] != '\\' || m_pTextBuffer->IsMBSTrail(nLineIndex, nLength - 1))
dwCookie &= COOKIE_EXT_COMMENT;
return dwCookie;
}
#include "stdafx.h"
#include "ccrystaltextview.h"
+#include "ccrystaltextbuffer.h"
#ifdef _DEBUG
#define new DEBUG_NEW
BOOL bWasCommentStart = FALSE;
BOOL bDecIndex = FALSE;
int nIdentBegin = -1;
- for (int I = 0;; I++)
+ int nPrevI = -1;
+ for (int I = 0;; nPrevI = I, I = CharNext(pszChars+I) - pszChars)
{
if (bRedefineBlock)
{
int nPos = I;
if (bDecIndex)
- nPos--;
+ nPos = nPrevI;
if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
{
DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
}
else
{
- if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (pszChars[nPos - 1]) && !xisalpha (pszChars[nPos + 1])))
+ if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (*::CharPrev(pszChars, pszChars + nPos)) && !xisalpha (*::CharNext(pszChars + nPos))))
{
DEFINE_BLOCK (nPos, COLORINDEX_NORMALTEXT);
}
// String constant "...."
if (dwCookie & COOKIE_STRING)
{
- if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_STRING;
bRedefineBlock = TRUE;
// Char constant '..'
if (dwCookie & COOKIE_CHAR)
{
- if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_CHAR;
bRedefineBlock = TRUE;
// Extended comment /*....*/
if (dwCookie & COOKIE_EXT_COMMENT)
{
- // if (I > 0 && pszChars[I] == '/' && pszChars[I - 1] == '*')
- if ((I > 1 && pszChars[I] == '/' && pszChars[I - 1] == '*' /*&& pszChars[I - 2] != '/'*/ && !bWasCommentStart) || (I == 1 && pszChars[I] == '/' && pszChars[I - 1] == '*'))
+ // if (I > 0 && pszChars[I] == '/' && pszChars[nPrevI] == '*')
+ if ((I > 1 && pszChars[I] == '/' && pszChars[nPrevI] == '*' /*&& *::CharPrev(pszChars, pszChars + nPrevI) != '/'*/ && !bWasCommentStart) || (I == 1 && pszChars[I] == '/' && pszChars[nPrevI] == '*'))
{
dwCookie &= ~COOKIE_EXT_COMMENT;
bRedefineBlock = TRUE;
continue;
}
- if (I > 0 && pszChars[I] == '/' && pszChars[I - 1] == '/')
+ if (I > 0 && pszChars[I] == '/' && pszChars[nPrevI] == '/')
{
- DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
+ DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_COMMENT;
break;
}
if (pszChars[I] == '\'')
{
// if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
- if (!I || !xisalnum (pszChars[I - 1]))
+ if (!I || !xisalnum (pszChars[nPrevI]))
{
DEFINE_BLOCK (I, COLORINDEX_STRING);
dwCookie |= COOKIE_CHAR;
continue;
}
}
- if (I > 0 && pszChars[I] == '*' && pszChars[I - 1] == '/')
+ if (I > 0 && pszChars[I] == '*' && pszChars[nPrevI] == '/')
{
- DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
+ DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_EXT_COMMENT;
bWasCommentStart = TRUE;
continue;
if (bFirstChar)
{
- if (!_istspace (pszChars[I]))
+ if (!xisspace (pszChars[I]))
bFirstChar = FALSE;
}
continue; // We don't need to extract keywords,
// for faster parsing skip the rest of loop
- if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[I - 1]) && !xisalpha (pszChars[I + 1])))
+ if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[nPrevI]) && !xisalpha (pszChars[I + 1])))
{
if (nIdentBegin == -1)
nIdentBegin = I;
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
}
}
- if (pszChars[nLength - 1] != '\\')
+ if (pszChars[nLength - 1] != '\\' || m_pTextBuffer->IsMBSTrail(nLineIndex, nLength - 1))
dwCookie &= COOKIE_EXT_COMMENT;
return dwCookie;
}
#include "stdafx.h"
#include "ccrystaltextview.h"
+#include "ccrystaltextbuffer.h"
#ifdef _DEBUG
#define new DEBUG_NEW
BOOL bWasCommentStart = FALSE;
BOOL bDecIndex = FALSE;
int nIdentBegin = -1;
- for (int I = 0;; I++)
+ int nPrevI = -1;
+ for (int I = 0;; nPrevI = I, I = CharNext(pszChars+I) - pszChars)
{
if (bRedefineBlock)
{
int nPos = I;
if (bDecIndex)
- nPos--;
+ nPos = nPrevI;
if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
{
DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
}
else
{
- if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (pszChars[nPos - 1]) && !xisalpha (pszChars[nPos + 1])))
+ if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (*::CharPrev(pszChars, pszChars + nPos)) && !xisalpha (*::CharNext(pszChars + nPos))))
{
DEFINE_BLOCK (nPos, COLORINDEX_NORMALTEXT);
}
// String constant "...."
if (dwCookie & COOKIE_STRING)
{
- if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_STRING;
bRedefineBlock = TRUE;
// Char constant '..'
if (dwCookie & COOKIE_CHAR)
{
- if (pszChars[I] == '\'' && (I == 0 || pszChars[I - 1] != '\\'))
+ if (pszChars[I] == '\'' && (I == 0 || pszChars[nPrevI] != '\\'))
{
dwCookie &= ~COOKIE_CHAR;
bRedefineBlock = TRUE;
// Extended comment /*....*/
if (dwCookie & COOKIE_EXT_COMMENT)
{
- // if (I > 0 && pszChars[I] == '/' && pszChars[I - 1] == '*')
- if ((I > 1 && pszChars[I] == '/' && pszChars[I - 1] == '*' /*&& pszChars[I - 2] != '/'*/ && !bWasCommentStart) || (I == 1 && pszChars[I] == '/' && pszChars[I - 1] == '*'))
+ // if (I > 0 && pszChars[I] == '/' && pszChars[nPrevI] == '*')
+ if ((I > 1 && pszChars[I] == '/' && pszChars[nPrevI] == '*' /*&& *::CharPrev(pszChars, pszChars + nPrevI) != '/'*/ && !bWasCommentStart) || (I == 1 && pszChars[I] == '/' && pszChars[nPrevI] == '*'))
{
dwCookie &= ~COOKIE_EXT_COMMENT;
bRedefineBlock = TRUE;
continue;
}
- if (I > 0 && pszChars[I] == '/' && pszChars[I - 1] == '/')
+ if (I > 0 && pszChars[I] == '/' && pszChars[nPrevI] == '/')
{
- DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
+ DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_COMMENT;
break;
}
// Preprocessor directive #....
if (dwCookie & COOKIE_PREPROCESSOR)
{
- if (I > 0 && pszChars[I] == '*' && pszChars[I - 1] == '/')
+ if (I > 0 && pszChars[I] == '*' && pszChars[nPrevI] == '/')
{
- DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
+ DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_EXT_COMMENT;
}
continue;
if (pszChars[I] == '\'')
{
// if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
- if (!I || !xisalnum (pszChars[I - 1]))
+ if (!I || !xisalnum (pszChars[nPrevI]))
{
DEFINE_BLOCK (I, COLORINDEX_STRING);
dwCookie |= COOKIE_CHAR;
continue;
}
}
- if (I > 0 && pszChars[I] == '*' && pszChars[I - 1] == '/')
+ if (I > 0 && pszChars[I] == '*' && pszChars[nPrevI] == '/')
{
- DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
+ DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_EXT_COMMENT;
bWasCommentStart = TRUE;
continue;
dwCookie |= COOKIE_PREPROCESSOR;
continue;
}
- if (!_istspace (pszChars[I]))
+ if (!xisspace (pszChars[I]))
bFirstChar = FALSE;
}
continue; // We don't need to extract keywords,
// for faster parsing skip the rest of loop
- if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[I - 1]) && !xisalpha (pszChars[I + 1])))
+ if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[nPrevI]) && !xisalpha (pszChars[I + 1])))
{
if (nIdentBegin == -1)
nIdentBegin = I;
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
}
}
- if (pszChars[nLength - 1] != '\\')
+ if (pszChars[nLength - 1] != '\\' || m_pTextBuffer->IsMBSTrail(nLineIndex, nLength - 1))
dwCookie &= COOKIE_EXT_COMMENT;
return dwCookie;
}
BOOL bRedefineBlock = TRUE;
BOOL bDecIndex = FALSE;
int nIdentBegin = -1;
- for (int I = 0;; I++)
+ int nPrevI = -1;
+ for (int I = 0;; nPrevI = I, I = CharNext(pszChars+I) - pszChars)
{
if (bRedefineBlock)
{
int nPos = I;
if (bDecIndex)
- nPos--;
+ nPos = nPrevI;
if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
{
DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
// String constant "...."
if (dwCookie & COOKIE_STRING)
{
- if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_STRING;
bRedefineBlock = TRUE;
// Char constant '..'
if (dwCookie & COOKIE_CHAR)
{
- if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_CHAR;
bRedefineBlock = TRUE;
// Extended comment <!--....-->
if (dwCookie & COOKIE_EXT_COMMENT)
{
- if (I > 1 && pszChars[I] == '>' && pszChars[I - 1] == '-' && pszChars[I - 2] == '-')
+ if (I > 1 && pszChars[I] == '>' && pszChars[nPrevI] == '-' && *::CharPrev(pszChars, pszChars + nPrevI) == '-')
{
dwCookie &= ~COOKIE_EXT_COMMENT;
bRedefineBlock = TRUE;
// Extended comment <?....?>
if (dwCookie & COOKIE_EXT_USER1)
{
- if (I > 0 && pszChars[I] == '>' && pszChars[I - 1] == '?')
+ if (I > 0 && pszChars[I] == '>' && pszChars[nPrevI] == '?')
{
dwCookie &= ~COOKIE_EXT_USER1;
bRedefineBlock = TRUE;
if (pszChars[I] == '\'')
{
// if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
- if (!I || !xisalnum (pszChars[I - 1]))
+ if (!I || !xisalnum (pszChars[nPrevI]))
{
DEFINE_BLOCK (I, COLORINDEX_STRING);
dwCookie |= COOKIE_CHAR;
if (bFirstChar)
{
- if (!_istspace (pszChars[I]))
+ if (!xisspace (pszChars[I]))
bFirstChar = FALSE;
}
#include "stdafx.h"
#include "ccrystaltextview.h"
+#include "ccrystaltextbuffer.h"
#ifdef _DEBUG
#define new DEBUG_NEW
BOOL bRedefineBlock = TRUE;
BOOL bDecIndex = FALSE;
int nIdentBegin = -1;
- for (int I = 0;; I++)
+ int nPrevI = -1;
+ for (int I = 0;; nPrevI = I, I = ::CharNext(pszChars+I) - pszChars)
{
if (bRedefineBlock)
{
int nPos = I;
if (bDecIndex)
- nPos--;
+ nPos = nPrevI;
if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
{
DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
}
else
{
- if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (pszChars[nPos - 1]) && !xisalpha (pszChars[nPos + 1])))
+ if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (*::CharPrev(pszChars, pszChars + nPos)) && !xisalpha (*::CharNext(pszChars + nPos))))
{
DEFINE_BLOCK (nPos, COLORINDEX_NORMALTEXT);
}
// String constant "...."
if (dwCookie & COOKIE_STRING)
{
- if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_STRING;
bRedefineBlock = TRUE;
// Char constant '..'
if (dwCookie & COOKIE_CHAR)
{
- if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_CHAR;
bRedefineBlock = TRUE;
if (pszChars[I] == '\'')
{
// if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
- if (!I || !xisalnum (pszChars[I - 1]))
+ if (!I || !xisalnum (pszChars[nPrevI]))
{
DEFINE_BLOCK (I, COLORINDEX_STRING);
dwCookie |= COOKIE_CHAR;
if (bFirstChar)
{
- if (!_istspace (pszChars[I]))
+ if (!xisspace (pszChars[I]))
bFirstChar = FALSE;
}
continue; // We don't need to extract keywords,
// for faster parsing skip the rest of loop
- if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[I - 1]) && !xisalpha (pszChars[I + 1])))
+ if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[nPrevI]) && !xisalpha (*::CharNext(pszChars + I))))
{
if (nIdentBegin == -1)
nIdentBegin = I;
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
}
}
- if (pszChars[nLength - 1] != '\\')
+ if (pszChars[nLength - 1] != '\\' || m_pTextBuffer->IsMBSTrail(nLineIndex, nLength - 1))
dwCookie &= COOKIE_EXT_COMMENT;
return dwCookie;
}
int nIdentBegin = -1;
BOOL bDefun = FALSE;
- for (int I = 0;; I++)
+ int nPrevI = -1;
+ for (int I = 0;; nPrevI = I, I = ::CharNext(pszChars+I) - pszChars)
{
if (bRedefineBlock)
{
int nPos = I;
if (bDecIndex)
- nPos--;
+ nPos = nPrevI;
if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
{
DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
// String constant "...."
if (dwCookie & COOKIE_STRING)
{
- if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_STRING;
bRedefineBlock = TRUE;
// Char constant '..'
if (dwCookie & COOKIE_CHAR)
{
- if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_CHAR;
bRedefineBlock = TRUE;
// Extended comment /*....*/
if (dwCookie & COOKIE_EXT_COMMENT)
{
- // if (I > 0 && pszChars[I] == ';' && pszChars[I - 1] == '|')
- if ((I > 1 && pszChars[I] == ';' && pszChars[I - 1] == '|' /*&& pszChars[I - 2] != ';'*/ && !bWasCommentStart) || (I == 1 && pszChars[I] == ';' && pszChars[I - 1] == '|'))
+ // if (I > 0 && pszChars[I] == ';' && pszChars[nPrevI] == '|')
+ if ((I > 1 && pszChars[I] == ';' && pszChars[nPrevI] == '|' /*&& *::CharPrev(pszChars, pszChars + nPrevI) != ';'*/ && !bWasCommentStart) || (I == 1 && pszChars[I] == ';' && pszChars[nPrevI] == '|'))
{
dwCookie &= ~COOKIE_EXT_COMMENT;
bRedefineBlock = TRUE;
continue;
}
- if (I > 0 && pszChars[I] != '|' && pszChars[I - 1] == ';')
+ if (I > 0 && pszChars[I] != '|' && pszChars[nPrevI] == ';')
{
DEFINE_BLOCK (I, COLORINDEX_COMMENT);
dwCookie |= COOKIE_COMMENT;
if (pszChars[I] == '\'')
{
// if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
- if (!I || !xisalnum (pszChars[I - 1]))
+ if (!I || !xisalnum (pszChars[nPrevI]))
{
DEFINE_BLOCK (I, COLORINDEX_STRING);
dwCookie |= COOKIE_CHAR;
continue;
}
}
- if (I > 0 && pszChars[I] == '|' && pszChars[I - 1] == ';')
+ if (I > 0 && pszChars[I] == '|' && pszChars[nPrevI] == ';')
{
- DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
+ DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_EXT_COMMENT;
bWasCommentStart = TRUE;
continue;
if (bFirstChar)
{
- if (!_istspace (pszChars[I]))
+ if (!xisspace (pszChars[I]))
bFirstChar = FALSE;
}
{
for (int j = nIdentBegin; --j >= 0;)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
{
for (int j = I; j >= 0; j--)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
{
for (int j = nIdentBegin; --j >= 0;)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
{
for (int j = I; j >= 0; j--)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
#include "stdafx.h"
#include "ccrystaltextview.h"
+#include "ccrystaltextbuffer.h"
#ifdef _DEBUG
#define new DEBUG_NEW
BOOL bWasCommentStart = FALSE;
BOOL bDecIndex = FALSE;
int nIdentBegin = -1;
- for (int I = 0;; I++)
+ int nPrevI = -1;
+ for (int I = 0;; nPrevI = I, I = ::CharNext(pszChars+I) - pszChars)
{
if (bRedefineBlock)
{
int nPos = I;
if (bDecIndex)
- nPos--;
+ nPos = nPrevI;
if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
{
DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
}
else
{
- if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (pszChars[nPos - 1]) && !xisalpha (pszChars[nPos + 1])))
+ if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (*::CharPrev(pszChars, pszChars + nPos)) && !xisalpha (*::CharNext(pszChars + nPos))))
{
DEFINE_BLOCK (nPos, COLORINDEX_NORMALTEXT);
}
// String constant "...."
if (dwCookie & COOKIE_STRING)
{
- if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_STRING;
bRedefineBlock = TRUE;
// Char constant '..'
if (dwCookie & COOKIE_CHAR)
{
- if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_CHAR;
bRedefineBlock = TRUE;
// Extended comment /*....*/
if (dwCookie & COOKIE_EXT_COMMENT)
{
- // if (I > 0 && pszChars[I] == '/' && pszChars[I - 1] == '*')
- if ((I > 1 && pszChars[I] == '/' && pszChars[I - 1] == '*' /*&& pszChars[I - 2] != '/'*/ && !bWasCommentStart) || (I == 1 && pszChars[I] == '/' && pszChars[I - 1] == '*'))
+ // if (I > 0 && pszChars[I] == '/' && pszChars[nPrevI] == '*')
+ if ((I > 1 && pszChars[I] == '/' && pszChars[nPrevI] == '*' /*&& *::CharPrev(pszChars, pszChars + nPrevI) != '/'*/ && !bWasCommentStart) || (I == 1 && pszChars[I] == '/' && pszChars[nPrevI] == '*'))
{
dwCookie &= ~COOKIE_EXT_COMMENT;
bRedefineBlock = TRUE;
continue;
}
- if (I > 0 && pszChars[I] == '/' && pszChars[I - 1] == '/')
+ if (I > 0 && pszChars[I] == '/' && pszChars[nPrevI] == '/')
{
DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
dwCookie |= COOKIE_COMMENT;
if (pszChars[I] == '\'')
{
// if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
- if (!I || !xisalnum (pszChars[I - 1]))
+ if (!I || !xisalnum (pszChars[nPrevI]))
{
DEFINE_BLOCK (I, COLORINDEX_STRING);
dwCookie |= COOKIE_CHAR;
continue;
}
}
- if (I > 0 && pszChars[I] == '*' && pszChars[I - 1] == '/')
+ if (I > 0 && pszChars[I] == '*' && pszChars[nPrevI] == '/')
{
DEFINE_BLOCK (I - 1, COLORINDEX_COMMENT);
dwCookie |= COOKIE_EXT_COMMENT;
if (bFirstChar)
{
- if (!_istspace (pszChars[I]))
+ if (!xisspace (pszChars[I]))
bFirstChar = FALSE;
}
continue; // We don't need to extract keywords,
// for faster parsing skip the rest of loop
- if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[I - 1]) && !xisalpha (pszChars[I + 1])))
+ if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[nPrevI]) && !xisalpha (pszChars[I + 1])))
{
if (nIdentBegin == -1)
nIdentBegin = I;
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
}
}
- if (pszChars[nLength - 1] != '\\')
+ if (pszChars[nLength - 1] != '\\' || m_pTextBuffer->IsMBSTrail(nLineIndex, nLength - 1))
dwCookie &= COOKIE_EXT_COMMENT;
return dwCookie;
}
#include "stdafx.h"
#include "ccrystaltextview.h"
+#include "ccrystaltextbuffer.h"
#ifdef _DEBUG
#define new DEBUG_NEW
BOOL bRedefineBlock = TRUE;
BOOL bDecIndex = FALSE;
int nIdentBegin = -1;
- for (int I = 0;; I++)
+ int nPrevI = -1;
+ for (int I = 0;; nPrevI = I, I = ::CharNext(pszChars+I) - pszChars)
{
if (bRedefineBlock)
{
int nPos = I;
if (bDecIndex)
- nPos--;
+ nPos = nPrevI;
if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
{
DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
}
else
{
- if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (pszChars[nPos - 1]) && !xisalpha (pszChars[nPos + 1])))
+ if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (*::CharPrev(pszChars, pszChars + nPos)) && !xisalpha (*::CharNext(pszChars + nPos))))
{
DEFINE_BLOCK (nPos, COLORINDEX_NORMALTEXT);
}
// String constant "...."
if (dwCookie & COOKIE_STRING)
{
- if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_STRING;
bRedefineBlock = TRUE;
// Char constant '..'
if (dwCookie & COOKIE_CHAR)
{
- if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_CHAR;
bRedefineBlock = TRUE;
if (pszChars[I] == '\'')
{
// if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
- if (!I || !xisalnum (pszChars[I - 1]))
+ if (!I || !xisalnum (pszChars[nPrevI]))
{
DEFINE_BLOCK (I, COLORINDEX_STRING);
dwCookie |= COOKIE_CHAR;
if (bFirstChar)
{
- if (!_istspace (pszChars[I]))
+ if (!xisspace (pszChars[I]))
bFirstChar = FALSE;
}
continue; // We don't need to extract keywords,
// for faster parsing skip the rest of loop
- if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[I - 1]) && !xisalpha (pszChars[I + 1])))
+ if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[nPrevI]) && !xisalpha (pszChars[I + 1])))
{
if (nIdentBegin == -1)
nIdentBegin = I;
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
for (int j = I; j < nLength; j++)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '(')
{
}
}
- if (pszChars[nLength - 1] != '\\')
+ if (pszChars[nLength - 1] != '\\' || m_pTextBuffer->IsMBSTrail(nLineIndex, nLength - 1))
dwCookie &= COOKIE_EXT_COMMENT;
return dwCookie;
}
BOOL bRedefineBlock = TRUE;
BOOL bDecIndex = FALSE;
int nIdentBegin = -1;
-
- for (int I = 0;; I++)
+ int nPrevI = -1;
+ for (int I = 0;; nPrevI = I, I = ::CharNext(pszChars+I) - pszChars)
{
if (bRedefineBlock)
{
int nPos = I;
if (bDecIndex)
- nPos--;
+ nPos = nPrevI;
if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
{
DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
// String constant "...."
if (dwCookie & COOKIE_STRING)
{
- if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_STRING;
bRedefineBlock = TRUE;
// Char constant '..'
if (dwCookie & COOKIE_CHAR)
{
- if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+ if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_CHAR;
bRedefineBlock = TRUE;
if (pszChars[I] == '\'')
{
// if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
- if (!I || !xisalnum (pszChars[I - 1]))
+ if (!I || !xisalnum (pszChars[nPrevI]))
{
DEFINE_BLOCK (I, COLORINDEX_STRING);
dwCookie |= COOKIE_CHAR;
if (bFirstChar)
{
- if (!_istspace (pszChars[I]))
+ if (!xisspace (pszChars[I]))
bFirstChar = FALSE;
}
{
for (int j = I; j >= 0; j--)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '$')
{
{
for (int j = I; j >= 0; j--)
{
- if (!_istspace (pszChars[j]))
+ if (!xisspace (pszChars[j]))
{
if (pszChars[j] == '$')
{
BOOL bRedefineBlock = TRUE;
BOOL bDecIndex = FALSE;
int nIdentBegin = -1;
- for (int I = 0;; I++)
+ int nPrevI = -1;
+ for (int I = 0;; nPrevI = I, I = ::CharNext(pszChars+I) - pszChars)
{
if (bRedefineBlock)
{
int nPos = I;
if (bDecIndex)
- nPos--;
+ nPos = nPrevI;
if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
{
DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
// Extended comment <!--....-->
if (dwCookie & COOKIE_EXT_COMMENT)
{
- if (I > 1 && pszChars[I] == '>' && pszChars[I - 1] == '-' && pszChars[I - 2] == '-')
+ if (I > 1 && pszChars[I] == '>' && pszChars[nPrevI] == '-' && *::CharPrev(pszChars, pszChars + nPrevI) == '-')
{
dwCookie &= ~COOKIE_EXT_COMMENT;
bRedefineBlock = TRUE;
// Extended comment <?....?>
if (dwCookie & COOKIE_EXT_USER1)
{
- if (I > 0 && pszChars[I] == '>' && pszChars[I - 1] == '?')
+ if (I > 0 && pszChars[I] == '>' && pszChars[nPrevI] == '?')
{
dwCookie &= ~COOKIE_EXT_USER1;
bRedefineBlock = TRUE;
if (pszChars[I] == '\'')
{
// if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
- if (!I || !xisalnum (pszChars[I - 1]))
+ if (!I || !xisalnum (pszChars[nPrevI]))
{
DEFINE_BLOCK (I, COLORINDEX_STRING);
dwCookie |= COOKIE_CHAR;
Add 0,0,0x1 to any FONT line lacking it, for all DIALOGEX dialogs
Src: Merge.rc
Languages: Merge*.rc
+ PATCH: [ 968285 ] DBCS fixes from Sawanaka
+ (continuing editlib portions)
+ Src/editlib: batch.cpp crystaleditview.cpp crystaltextview2.cpp cplusplus.cpp
+ cregexp.cpp csharp.cpp dcl.cpp filesup.cpp fortran.cpp html.cpp js.cpp
+ java.cpp list.cpp pascal.cpp perl.cpp php.cpp python.cpp rexx.cpp rsrc.cpp
+ sgml.cpp sh.cpp siod.cpp sql.cpp tcl.cpp tex.cpp xml.cpp
2005-03-05 Perry
Rename CDirFrame::SetFilter to CDirFrame::SetFilterStatusDisplay for easier greps.