diff options
Diffstat (limited to 'qmake/project.cpp')
-rw-r--r-- | qmake/project.cpp | 85 |
1 files changed, 41 insertions, 44 deletions
diff --git a/qmake/project.cpp b/qmake/project.cpp index 177ab2f..d4fa786 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -87,7 +87,7 @@ QMap<QString, ExpandFunc> qmake_expandFunctions() static QMap<QString, ExpandFunc> *qmake_expand_functions = 0; if(!qmake_expand_functions) { qmake_expand_functions = new QMap<QString, ExpandFunc>; - qmakeAddCacheClear(qmakeDeleteCacheClear_QMapStringInt, (void**)&qmake_expand_functions); + qmakeAddCacheClear(qmakeDeleteCacheClear<QMap<QString, ExpandFunc> >, (void**)&qmake_expand_functions); qmake_expand_functions->insert("member", E_MEMBER); qmake_expand_functions->insert("first", E_FIRST); qmake_expand_functions->insert("last", E_LAST); @@ -237,59 +237,56 @@ static QStringList split_arg_list(const QString ¶ms) const ushort RPAREN = ')'; const ushort SINGLEQUOTE = '\''; const ushort DOUBLEQUOTE = '"'; + const ushort BACKSLASH = '\\'; const ushort COMMA = ','; const ushort SPACE = ' '; //const ushort TAB = '\t'; - ushort unicode; const QChar *params_data = params.data(); const int params_len = params.length(); - int last = 0; - while(last < params_len && (params_data[last].unicode() == SPACE - /*|| params_data[last].unicode() == TAB*/)) - ++last; - for(int x = last, parens = 0; x <= params_len; x++) { - unicode = params_data[x].unicode(); - if(x == params_len) { - while(x && params_data[x-1].unicode() == SPACE) - --x; - QString mid(params_data+last, x-last); - if(quote) { - if(mid[0] == quote && mid[(int)mid.length()-1] == quote) - mid = mid.mid(1, mid.length()-2); + for(int last = 0; ;) { + while(last < params_len && (params_data[last].unicode() == SPACE + /*|| params_data[last].unicode() == TAB*/)) + ++last; + for(int x = last, parens = 0; ; x++) { + if(x == params_len) { + while(x > last && params_data[x-1].unicode() == SPACE) + --x; + args << params.mid(last, x - last); + // Could do a check for unmatched parens here, but split_value_list() + // is called on all our output, so mistakes will be caught anyway. + return args; + } + ushort unicode = params_data[x].unicode(); + if(x != (int)params_len-1 && unicode == BACKSLASH && + (params_data[x+1].unicode() == SINGLEQUOTE || params_data[x+1].unicode() == DOUBLEQUOTE)) { + x++; //get that 'escape' + } else if(quote && unicode == quote) { quote = 0; + } else if(!quote && (unicode == SINGLEQUOTE || unicode == DOUBLEQUOTE)) { + quote = unicode; + } else if(unicode == RPAREN) { + --parens; + } else if(unicode == LPAREN) { + ++parens; + } + if(!parens && !quote && unicode == COMMA) { + int prev = last; + last = x+1; + while(x > prev && params_data[x-1].unicode() == SPACE) + --x; + args << params.mid(prev, x - prev); + break; } - args << mid; - break; - } - if(unicode == LPAREN) { - --parens; - } else if(unicode == RPAREN) { - ++parens; - } else if(quote && unicode == quote) { - quote = 0; - } else if(!quote && (unicode == SINGLEQUOTE || unicode == DOUBLEQUOTE)) { - quote = unicode; - } - if(!parens && !quote && unicode == COMMA) { - QString mid = params.mid(last, x - last).trimmed(); - args << mid; - last = x+1; - while(last < params_len && (params_data[last].unicode() == SPACE - /*|| params_data[last].unicode() == TAB*/)) - ++last; } } - // Could do a check for unmatched parens here, but split_value_list() - // is called on all our output, so mistakes will be caught anyway. - return args; } static QStringList split_value_list(const QString &vals) { QString build; QStringList ret; - QStack<char> quote; + ushort quote = 0; int parens = 0; const ushort LPAREN = '('; @@ -306,17 +303,17 @@ static QStringList split_value_list(const QString &vals) if(x != (int)vals_len-1 && unicode == BACKSLASH && (vals_data[x+1].unicode() == SINGLEQUOTE || vals_data[x+1].unicode() == DOUBLEQUOTE)) { build += vals_data[x++]; //get that 'escape' - } else if(!quote.isEmpty() && unicode == quote.top()) { - quote.pop(); - } else if(unicode == SINGLEQUOTE || unicode == DOUBLEQUOTE) { - quote.push(unicode); + } else if(quote && unicode == quote) { + quote = 0; + } else if(!quote && (unicode == SINGLEQUOTE || unicode == DOUBLEQUOTE)) { + quote = unicode; } else if(unicode == RPAREN) { --parens; } else if(unicode == LPAREN) { ++parens; } - if(!parens && quote.isEmpty() && (vals_data[x] == Option::field_sep)) { + if(!parens && !quote && (vals_data[x] == Option::field_sep)) { ret << build; build.clear(); } else { @@ -1655,7 +1652,7 @@ QMakeProject::doProjectInclude(QString file, uchar flags, QMap<QString, QStringL static QStringList *feature_roots = 0; if(!feature_roots) { feature_roots = new QStringList(qmake_feature_paths(prop)); - qmakeAddCacheClear(qmakeDeleteCacheClear_QStringList, (void**)&feature_roots); + qmakeAddCacheClear(qmakeDeleteCacheClear<QStringList>, (void**)&feature_roots); } debug_msg(2, "Looking for feature '%s' in (%s)", file.toLatin1().constData(), feature_roots->join("::").toLatin1().constData()); |