Fix dependency scanner being confused by UTF-8 BOM

Update QMakeSourceFileInfo::findDeps to skip UTF-8 BOM if exists.

Task-number: QTBUG-34182
Change-Id: I7a3e30ecab08f485c53e2ca2eab197619b11c2c7
Reviewed-by: Edward Welbourne <edward.welbourne@theqtcompany.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
MATSUMURA Tetsuro 2016-04-13 20:35:45 +09:00 committed by Oswald Buddenhagen
parent 208f364a95
commit 96ff51f856

View File

@ -554,7 +554,14 @@ bool QMakeSourceFileInfo::findDeps(SourceFile *file)
InCode // after directive, parsing non-#include directive or in actual code
} cpp_state = AtStart;
for(int x = 0; x < buffer_len; ++x) {
int x = 0;
if (buffer_len >= 3) {
const unsigned char *p = (unsigned char *)buffer;
// skip UTF-8 BOM, if present
if (p[0] == 0xEF && p[1] == 0xBB && p[2] == 0xBF)
x += 3;
}
for (; x < buffer_len; ++x) {
bool try_local = true;
char *inc = 0;
if(file->type == QMakeSourceFileInfo::TYPE_UI) {