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 <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
Edward Welbourne 2015-11-18 14:29:19 +01:00
parent fda85b6d57
commit 8fd05e6289
2 changed files with 7 additions and 7 deletions

View File

@ -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;
}

View File

@ -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 <moc_object1.cpp>
/**/ #include <moc_object2.cpp>
/**//**/ #include <moc_object3.cpp>