diff options
author | nyamatongwe <devnull@localhost> | 2000-04-27 14:28:34 +0000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2000-04-27 14:28:34 +0000 |
commit | 97f2e58c0f21b7ad3d88ca936e9129d6fb6564a4 (patch) | |
tree | b579bb1eef9e059bc98d849c5302f125e89d1bc7 | |
parent | cdfaf6125e0a63ba72827cc48a124e31f223e474 (diff) | |
download | scintilla-mirror-97f2e58c0f21b7ad3d88ca936e9129d6fb6564a4.tar.gz |
Mad preprocessor continue when \ at end of line.
Made unterminated string finish earlier.
-rw-r--r-- | src/LexCPP.cxx | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/src/LexCPP.cxx b/src/LexCPP.cxx index 3c02111be..ea62091df 100644 --- a/src/LexCPP.cxx +++ b/src/LexCPP.cxx @@ -51,6 +51,8 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo int levelCurrent = levelPrev; int state = initStyle; + if (state == SCE_C_STRINGEOL) // Does not leak onto next line + state = SCE_C_DEFAULT; char chPrev = ' '; char chNext = styler[startPos]; unsigned int lengthDoc = startPos + length; @@ -61,16 +63,23 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); - if ((fold) && ((ch == '\r' && chNext != '\n') || (ch == '\n'))) { - int lev = levelPrev; - if (visChars == 0) - lev |= SC_FOLDLEVELWHITEFLAG; - if ((levelCurrent > levelPrev) && (visChars > 0)) - lev |= SC_FOLDLEVELHEADERFLAG; - styler.SetLevel(lineCurrent, lev); - lineCurrent++; - visChars = 0; - levelPrev = levelCurrent; + if ((ch == '\r' && chNext != '\n') || (ch == '\n')) { + // End of line + if (state == SCE_C_STRINGEOL) { + styler.ColourTo(i, state); + state = SCE_C_DEFAULT; + } + if (fold) { + int lev = levelPrev; + if (visChars == 0) + lev |= SC_FOLDLEVELWHITEFLAG; + if ((levelCurrent > levelPrev) && (visChars > 0)) + lev |= SC_FOLDLEVELHEADERFLAG; + styler.SetLevel(lineCurrent, lev); + lineCurrent++; + visChars = 0; + levelPrev = levelCurrent; + } } if (!isspace(ch)) visChars++; @@ -82,12 +91,6 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo continue; } - if (state == SCE_C_STRINGEOL) { - if (ch != '\r' && ch != '\n') { - styler.ColourTo(i-1, state); - state = SCE_C_DEFAULT; - } - } if (state == SCE_C_DEFAULT) { if (iswordstart(ch)) { styler.ColourTo(i-1, state); @@ -148,7 +151,7 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo } } else { if (state == SCE_C_PREPROCESSOR) { - if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) { + if ((ch == '\r' || ch == '\n') && !(chPrev == '\\' || chPrev == '\r')) { styler.ColourTo(i-1, state); state = SCE_C_DEFAULT; } |