aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2018-12-04 08:29:58 +1100
committerNeil <nyamatongwe@gmail.com>2018-12-04 08:29:58 +1100
commit02b035fec78afcb1bd3d76cdcde876fdf322c655 (patch)
tree30fd9b44c423a468fb8792df5bbc45eb594a88d2
parentf18c7c8cdcbd00681dee4d8110c2b767f1d7f5f8 (diff)
downloadscintilla-mirror-02b035fec78afcb1bd3d76cdcde876fdf322c655.tar.gz
Bug [#2062]. Interpret continued preprocessor lines correctly by reading all of
the logical line.
-rw-r--r--doc/ScintillaHistory.html5
-rw-r--r--lexers/LexCPP.cxx30
2 files changed, 25 insertions, 10 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index 9d5379468..0908fcc08 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -577,6 +577,11 @@
<a href="https://sourceforge.net/p/scintilla/bugs/2054/">Bug #2054</a>.
</li>
<li>
+ The C++ lexer interprets continued preprocessor lines correctly by reading all of
+ the logical line.
+ <a href="https://sourceforge.net/p/scintilla/bugs/2062/">Bug #2062</a>.
+ </li>
+ <li>
For SciTE's Find in Files, allow case-sensitivity and whole-word options when running
a user defined command.
<a href="https://sourceforge.net/p/scintilla/bugs/2053/">Bug #2053</a>.
diff --git a/lexers/LexCPP.cxx b/lexers/LexCPP.cxx
index 4df005af2..4ca182b3a 100644
--- a/lexers/LexCPP.cxx
+++ b/lexers/LexCPP.cxx
@@ -201,17 +201,27 @@ struct EscapeSequence {
std::string GetRestOfLine(LexAccessor &styler, Sci_Position start, bool allowSpace) {
std::string restOfLine;
- Sci_Position i =0;
+ Sci_Position line = styler.GetLine(start);
+ Sci_Position pos = start;
+ Sci_Position endLine = styler.LineEnd(line);
char ch = styler.SafeGetCharAt(start, '\n');
- const Sci_Position endLine = styler.LineEnd(styler.GetLine(start));
- while (((start+i) < endLine) && (ch != '\r')) {
- const char chNext = styler.SafeGetCharAt(start + i + 1, '\n');
- if (ch == '/' && (chNext == '/' || chNext == '*'))
- break;
- if (allowSpace || (ch != ' '))
- restOfLine += ch;
- i++;
- ch = chNext;
+ while (pos < endLine) {
+ if (ch == '\\' && ((pos + 1) == endLine)) {
+ // Continuation line
+ line++;
+ pos = styler.LineStart(line);
+ endLine = styler.LineEnd(line);
+ ch = styler.SafeGetCharAt(pos, '\n');
+ } else {
+ const char chNext = styler.SafeGetCharAt(pos + 1, '\n');
+ if (ch == '/' && (chNext == '/' || chNext == '*'))
+ break;
+ if (allowSpace || (ch != ' ')) {
+ restOfLine += ch;
+ }
+ pos++;
+ ch = chNext;
+ }
}
return restOfLine;
}