Revert "Preprocessor Enginge: fix bug in pp-engine.cpp"

Breaks highlighting for macros using the predefined macros.

This reverts commit 1d834c1126.

Change-Id: Ic13c407e293a806a63ff30153864530df6a32e47
Reviewed-by: hjk <hjk121@nokiamail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Nikolai Kosjar
2013-11-29 10:53:45 +01:00
parent b2ff8d8795
commit 4edfe87b58
2 changed files with 61 additions and 1 deletions

View File

@@ -906,7 +906,49 @@ bool Preprocessor::handleIdentifier(PPToken *tk)
{
ScopedBoolSwap s(m_state.m_inPreprocessorDirective, true);
Macro *macro = m_env->resolve(tk->asByteArrayRef());
static const QByteArray ppLine("__LINE__");
static const QByteArray ppFile("__FILE__");
static const QByteArray ppDate("__DATE__");
static const QByteArray ppTime("__TIME__");
ByteArrayRef macroNameRef = tk->asByteArrayRef();
if (macroNameRef.size() == 8
&& macroNameRef[0] == '_'
&& macroNameRef[1] == '_') {
PPToken newTk;
if (macroNameRef == ppLine) {
QByteArray txt = QByteArray::number(tk->lineno);
newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false);
} else if (macroNameRef == ppFile) {
QByteArray txt;
txt.append('"');
txt.append(m_env->currentFileUtf8);
txt.append('"');
newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false);
} else if (macroNameRef == ppDate) {
QByteArray txt;
txt.append('"');
txt.append(QDate::currentDate().toString().toUtf8());
txt.append('"');
newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false);
} else if (macroNameRef == ppTime) {
QByteArray txt;
txt.append('"');
txt.append(QTime::currentTime().toString().toUtf8());
txt.append('"');
newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false);
}
if (newTk.hasSource()) {
newTk.f.newline = tk->newline();
newTk.f.whitespace = tk->whitespace();
*tk = newTk;
return false;
}
}
Macro *macro = m_env->resolve(macroNameRef);
if (!macro
|| (tk->expanded()
&& m_state.m_tokenBuffer