diff options
-rw-r--r-- | include/SciLexer.h | 1 | ||||
-rw-r--r-- | include/Scintilla.iface | 1 | ||||
-rw-r--r-- | lexers/LexCPP.cxx | 16 | ||||
-rw-r--r-- | test/examples/x.cxx | 2 | ||||
-rw-r--r-- | test/examples/x.cxx.styled | 2 |
5 files changed, 18 insertions, 4 deletions
diff --git a/include/SciLexer.h b/include/SciLexer.h index 7fc0719a0..57b5cf6e7 100644 --- a/include/SciLexer.h +++ b/include/SciLexer.h @@ -160,6 +160,7 @@ #define SCE_C_STRINGRAW 20 #define SCE_C_TRIPLEVERBATIM 21 #define SCE_C_HASHQUOTEDSTRING 22 +#define SCE_C_PREPROCESSORCOMMENT 23 #define SCE_D_DEFAULT 0 #define SCE_D_COMMENT 1 #define SCE_D_COMMENTLINE 2 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 24de70917..7d6588616 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -2554,6 +2554,7 @@ val SCE_C_GLOBALCLASS=19 val SCE_C_STRINGRAW=20 val SCE_C_TRIPLEVERBATIM=21 val SCE_C_HASHQUOTEDSTRING=22 +val SCE_C_PREPROCESSORCOMMENT=23 # Lexical states for SCLEX_D lex D=SCLEX_D SCE_D_ val SCE_D_DEFAULT=0 diff --git a/lexers/LexCPP.cxx b/lexers/LexCPP.cxx index c3c69b703..b8cc706e7 100644 --- a/lexers/LexCPP.cxx +++ b/lexers/LexCPP.cxx @@ -517,7 +517,7 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, int activitySet = preproc.IsInactive() ? activeFlag : 0; - for (; sc.More(); sc.Forward()) { + for (; sc.More();) { if (sc.atLineStart) { // Using MaskActive() is not needed in the following statement. @@ -559,6 +559,7 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, sc.Forward(); } continuationLine = true; + sc.Forward(); continue; } } @@ -618,11 +619,21 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, sc.SetState(SCE_C_DEFAULT|activitySet); } } else { - if (sc.Match('/', '*') || sc.Match('/', '/')) { + if (sc.Match('/', '*')) { + sc.SetState(SCE_C_PREPROCESSORCOMMENT|activitySet); + sc.Forward(); // Eat the * + } else if (sc.Match('/', '/')) { sc.SetState(SCE_C_DEFAULT|activitySet); } } break; + case SCE_C_PREPROCESSORCOMMENT: + if (sc.Match('*', '/')) { + sc.Forward(); + sc.ForwardSetState(SCE_C_PREPROCESSOR|activitySet); + continue; // Without advancing in case of '\'. + } + break; case SCE_C_COMMENT: if (sc.Match('*', '/')) { sc.Forward(); @@ -924,6 +935,7 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, visibleChars++; } continuationLine = false; + sc.Forward(); } const bool rawStringsChanged = rawStringTerminators.Merge(rawSTNew, lineCurrent); if (definitionsChanged || rawStringsChanged) diff --git a/test/examples/x.cxx b/test/examples/x.cxx index 7d020ba10..384997072 100644 --- a/test/examples/x.cxx +++ b/test/examples/x.cxx @@ -1,6 +1,6 @@ // A demonstration program #include <stdio.h> -#if 0 +#if 0 /* */ #define DUMMY() \ if (1); #endif diff --git a/test/examples/x.cxx.styled b/test/examples/x.cxx.styled index 082c6c3e0..b602717a5 100644 --- a/test/examples/x.cxx.styled +++ b/test/examples/x.cxx.styled @@ -1,6 +1,6 @@ {2}// A demonstration program {9}#include <stdio.h> -#if 0 +#if 0 {23}/* */{9} {73}#define DUMMY() \ if (1); {9}#endif |