From 7052bcc0c6da28f9554f560fef36a5ae3d1e26fd Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 24 Jan 2011 20:28:56 +0100 Subject: remove the completely insane quote nesting from split_value_list() "foo 'bar "whee"' baz" would be actually treated like nested quotes. of course, this makes utterly no sense, as both the layers below and above couldn't do anything with that. and it would break actually useful things like quoting an apostrophe. Reviewed-by: mariusSO --- qmake/project.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/qmake/project.cpp b/qmake/project.cpp index f314b8b..cbe3a94 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -287,7 +287,7 @@ static QStringList split_value_list(const QString &vals) { QString build; QStringList ret; - QStack quote; + ushort quote = 0; const ushort LPAREN = '('; const ushort RPAREN = ')'; @@ -303,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 { -- cgit v0.12 From 9e0f4a89564997856c784aed6611b91a9f9f184a Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 24 Jan 2011 20:44:22 +0100 Subject: remove the somewhat bizarre unquoting of the last argument in split_arg_list() the last argument would be unquoted, but only if currently in a quote. that means that an invalid construct like "foo"" would be reduced to another invalid construct foo". this doesn't sound overly useful ... Reviewed-by: mariusSO --- qmake/project.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/qmake/project.cpp b/qmake/project.cpp index cbe3a94..4053b3d 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -254,11 +254,6 @@ static QStringList split_arg_list(QString params) 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); - quote = 0; - } args << mid; break; } -- cgit v0.12 From 1f28efe4125397f2a61af421dbeb9f6954ca2a9c Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 25 Jan 2011 13:17:08 +0100 Subject: slightly reorganize split_arg_list() cut down code duplication Reviewed-by: mariusSO --- qmake/project.cpp | 59 ++++++++++++++++++++++++++----------------------------- 1 file 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) -- cgit v0.12 From 005e39a2aab88d47044fa2108a6d04bd490b169e Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 25 Jan 2011 13:23:24 +0100 Subject: cleanup split_arg_list() some more unify the code paths for last and intermediate arguments. as a side effect, this should be somewhat more efficient. Reviewed-by: mariusSO --- qmake/project.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/qmake/project.cpp b/qmake/project.cpp index d690770..7951d11 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -249,10 +249,9 @@ static QStringList split_arg_list(QString params) ++last; for(int x = last, parens = 0; ; x++) { if(x == params_len) { - while(x && params_data[x-1].unicode() == SPACE) + while(x > last && params_data[x-1].unicode() == SPACE) --x; - QString mid(params_data+last, x-last); - args << mid; + args << params.mid(last, x - last); return args; } ushort unicode = params_data[x].unicode(); @@ -266,9 +265,11 @@ static QStringList split_arg_list(QString params) quote = unicode; } if(!parens && !quote && unicode == COMMA) { - QString mid = params.mid(last, x - last).trimmed(); - args << mid; + int prev = last; last = x+1; + while(x > prev && params_data[x-1].unicode() == SPACE) + --x; + args << params.mid(prev, x - prev); break; } } -- cgit v0.12 From 648dbc62e9c4e3fc15613c86bbf3c33029d56366 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 25 Jan 2011 13:59:20 +0100 Subject: interpret backslash escaping of quotes in split_arg_list() split_value_list() interprets them, too, but this is useless if the higher layer doesn't and is thus confused by unmatched quotes. note the top-level parsing layer doesn't support escapes, but that's ok, because there function calls are "isolated" by non-escapable parenthesis counting (and the RHS of assignments is not subject to any parsing at all). Reviewed-by: mariusSO --- qmake/project.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/qmake/project.cpp b/qmake/project.cpp index 7951d11..88d5962 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -237,6 +237,7 @@ static QStringList split_arg_list(QString params) const ushort RPAREN = ')'; const ushort SINGLEQUOTE = '\''; const ushort DOUBLEQUOTE = '"'; + const ushort BACKSLASH = '\\'; const ushort COMMA = ','; const ushort SPACE = ' '; //const ushort TAB = '\t'; @@ -255,14 +256,17 @@ static QStringList split_arg_list(QString params) return args; } ushort unicode = params_data[x].unicode(); - if(unicode == LPAREN) { - --parens; - } else if(unicode == RPAREN) { - ++parens; + 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; -- cgit v0.12 From e881b19ba3f2f4bfda460e1a043f461fb0517d70 Mon Sep 17 00:00:00 2001 From: Sergey Belyashov Date: Tue, 25 Jan 2011 20:41:07 +0100 Subject: Added scrollbars support to the Linguist form preview. Merge-request: 1030 Reviewed-by: Oswald Buddenhagen --- tools/linguist/linguist/formpreviewview.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/linguist/linguist/formpreviewview.cpp b/tools/linguist/linguist/formpreviewview.cpp index d46cf76..a2a6002 100644 --- a/tools/linguist/linguist/formpreviewview.cpp +++ b/tools/linguist/linguist/formpreviewview.cpp @@ -463,6 +463,8 @@ FormPreviewView::FormPreviewView(QWidget *parent, MultiDataModel *dataModel) m_mdiArea = new QMdiArea(this); m_mdiArea->addSubWindow(m_mdiSubWindow); setCentralWidget(m_mdiArea); + m_mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); + m_mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); } void FormPreviewView::setSourceContext(int model, MessageItem *messageItem) -- cgit v0.12