Rework scan for keyword in preprocessor directive.
When looking for the keyword in a preprocessor directive, we were checking for non-word characters to find its end. If that check failed (i.e. we had a word character) we would then check for EOL (which necessarily failed, on a word character). That made no sense. However, we genuinely have no interest in a directive with nothing after the keyword, so do check for EOL after the loop (once we've skipped spaces after the keyword). The loop itself was made needlessly complicated by, on finding the end of the keyword, skipping over later space inside the loop. Moved this outside the loop. Change-Id: Iccc2d445bf44deb75604e7fa60f2464e7397d8ed Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
parent
3780b3da99
commit
213111f0fc
@ -572,22 +572,18 @@ bool QMakeSourceFileInfo::findDeps(SourceFile *file)
|
||||
break;
|
||||
|
||||
// Got a preprocessor directive
|
||||
|
||||
int keyword_len = 0;
|
||||
const char *const keyword = buffer + x;
|
||||
while(x+keyword_len < buffer_len) {
|
||||
if (buffer[x + keyword_len] < 'a' || buffer[x + keyword_len] > 'z') {
|
||||
for (x += keyword_len;
|
||||
x < buffer_len && (buffer[x] == ' ' || buffer[x] == '\t');
|
||||
x++) {} // skip spaces after keyword
|
||||
break;
|
||||
} else if (qmake_endOfLine(buffer[x + keyword_len])) {
|
||||
x += keyword_len-1;
|
||||
keyword_len = 0;
|
||||
break;
|
||||
}
|
||||
keyword_len++;
|
||||
}
|
||||
for (;
|
||||
x < buffer_len && buffer[x] >= 'a' && buffer[x] <= 'z';
|
||||
x++) {} // skip over identifier
|
||||
int keyword_len = buffer + x - keyword;
|
||||
for (;
|
||||
x < buffer_len && (buffer[x] == ' ' || buffer[x] == '\t');
|
||||
x++) {} // skip spaces after keyword
|
||||
|
||||
/* Keyword with nothing after it, e.g. #endif: not interesting. */
|
||||
if (qmake_endOfLine(buffer[x]))
|
||||
keyword_len = 0;
|
||||
|
||||
if((keyword_len == 7 && !strncmp(keyword, "include", 7)) // C & Obj-C
|
||||
|| (keyword_len == 6 && !strncmp(keyword, "import", 6))) { // Obj-C
|
||||
|
Loading…
Reference in New Issue
Block a user