diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2011-01-25 12:17:08 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2011-01-25 19:29:07 (GMT) |
commit | 1f28efe4125397f2a61af421dbeb9f6954ca2a9c (patch) | |
tree | 53e2480bd59f6ed6f056b7ff57d41cc891ff0963 /qmake/project.cpp | |
parent | 9e0f4a89564997856c784aed6611b91a9f9f184a (diff) | |
download | Qt-1f28efe4125397f2a61af421dbeb9f6954ca2a9c.zip Qt-1f28efe4125397f2a61af421dbeb9f6954ca2a9c.tar.gz Qt-1f28efe4125397f2a61af421dbeb9f6954ca2a9c.tar.bz2 |
slightly reorganize split_arg_list()
cut down code duplication
Reviewed-by: mariusSO
Diffstat (limited to 'qmake/project.cpp')
-rw-r--r-- | qmake/project.cpp | 59 |
1 files changed, 28 insertions, 31 deletions
diff --git a/qmake/project.cpp b/qmake/project.cpp index 4053b3d..d690770 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -241,41 +241,38 @@ static QStringList split_arg_list(QString params) 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); - 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; + 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 && params_data[x-1].unicode() == SPACE) + --x; + QString mid(params_data+last, x-last); + args << mid; + return args; + } + ushort unicode = params_data[x].unicode(); + 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; + break; + } } } - return args; } static QStringList split_value_list(const QString &vals) |