summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2012-10-12 14:06:19 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-13 05:51:19 +0200
commit9ab8c0ae98f2e488f362484c2c2d1dc6a5ae1d1e (patch)
tree34c670430061488191c44721dd357976ae1d6229 /src/tools
parenteda0e120e9e2e7b7be747f4ed035d686c9547769 (diff)
Fix moc preprocessor-only mode with input that contains seemingly invalid identifiers
In WebKit we use moc -E to pre-process various files before throwing at further build creation tools. The pre-processing is used to filter out code depending in #ifdef'fed features. The latest addition to the family of pre-processed files is the CSS grammar, which is written in Bison. It contains rule lines like $$ = parser->createFoo() and when pre-processing this moc stumbles over the dollar sign. Instead of ignoring un-tokenizable input we should add it to the current token if we're in preprocessor-only mode, otherwise the $$ gets eaten and we produce data-loss by printing out less characters than. Change-Id: Ib32e7c04b38dd2ba3726201e76f27405f7ea6c0d Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/moc/preprocessor.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp
index fd8813ee88..40bba33d40 100644
--- a/src/tools/moc/preprocessor.cpp
+++ b/src/tools/moc/preprocessor.cpp
@@ -193,9 +193,12 @@ static Symbols tokenize(const QByteArray &input, int lineNum = 1, TokenizeMode m
token = keywords[state].ident;
if (token == NOTOKEN) {
- // an error really
++data;
- continue;
+ // an error really, but let's ignore this input
+ // to not confuse moc later. However in pre-processor
+ // only mode let's continue.
+ if (!Preprocessor::preprocessOnly)
+ continue;
}
++column;