Readability clean-up (purely cosmetic).
Principally *(buffer + expr) -> buffer[expr] changes, with some hspace normalization on affected lines. Made some empty loops more visible. Pulled out a repeated character class test as a function. Change-Id: I03d1b633550ad1814fa383d69ea04138dd0f82cd Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
parent
93466161ca
commit
f1d5641d49
@ -431,104 +431,104 @@ bool QMakeSourceFileInfo::findDeps(SourceFile *file)
|
|||||||
char *inc = 0;
|
char *inc = 0;
|
||||||
if(file->type == QMakeSourceFileInfo::TYPE_UI) {
|
if(file->type == QMakeSourceFileInfo::TYPE_UI) {
|
||||||
// skip whitespaces
|
// skip whitespaces
|
||||||
while(x < buffer_len && (*(buffer+x) == ' ' || *(buffer+x) == '\t'))
|
while (x < buffer_len && (buffer[x] == ' ' || buffer[x] == '\t'))
|
||||||
++x;
|
++x;
|
||||||
if(*(buffer + x) == '<') {
|
if (buffer[x] == '<') {
|
||||||
++x;
|
++x;
|
||||||
if(buffer_len >= x + 12 && !strncmp(buffer + x, "includehint", 11) &&
|
if (buffer_len >= x + 12 && !strncmp(buffer + x, "includehint", 11) &&
|
||||||
(*(buffer + x + 11) == ' ' || *(buffer + x + 11) == '>')) {
|
(buffer[x + 11] == ' ' || buffer[x + 11] == '>')) {
|
||||||
for(x += 11; *(buffer + x) != '>'; ++x) ;
|
for (x += 11; buffer[x] != '>'; ++x) {} // skip
|
||||||
int inc_len = 0;
|
int inc_len = 0;
|
||||||
for(x += 1 ; *(buffer + x + inc_len) != '<'; ++inc_len) ;
|
for (x += 1 ; buffer[x + inc_len] != '<'; ++inc_len) {} // skip
|
||||||
*(buffer + x + inc_len) = '\0';
|
buffer[x + inc_len] = '\0';
|
||||||
inc = buffer + x;
|
inc = buffer + x;
|
||||||
} else if(buffer_len >= x + 13 && !strncmp(buffer + x, "customwidget", 12) &&
|
} else if (buffer_len >= x + 13 && !strncmp(buffer + x, "customwidget", 12) &&
|
||||||
(*(buffer + x + 12) == ' ' || *(buffer + x + 12) == '>')) {
|
(buffer[x + 12] == ' ' || buffer[x + 12] == '>')) {
|
||||||
for(x += 13; *(buffer + x) != '>'; ++x) ; //skip up to >
|
for (x += 13; buffer[x] != '>'; ++x) {} // skip up to >
|
||||||
while(x < buffer_len) {
|
while(x < buffer_len) {
|
||||||
for(x++; *(buffer + x) != '<'; ++x) ; //skip up to <
|
for (x++; buffer[x] != '<'; ++x) {} // skip up to <
|
||||||
x++;
|
x++;
|
||||||
if(buffer_len >= x + 7 && !strncmp(buffer+x, "header", 6) &&
|
if(buffer_len >= x + 7 && !strncmp(buffer+x, "header", 6) &&
|
||||||
(*(buffer + x + 6) == ' ' || *(buffer + x + 6) == '>')) {
|
(buffer[x + 6] == ' ' || buffer[x + 6] == '>')) {
|
||||||
for(x += 7; *(buffer + x) != '>'; ++x) ; //skip up to >
|
for (x += 7; buffer[x] != '>'; ++x) {} // skip up to >
|
||||||
int inc_len = 0;
|
int inc_len = 0;
|
||||||
for(x += 1 ; *(buffer + x + inc_len) != '<'; ++inc_len) ;
|
for (x += 1 ; buffer[x + inc_len] != '<'; ++inc_len) {} // skip
|
||||||
*(buffer + x + inc_len) = '\0';
|
buffer[x + inc_len] = '\0';
|
||||||
inc = buffer + x;
|
inc = buffer + x;
|
||||||
break;
|
break;
|
||||||
} else if(buffer_len >= x + 14 && !strncmp(buffer+x, "/customwidget", 13) &&
|
} else if(buffer_len >= x + 14 && !strncmp(buffer+x, "/customwidget", 13) &&
|
||||||
(*(buffer + x + 13) == ' ' || *(buffer + x + 13) == '>')) {
|
(buffer[x + 13] == ' ' || buffer[x + 13] == '>')) {
|
||||||
x += 14;
|
x += 14;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(buffer_len >= x + 8 && !strncmp(buffer + x, "include", 7) &&
|
} else if(buffer_len >= x + 8 && !strncmp(buffer + x, "include", 7) &&
|
||||||
(*(buffer + x + 7) == ' ' || *(buffer + x + 7) == '>')) {
|
(buffer[x + 7] == ' ' || buffer[x + 7] == '>')) {
|
||||||
for(x += 8; *(buffer + x) != '>'; ++x) {
|
for (x += 8; buffer[x] != '>'; ++x) {
|
||||||
if(buffer_len >= x + 9 && *(buffer + x) == 'i' &&
|
if (buffer_len >= x + 9 && buffer[x] == 'i' &&
|
||||||
!strncmp(buffer + x, "impldecl", 8)) {
|
!strncmp(buffer + x, "impldecl", 8)) {
|
||||||
for(x += 8; *(buffer + x) != '='; ++x) ;
|
for (x += 8; buffer[x] != '='; ++x) {} // skip
|
||||||
if(*(buffer + x) != '=')
|
if (buffer[x] != '=')
|
||||||
continue;
|
continue;
|
||||||
for(++x; *(buffer+x) == '\t' || *(buffer+x) == ' '; ++x) ;
|
for (++x; buffer[x] == '\t' || buffer[x] == ' '; ++x) {} // skip
|
||||||
char quote = 0;
|
char quote = 0;
|
||||||
if(*(buffer+x) == '\'' || *(buffer+x) == '"') {
|
if (buffer[x] == '\'' || buffer[x] == '"') {
|
||||||
quote = *(buffer + x);
|
quote = buffer[x];
|
||||||
++x;
|
++x;
|
||||||
}
|
}
|
||||||
int val_len;
|
int val_len;
|
||||||
for(val_len = 0; true; ++val_len) {
|
for(val_len = 0; true; ++val_len) {
|
||||||
if(quote) {
|
if(quote) {
|
||||||
if(*(buffer+x+val_len) == quote)
|
if (buffer[x + val_len] == quote)
|
||||||
break;
|
break;
|
||||||
} else if(*(buffer + x + val_len) == '>' ||
|
} else if (buffer[x + val_len] == '>' ||
|
||||||
*(buffer + x + val_len) == ' ') {
|
buffer[x + val_len] == ' ') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//? char saved = *(buffer + x + val_len);
|
//? char saved = buffer[x + val_len];
|
||||||
*(buffer + x + val_len) = '\0';
|
buffer[x + val_len] = '\0';
|
||||||
if(!strcmp(buffer+x, "in implementation")) {
|
if(!strcmp(buffer+x, "in implementation")) {
|
||||||
//### do this
|
//### do this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int inc_len = 0;
|
int inc_len = 0;
|
||||||
for(x += 1 ; *(buffer + x + inc_len) != '<'; ++inc_len) ;
|
for (x += 1 ; buffer[x + inc_len] != '<'; ++inc_len) {} // skip
|
||||||
*(buffer + x + inc_len) = '\0';
|
buffer[x + inc_len] = '\0';
|
||||||
inc = buffer + x;
|
inc = buffer + x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//read past new line now..
|
//read past new line now..
|
||||||
for(; x < buffer_len && !qmake_endOfLine(*(buffer + x)); ++x) ;
|
for (; x < buffer_len && !qmake_endOfLine(buffer[x]); ++x) {} // skip
|
||||||
++line_count;
|
++line_count;
|
||||||
} else if(file->type == QMakeSourceFileInfo::TYPE_QRC) {
|
} else if(file->type == QMakeSourceFileInfo::TYPE_QRC) {
|
||||||
} else if(file->type == QMakeSourceFileInfo::TYPE_C) {
|
} else if(file->type == QMakeSourceFileInfo::TYPE_C) {
|
||||||
for(int beginning=1; x < buffer_len; ++x) {
|
for(int beginning=1; x < buffer_len; ++x) {
|
||||||
// whitespace comments and line-endings
|
// Seek code or directive, skipping comments and space:
|
||||||
for(; x < buffer_len; ++x) {
|
for(; x < buffer_len; ++x) {
|
||||||
if(*(buffer+x) == ' ' || *(buffer+x) == '\t') {
|
if (buffer[x] == ' ' || buffer[x] == '\t') {
|
||||||
// keep going
|
// keep going
|
||||||
} else if(*(buffer+x) == '/') {
|
} else if (buffer[x] == '/') {
|
||||||
++x;
|
++x;
|
||||||
if(buffer_len >= x) {
|
if(buffer_len >= x) {
|
||||||
if(*(buffer+x) == '/') { //c++ style comment
|
if (buffer[x] == '/') { // C++-style comment
|
||||||
for(; x < buffer_len && !qmake_endOfLine(*(buffer + x)); ++x) ;
|
for (; x < buffer_len && !qmake_endOfLine(buffer[x]); ++x) {} // skip
|
||||||
beginning = 1;
|
beginning = 1;
|
||||||
} else if(*(buffer+x) == '*') { //c style comment
|
} else if (buffer[x] == '*') { // C-style comment
|
||||||
for(++x; x < buffer_len; ++x) {
|
for(++x; x < buffer_len; ++x) {
|
||||||
if(*(buffer+x) == '*') {
|
if (buffer[x] == '*') {
|
||||||
if(x+1 < buffer_len && *(buffer + (x+1)) == '/') {
|
if (x + 1 < buffer_len && buffer[x + 1] == '/') {
|
||||||
++x;
|
++x;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if(qmake_endOfLine(*(buffer+x))) {
|
} else if (qmake_endOfLine(buffer[x])) {
|
||||||
++line_count;
|
++line_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(qmake_endOfLine(*(buffer+x))) {
|
} else if (qmake_endOfLine(buffer[x])) {
|
||||||
++line_count;
|
++line_count;
|
||||||
beginning = 1;
|
beginning = 1;
|
||||||
} else {
|
} else {
|
||||||
@ -540,19 +540,19 @@ bool QMakeSourceFileInfo::findDeps(SourceFile *file)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
// preprocessor directive
|
// preprocessor directive
|
||||||
if(beginning && *(buffer+x) == '#')
|
if (beginning && buffer[x] == '#')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// quoted strings
|
// quoted strings
|
||||||
if(*(buffer+x) == '\'' || *(buffer+x) == '"') {
|
if (buffer[x] == '\'' || buffer[x] == '"') {
|
||||||
const char term = *(buffer+(x++));
|
const char term = buffer[x++];
|
||||||
for(; x < buffer_len; ++x) {
|
for(; x < buffer_len; ++x) {
|
||||||
if(*(buffer+x) == term) {
|
if (buffer[x] == term) {
|
||||||
++x;
|
++x;
|
||||||
break;
|
break;
|
||||||
} else if(*(buffer+x) == '\\') {
|
} else if (buffer[x] == '\\') {
|
||||||
++x;
|
++x;
|
||||||
} else if(qmake_endOfLine(*(buffer+x))) {
|
} else if (qmake_endOfLine(buffer[x])) {
|
||||||
++line_count;
|
++line_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -565,20 +565,20 @@ bool QMakeSourceFileInfo::findDeps(SourceFile *file)
|
|||||||
//got a preprocessor symbol
|
//got a preprocessor symbol
|
||||||
++x;
|
++x;
|
||||||
while(x < buffer_len) {
|
while(x < buffer_len) {
|
||||||
if(*(buffer+x) != ' ' && *(buffer+x) != '\t')
|
if (buffer[x] != ' ' && buffer[x] != '\t')
|
||||||
break;
|
break;
|
||||||
++x;
|
++x;
|
||||||
}
|
}
|
||||||
|
|
||||||
int keyword_len = 0;
|
int keyword_len = 0;
|
||||||
const char *keyword = buffer+x;
|
const char *const keyword = buffer + x;
|
||||||
while(x+keyword_len < buffer_len) {
|
while(x+keyword_len < buffer_len) {
|
||||||
if ((*(buffer+x+keyword_len) < 'a' || *(buffer+x+keyword_len) > 'z')) {
|
if (buffer[x + keyword_len] < 'a' || buffer[x + keyword_len] > 'z') {
|
||||||
for(x+=keyword_len; //skip spaces after keyword
|
for (x += keyword_len;
|
||||||
x < buffer_len && (*(buffer+x) == ' ' || *(buffer+x) == '\t');
|
x < buffer_len && (buffer[x] == ' ' || buffer[x] == '\t');
|
||||||
x++) ;
|
x++) {} // skip spaces after keyword
|
||||||
break;
|
break;
|
||||||
} else if(qmake_endOfLine(*(buffer+x+keyword_len))) {
|
} else if (qmake_endOfLine(buffer[x + keyword_len])) {
|
||||||
x += keyword_len-1;
|
x += keyword_len-1;
|
||||||
keyword_len = 0;
|
keyword_len = 0;
|
||||||
break;
|
break;
|
||||||
@ -588,7 +588,7 @@ bool QMakeSourceFileInfo::findDeps(SourceFile *file)
|
|||||||
|
|
||||||
if((keyword_len == 7 && !strncmp(keyword, "include", 7)) // C & Obj-C
|
if((keyword_len == 7 && !strncmp(keyword, "include", 7)) // C & Obj-C
|
||||||
|| (keyword_len == 6 && !strncmp(keyword, "import", 6))) { // Obj-C
|
|| (keyword_len == 6 && !strncmp(keyword, "import", 6))) { // Obj-C
|
||||||
char term = *(buffer + x);
|
char term = buffer[x];
|
||||||
if(term == '<') {
|
if(term == '<') {
|
||||||
try_local = false;
|
try_local = false;
|
||||||
term = '>';
|
term = '>';
|
||||||
@ -598,19 +598,21 @@ bool QMakeSourceFileInfo::findDeps(SourceFile *file)
|
|||||||
x++;
|
x++;
|
||||||
|
|
||||||
int inc_len;
|
int inc_len;
|
||||||
for(inc_len = 0; *(buffer + x + inc_len) != term && !qmake_endOfLine(*(buffer + x + inc_len)); ++inc_len) ;
|
for (inc_len = 0;
|
||||||
*(buffer + x + inc_len) = '\0';
|
buffer[x + inc_len] != term && !qmake_endOfLine(buffer[x + inc_len]);
|
||||||
|
++inc_len) {} // skip until end of include name
|
||||||
|
buffer[x + inc_len] = '\0';
|
||||||
inc = buffer + x;
|
inc = buffer + x;
|
||||||
x += inc_len;
|
x += inc_len;
|
||||||
} else if(*(buffer+x) == '\'' || *(buffer+x) == '"') {
|
} else if (buffer[x] == '\'' || buffer[x] == '"') {
|
||||||
const char term = *(buffer+(x++));
|
const char term = buffer[x++];
|
||||||
while(x < buffer_len) {
|
while(x < buffer_len) {
|
||||||
if(*(buffer+x) == term)
|
if (buffer[x] == term)
|
||||||
break;
|
break;
|
||||||
if(*(buffer+x) == '\\') {
|
if (buffer[x] == '\\') {
|
||||||
x+=2;
|
x+=2;
|
||||||
} else {
|
} else {
|
||||||
if(qmake_endOfLine(*(buffer+x)))
|
if (qmake_endOfLine(buffer[x]))
|
||||||
++line_count;
|
++line_count;
|
||||||
++x;
|
++x;
|
||||||
}
|
}
|
||||||
@ -686,6 +688,13 @@ bool QMakeSourceFileInfo::findDeps(SourceFile *file)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isCWordChar(char c) {
|
||||||
|
return c == '_'
|
||||||
|
|| (c >= 'a' && c <= 'z')
|
||||||
|
|| (c >= 'A' && c <= 'Z')
|
||||||
|
|| (c >= '0' && c <= '9');
|
||||||
|
}
|
||||||
|
|
||||||
bool QMakeSourceFileInfo::findMocs(SourceFile *file)
|
bool QMakeSourceFileInfo::findMocs(SourceFile *file)
|
||||||
{
|
{
|
||||||
if(file->moc_checked)
|
if(file->moc_checked)
|
||||||
@ -723,14 +732,14 @@ bool QMakeSourceFileInfo::findMocs(SourceFile *file)
|
|||||||
/* qmake ignore Q_GADGET */
|
/* qmake ignore Q_GADGET */
|
||||||
/* qmake ignore Q_OBJECT */
|
/* qmake ignore Q_OBJECT */
|
||||||
for(int x = 0; x < buffer_len; x++) {
|
for(int x = 0; x < buffer_len; x++) {
|
||||||
if(*(buffer + x) == '/') {
|
if (buffer[x] == '/') {
|
||||||
++x;
|
++x;
|
||||||
if(buffer_len >= x) {
|
if(buffer_len >= x) {
|
||||||
if(*(buffer + x) == '/') { //c++ style comment
|
if (buffer[x] == '/') { // C++-style comment
|
||||||
for(;x < buffer_len && !qmake_endOfLine(*(buffer + x)); ++x) ;
|
for (; x < buffer_len && !qmake_endOfLine(buffer[x]); ++x) {} // skip
|
||||||
} else if(*(buffer + x) == '*') { //c style comment
|
} else if (buffer[x] == '*') { // C-style comment
|
||||||
for(++x; x < buffer_len; ++x) {
|
for(++x; x < buffer_len; ++x) {
|
||||||
if(*(buffer + x) == 't' || *(buffer + x) == 'q') { //ignore
|
if (buffer[x] == 't' || buffer[x] == 'q') { // ignore
|
||||||
if(buffer_len >= (x + 20) &&
|
if(buffer_len >= (x + 20) &&
|
||||||
!strncmp(buffer + x + 1, "make ignore Q_OBJECT", 20)) {
|
!strncmp(buffer + x + 1, "make ignore Q_OBJECT", 20)) {
|
||||||
debug_msg(2, "Mocgen: %s:%d Found \"qmake ignore Q_OBJECT\"",
|
debug_msg(2, "Mocgen: %s:%d Found \"qmake ignore Q_OBJECT\"",
|
||||||
@ -744,38 +753,35 @@ bool QMakeSourceFileInfo::findMocs(SourceFile *file)
|
|||||||
x += 20;
|
x += 20;
|
||||||
ignore_qgadget = true;
|
ignore_qgadget = true;
|
||||||
}
|
}
|
||||||
} else if(*(buffer + x) == '*') {
|
} else if (buffer[x] == '*') {
|
||||||
if(buffer_len >= (x+1) && *(buffer + (x+1)) == '/') {
|
if (buffer_len >= x + 1 && buffer[x + 1] == '/') {
|
||||||
++x;
|
++x;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if(Option::debug_level && qmake_endOfLine(*(buffer + x))) {
|
} else if (Option::debug_level && qmake_endOfLine(buffer[x])) {
|
||||||
++line_count;
|
++line_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(*(buffer+x) == '\'' || *(buffer+x) == '"') {
|
} else if (buffer[x] == '\'' || buffer[x] == '"') {
|
||||||
const char term = *(buffer+(x++));
|
const char term = buffer[x++];
|
||||||
while(x < buffer_len) {
|
while(x < buffer_len) {
|
||||||
if(*(buffer+x) == term)
|
if (buffer[x] == term)
|
||||||
break;
|
break;
|
||||||
if(*(buffer+x) == '\\') {
|
if (buffer[x] == '\\') {
|
||||||
x+=2;
|
x+=2;
|
||||||
} else {
|
} else {
|
||||||
if(qmake_endOfLine(*(buffer+x)))
|
if (qmake_endOfLine(buffer[x]))
|
||||||
++line_count;
|
++line_count;
|
||||||
++x;
|
++x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(Option::debug_level && qmake_endOfLine(*(buffer+x)))
|
if (Option::debug_level && qmake_endOfLine(buffer[x]))
|
||||||
++line_count;
|
++line_count;
|
||||||
if (buffer_len > x + 2 && buffer[x + 1] == 'Q' && buffer[x + 2] == '_' &&
|
if (buffer_len > x + 2 && buffer[x + 1] == 'Q' &&
|
||||||
*(buffer + x) != '_' &&
|
buffer[x + 2] == '_' && !isCWordChar(buffer[x])) {
|
||||||
(*(buffer + x) < 'a' || *(buffer + x) > 'z') &&
|
|
||||||
(*(buffer + x) < 'A' || *(buffer + x) > 'Z') &&
|
|
||||||
(*(buffer + x) < '0' || *(buffer + x) > '9')) {
|
|
||||||
++x;
|
++x;
|
||||||
int match = 0;
|
int match = 0;
|
||||||
static const char *interesting[] = { "OBJECT", "GADGET" };
|
static const char *interesting[] = { "OBJECT", "GADGET" };
|
||||||
@ -784,8 +790,8 @@ bool QMakeSourceFileInfo::findMocs(SourceFile *file)
|
|||||||
continue;
|
continue;
|
||||||
else if(interest == 1 && ignore_qgadget)
|
else if(interest == 1 && ignore_qgadget)
|
||||||
continue;
|
continue;
|
||||||
for(m1 = 0, m2 = 0; *(interesting[interest]+m1); ++m1) {
|
for (m1 = 0, m2 = 0; interesting[interest][m1]; ++m1) {
|
||||||
if(*(interesting[interest]+m1) != *(buffer+x+2+m1)) {
|
if (interesting[interest][m1] != buffer[x + 2 + m1]) {
|
||||||
m2 = -1;
|
m2 = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -796,14 +802,12 @@ bool QMakeSourceFileInfo::findMocs(SourceFile *file)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(match && *(buffer+x+match) != '_' &&
|
if (match && !isCWordChar(buffer[x + match])) {
|
||||||
(*(buffer+x+match) < 'a' || *(buffer+x+match) > 'z') &&
|
if (Option::debug_level) {
|
||||||
(*(buffer+x+match) < 'A' || *(buffer+x+match) > 'Z') &&
|
buffer[x + match] = '\0';
|
||||||
(*(buffer+x+match) < '0' || *(buffer+x+match) > '9')) {
|
debug_msg(2, "Mocgen: %s:%d Found MOC symbol %s",
|
||||||
if(Option::debug_level) {
|
file->file.real().toLatin1().constData(),
|
||||||
*(buffer+x+match) = '\0';
|
line_count, buffer + x);
|
||||||
debug_msg(2, "Mocgen: %s:%d Found MOC symbol %s", file->file.real().toLatin1().constData(),
|
|
||||||
line_count, buffer+x);
|
|
||||||
}
|
}
|
||||||
file->mocable = true;
|
file->mocable = true;
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user