From 8fd05e6289a3190a9e1e5056ecff2a0e02aac2c2 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 18 Nov 2015 14:29:19 +0100 Subject: [PATCH] Don't ignore first character after a string. The parser in QMakeSourceFileInfo::findDeps() would step over the closing quote of a string, only to have a for loop then step over the character just after that closing quote, which was thus never studied; this could lead to problems in various ways. Fixed that and expanded findDeps() test to catch regressions. Task-number: QTBUG-17533 Change-Id: I7dec5222e38fa188495b39376ffee70bc7bbc87f Reviewed-by: Oswald Buddenhagen --- qmake/generators/makefiledeps.cpp | 11 ++++------- tests/auto/tools/qmake/testdata/findDeps/main.cpp | 3 +++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/qmake/generators/makefiledeps.cpp b/qmake/generators/makefiledeps.cpp index b939a9c9d4..43f368f0be 100644 --- a/qmake/generators/makefiledeps.cpp +++ b/qmake/generators/makefiledeps.cpp @@ -584,17 +584,14 @@ bool QMakeSourceFileInfo::findDeps(SourceFile *file) // buffer[x] is '"' } else { const char term = buffer[x]; - while (++x < buffer_len) { - if (buffer[x] == term) { + while (++x < buffer_len && buffer[x] != term) { + if (buffer[x] == '\\') ++x; - break; - } else if (buffer[x] == '\\') { - ++x; - } else if (qmake_endOfLine(buffer[x])) { + else if (qmake_endOfLine(buffer[x])) ++line_count; - } } } + // for loop's ++x shall step over the closing quote. } beginning = 0; } diff --git a/tests/auto/tools/qmake/testdata/findDeps/main.cpp b/tests/auto/tools/qmake/testdata/findDeps/main.cpp index 0df3f9b7c3..d5dd5b81d3 100644 --- a/tests/auto/tools/qmake/testdata/findDeps/main.cpp +++ b/tests/auto/tools/qmake/testdata/findDeps/main.cpp @@ -35,6 +35,9 @@ / #include "needed.cpp" // if not ignored, symbol needed() won't be available ... +// Check we're not confused by string juxtaposition: +static const char text[] = "lorem ""ipsum /*"; + #include /**/ #include /**//**/ #include