aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2013-02-21 13:52:35 +1100
committernyamatongwe <devnull@localhost>2013-02-21 13:52:35 +1100
commit64a54a3c407b2208f299701628619c55121da4a3 (patch)
tree3f884f95ba6e86b8da0b5b4a986fb474da3c3950
parentbc12b527d44a39fd2b5692cd745a087eda3507b8 (diff)
downloadscintilla-mirror-64a54a3c407b2208f299701628619c55121da4a3.tar.gz
Feature: [#978]. Update preprocessor defines upon encountering an #undef directive.
From Alpha.
-rw-r--r--doc/ScintillaHistory.html1
-rw-r--r--lexers/LexCPP.cxx22
2 files changed, 20 insertions, 3 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index 8ffba3dac..fb3e71478 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -418,6 +418,7 @@
</tr><tr>
<td>G. Hu</td>
<td>Byron Hawkins</td>
+ <td>Alpha</td>
</tr>
</table>
<p>
diff --git a/lexers/LexCPP.cxx b/lexers/LexCPP.cxx
index f30cdfbdd..a064328c8 100644
--- a/lexers/LexCPP.cxx
+++ b/lexers/LexCPP.cxx
@@ -132,8 +132,9 @@ struct PPDefinition {
int line;
std::string key;
std::string value;
- PPDefinition(int line_, const std::string &key_, const std::string &value_) :
- line(line_), key(key_), value(value_) {
+ bool isUndef;
+ PPDefinition(int line_, const std::string &key_, const std::string &value_, bool isUndef_ = false) :
+ line(line_), key(key_), value(value_), isUndef(isUndef_) {
}
};
@@ -547,7 +548,10 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
std::map<std::string, std::string> preprocessorDefinitions = preprocessorDefinitionsStart;
for (std::vector<PPDefinition>::iterator itDef = ppDefineHistory.begin(); itDef != ppDefineHistory.end(); ++itDef) {
- preprocessorDefinitions[itDef->key] = itDef->value;
+ if (itDef->isUndef)
+ preprocessorDefinitions.erase(itDef->key);
+ else
+ preprocessorDefinitions[itDef->key] = itDef->value;
}
std::string rawStringTerminator = rawStringTerminators.ValueAt(lineCurrent-1);
@@ -991,6 +995,18 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
}
}
}
+ } else if (sc.Match("undef")) {
+ if (options.updatePreprocessor && !preproc.IsInactive()) {
+ std::string restOfLine = GetRestOfLine(styler, sc.currentPos + 5, true);
+ std::vector<std::string> tokens = Tokenize(restOfLine);
+ std::string key;
+ if (tokens.size() >= 1) {
+ key = tokens[0];
+ preprocessorDefinitions.erase(key);
+ ppDefineHistory.push_back(PPDefinition(lineCurrent, key, "", true));
+ definitionsChanged = true;
+ }
+ }
}
}
}