From 2b4c35d66eb4f787b869939bef63a5d7246ffa62 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Fri, 6 Nov 2009 13:21:02 +0100 Subject: tst_networkselftest: Also check for SSL support We want all our auto test machines to have OpenSSL. Reviewed-by: Peter Hartmann --- tests/auto/networkselftest/tst_networkselftest.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp index a09d998..f13bcad 100644 --- a/tests/auto/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/networkselftest/tst_networkselftest.cpp @@ -80,6 +80,9 @@ private slots: void httpProxyNtlmAuth(); void socks5Proxy(); void socks5ProxyAuth(); + + // ssl supported test + void supportsSsl(); }; class Chat @@ -717,5 +720,14 @@ void tst_NetworkSelfTest::socks5ProxyAuth() ); } +void tst_NetworkSelfTest::supportsSsl() +{ +#ifdef QT_NO_OPENSSL + QFAIL("SSL not compiled in"); +#else + QVERIFY(QSslSocket::supportsSsl()); +#endif +} + QTEST_MAIN(tst_NetworkSelfTest) #include "tst_networkselftest.moc" -- cgit v0.12 From 6cc5e911a3afa2fab5b44d113a9bf2fa2720ab79 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Fri, 6 Nov 2009 14:37:38 +0100 Subject: QNAM: Do not emit uploadProgress() when reply was aborted Reviewed-by: Peter Hartmann --- src/network/access/qnetworkaccessbackend.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/network/access/qnetworkaccessbackend.cpp b/src/network/access/qnetworkaccessbackend.cpp index 1a92868..3e2db7a 100644 --- a/src/network/access/qnetworkaccessbackend.cpp +++ b/src/network/access/qnetworkaccessbackend.cpp @@ -141,6 +141,8 @@ QNonContiguousByteDevice* QNetworkAccessBackend::createUploadByteDevice() // and the special backends need to access this. void QNetworkAccessBackend::emitReplyUploadProgress(qint64 bytesSent, qint64 bytesTotal) { + if (reply->isFinished()) + return; reply->emitUploadProgress(bytesSent, bytesTotal); } -- cgit v0.12 From 7623cf03a68d5c071b06cf50d23e393a37265d95 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 8 Nov 2009 17:35:00 +0100 Subject: Autotest: prevent race-condition from causing a test failure. The test requires receiving the NameOwnerChanged signal from the bus before the voidSignal we emit ourselves. For whatever reason, the bus apparently delays the emission of that signal, which could cause our signal to be received first. We should actually wait for the signal, but a simple processEvents is enough in my tests. --- tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp b/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp index 91050f5..a2c4758 100644 --- a/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp +++ b/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp @@ -133,7 +133,7 @@ tst_QDBusAbstractInterface::tst_QDBusAbstractInterface() void tst_QDBusAbstractInterface::initTestCase() { // enable debugging temporarily: - putenv("QDBUS_DEBUG=1"); + //putenv("QDBUS_DEBUG=1"); // register the object QDBusConnection con = QDBusConnection::sessionBus(); @@ -465,6 +465,7 @@ void tst_QDBusAbstractInterface::followSignal() QDBusConnectionInterface::DontAllowReplacement); QVERIFY(r.isValid() && r.value() == QDBusConnectionInterface::ServiceRegistered); QVERIFY(con.interface()->isServiceRegistered(serviceToFollow)); + QCoreApplication::instance()->processEvents(); // emit the signal again: emit targetObj.voidSignal(); -- cgit v0.12 From 5c05470ea96dcb25deb21a64eddffcb2d4ff6fcf Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 8 Nov 2009 17:52:52 +0100 Subject: Fix enabling of level 2 debugging in QtDBus --- src/dbus/qdbusintegrator.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index c7538c3..626d215 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -934,7 +934,8 @@ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p) rootNode(QString(QLatin1Char('/'))) { static const bool threads = q_dbus_threads_init_default(); - static const int debugging = ::isDebugging = qgetenv("QDBUS_DEBUG").toInt(); + static const int debugging = qgetenv("QDBUS_DEBUG").toInt(); + ::isDebugging = debugging; Q_UNUSED(threads) Q_UNUSED(debugging) -- cgit v0.12 From 89421331366ac1d34ff18bcd40f3e78f7fa1883e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 8 Nov 2009 17:53:05 +0100 Subject: Fix annotations added for complex types in signals. Signals are badly mishandled in QtDBus. In the spec, they are "in" arguments, but we generate "Out" annotations for them. What's worse, we were using the wrong count. QTBUG-914 is about fixing the directionality. While that task isn't fixed, at least use the right count. Task-number: QTBUG-5563 Reviewed-by: TrustMe --- src/dbus/qdbusxmlgenerator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dbus/qdbusxmlgenerator.cpp b/src/dbus/qdbusxmlgenerator.cpp index 9870584..380b949 100644 --- a/src/dbus/qdbusxmlgenerator.cpp +++ b/src/dbus/qdbusxmlgenerator.cpp @@ -203,7 +203,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method const char *typeName = QVariant::typeToName( QVariant::Type(types.at(j)) ); xml += QString::fromLatin1(" \n") .arg(isOutput ? QLatin1String("Out") : QLatin1String("In")) - .arg(isOutput ? j - inputCount : j - 1) + .arg(isOutput && !isSignal ? j - inputCount : j - 1) .arg(typeNameToXml(typeName)); } } -- cgit v0.12 From 88b713cb11bdbded762c4004aae87aa9524d73cf Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 9 Nov 2009 14:49:14 +0100 Subject: QNAM HTTP Code: Also send our locale name as accept-language Inspired by merge request 2012 by Joel Nordell Reviewed-by: Peter Hartmann --- src/network/access/qhttpnetworkconnection.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 1124337..7d54908 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -194,11 +194,20 @@ void QHttpNetworkConnectionPrivate::prepareRequest(HttpMessagePair &messagePair) // some websites mandate an accept-language header and fail // if it is not sent. This is a problem with the website and - // not with us, but we work around this by setting a - // universal one always. + // not with us, but we work around this by setting + // one always. value = request.headerField("accept-language"); - if (value.isEmpty()) - request.setHeaderField("accept-language", "en,*"); + if (value.isEmpty()) { + QString systemLocale = QLocale::system().name().replace(QChar::fromAscii('_'),QChar::fromAscii('-')); + QString acceptLanguage; + if (systemLocale == QLatin1String("C")) + acceptLanguage = QString::fromAscii("en,*"); + else if (systemLocale.startsWith(QLatin1String("en-"))) + acceptLanguage = QString::fromAscii("%1,*").arg(systemLocale); + else + acceptLanguage = QString::fromAscii("%1,en,*").arg(systemLocale); + request.setHeaderField("accept-language", acceptLanguage.toAscii()); + } // set the User Agent value = request.headerField("user-agent"); -- cgit v0.12 From bbdf3d9a600acfcb6df19eb5317fcb79da79c2df Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Mon, 9 Nov 2009 15:40:18 +0100 Subject: network examples: unify the fortune server/client examples always use the first non-localhost IP address to listen/connect to, if there is one. Reviewed-by: Markus Goetz --- .../network/blockingfortuneclient/blockingclient.cpp | 17 ++++++++++++++++- examples/network/fortuneclient/client.cpp | 4 +++- examples/network/fortuneserver/server.cpp | 4 +++- examples/network/threadedfortuneserver/dialog.cpp | 4 +++- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/examples/network/blockingfortuneclient/blockingclient.cpp b/examples/network/blockingfortuneclient/blockingclient.cpp index b731f7a..a3d7c23 100644 --- a/examples/network/blockingfortuneclient/blockingclient.cpp +++ b/examples/network/blockingfortuneclient/blockingclient.cpp @@ -50,7 +50,22 @@ BlockingClient::BlockingClient(QWidget *parent) hostLabel = new QLabel(tr("&Server name:")); portLabel = new QLabel(tr("S&erver port:")); - hostLineEdit = new QLineEdit("Localhost"); + // find out which IP to connect to + QString ipAddress; + QList ipAddressesList = QNetworkInterface::allAddresses(); + // use the first non-localhost IPv4 address + for (int i = 0; i < ipAddressesList.size(); ++i) { + if (ipAddressesList.at(i) != QHostAddress::LocalHost && + ipAddressesList.at(i).toIPv4Address()) { + ipAddress = ipAddressesList.at(i).toString(); + break; + } + } + // if we did not find one, use IPv4 localhost + if (ipAddress.isEmpty()) + ipAddress = QHostAddress(QHostAddress::LocalHost).toString(); + + hostLineEdit = new QLineEdit(ipAddress); portLineEdit = new QLineEdit; portLineEdit->setValidator(new QIntValidator(1, 65535, this)); diff --git a/examples/network/fortuneclient/client.cpp b/examples/network/fortuneclient/client.cpp index ca5d40e..e043f78 100644 --- a/examples/network/fortuneclient/client.cpp +++ b/examples/network/fortuneclient/client.cpp @@ -62,8 +62,10 @@ Client::Client(QWidget *parent) // use the first non-localhost IPv4 address for (int i = 0; i < ipAddressesList.size(); ++i) { if (ipAddressesList.at(i) != QHostAddress::LocalHost && - ipAddressesList.at(i).toIPv4Address()) + ipAddressesList.at(i).toIPv4Address()) { ipAddress = ipAddressesList.at(i).toString(); + break; + } } // if we did not find one, use IPv4 localhost if (ipAddress.isEmpty()) diff --git a/examples/network/fortuneserver/server.cpp b/examples/network/fortuneserver/server.cpp index 52b7d61..06f6eeb 100644 --- a/examples/network/fortuneserver/server.cpp +++ b/examples/network/fortuneserver/server.cpp @@ -68,8 +68,10 @@ Server::Server(QWidget *parent) // use the first non-localhost IPv4 address for (int i = 0; i < ipAddressesList.size(); ++i) { if (ipAddressesList.at(i) != QHostAddress::LocalHost && - ipAddressesList.at(i).toIPv4Address()) + ipAddressesList.at(i).toIPv4Address()) { ipAddress = ipAddressesList.at(i).toString(); + break; + } } // if we did not find one, use IPv4 localhost if (ipAddress.isEmpty()) diff --git a/examples/network/threadedfortuneserver/dialog.cpp b/examples/network/threadedfortuneserver/dialog.cpp index b1ea395..d0d3fc0 100644 --- a/examples/network/threadedfortuneserver/dialog.cpp +++ b/examples/network/threadedfortuneserver/dialog.cpp @@ -67,8 +67,10 @@ Dialog::Dialog(QWidget *parent) // use the first non-localhost IPv4 address for (int i = 0; i < ipAddressesList.size(); ++i) { if (ipAddressesList.at(i) != QHostAddress::LocalHost && - ipAddressesList.at(i).toIPv4Address()) + ipAddressesList.at(i).toIPv4Address()) { ipAddress = ipAddressesList.at(i).toString(); + break; + } } // if we did not find one, use IPv4 localhost if (ipAddress.isEmpty()) -- cgit v0.12 From 8fbdbd25015a4e5544dace3a77427861f0ca89f4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 9 Nov 2009 16:10:58 +0100 Subject: Let QDBusInterface work even if the introspection failed. If the introspection failed, we won't have a meta object, meaning you cannot connect to signals or invoke methods via the slot mechanism. But you can still make calls. The isValid() functionality is preserved because there is no owner for this object. Reviewed-By: Harald Fernengel --- src/dbus/qdbusinterface.cpp | 6 ++++-- tests/auto/qdbusinterface/tst_qdbusinterface.cpp | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/dbus/qdbusinterface.cpp b/src/dbus/qdbusinterface.cpp index 74b2a44..d0a693f 100644 --- a/src/dbus/qdbusinterface.cpp +++ b/src/dbus/qdbusinterface.cpp @@ -157,7 +157,9 @@ QDBusInterfacePrivate::QDBusInterfacePrivate(const QString &serv, const QString if (!metaObject) { // creation failed, somehow - isValid = false; + // most common causes are that the service doesn't exist or doesn't support introspection + // those are not fatal errors, so we continue working + if (!lastError.isValid()) lastError = QDBusError(QDBusError::InternalError, QLatin1String("Unknown error")); } @@ -232,7 +234,7 @@ QDBusInterface::~QDBusInterface() */ const QMetaObject *QDBusInterface::metaObject() const { - return d_func()->isValid ? d_func()->metaObject : &QDBusAbstractInterface::staticMetaObject; + return d_func()->metaObject ? d_func()->metaObject : &QDBusAbstractInterface::staticMetaObject; } /*! diff --git a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp index 62d6342..bcd5bd9 100644 --- a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp +++ b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp @@ -234,6 +234,7 @@ void tst_QDBusInterface::notValid() void tst_QDBusInterface::invalidAfterServiceOwnerChanged() { + // this test is technically the same as tst_QDBusAbstractInterface::followSignal QDBusConnection conn = QDBusConnection::sessionBus(); QDBusConnectionInterface *connIface = conn.interface(); @@ -249,7 +250,7 @@ void tst_QDBusInterface::invalidAfterServiceOwnerChanged() QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); - QVERIFY(!invalidInterface.isValid()); + QVERIFY(invalidInterface.isValid()); } void tst_QDBusInterface::introspect() -- cgit v0.12 From bd47ffa5deeb2489e47d90d1110c435dc68d4f30 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 10 Nov 2009 10:16:10 +0100 Subject: QNAM HTTP Code: Start accept-language header with capital letter HTTP header names are case insensitive, but stick to what all browsers etc. use to work around buggy servers. Reviewed-by: TrustMe --- src/network/access/qhttpnetworkconnection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 7d54908..1f6a51a 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -206,7 +206,7 @@ void QHttpNetworkConnectionPrivate::prepareRequest(HttpMessagePair &messagePair) acceptLanguage = QString::fromAscii("%1,*").arg(systemLocale); else acceptLanguage = QString::fromAscii("%1,en,*").arg(systemLocale); - request.setHeaderField("accept-language", acceptLanguage.toAscii()); + request.setHeaderField("Accept-Language", acceptLanguage.toAscii()); } // set the User Agent -- cgit v0.12 From c412b5f144ea99ea70f4df291678631e13900962 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 10 Nov 2009 10:29:59 +0100 Subject: stabilize QNetworkReply autotest ioPostToHttpFromSocket was failing from time to time Reviewed-by: Markus Goetz --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 0b61dcd..446fb53 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -2619,12 +2619,7 @@ void tst_QNetworkReply::ioPostToHttpFromSocket() QSignalSpy authenticationRequiredSpy(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*))); QSignalSpy proxyAuthenticationRequiredSpy(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); -#ifdef Q_OS_SYMBIAN QTestEventLoop::instance().enterLoop(6); -#else - QTestEventLoop::instance().enterLoop(3); -#endif - disconnect(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); disconnect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), -- cgit v0.12 From 1502df3ddedc5a4365e12bce570d946744259785 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Thu, 29 Oct 2009 14:15:59 +0100 Subject: utils/qlalr generator: adapt changes to xmlstream and script files some changes were made to qxmlstream_p.h and script files directly; however, those files are generated automatically by src/corelib/xml/make-parser.sh and src/script/parser/make-parser.sh, respectively, so the generator would overwrite the manual changes to the files the next time it is run. This patch integrates those changes into the generator rather than into the files directly. Reviewed-by: Roberto Raggi Reviewed-by: Olivier Goffart --- src/corelib/xml/make-parser.sh | 2 +- src/corelib/xml/qxmlstream.g | 1 + src/corelib/xml/qxmlstream_p.h | 30 +++++++-------- src/script/parser/make-parser.sh | 53 +++++++++++++++++++++++++++ src/script/parser/qscript.g | 62 +++++++++++++++++++++---------- src/script/parser/qscriptgrammar.cpp | 16 ++++---- src/script/parser/qscriptgrammar_p.h | 39 +++++++++----------- src/script/parser/qscriptparser.cpp | 11 +++--- src/script/parser/qscriptparser_p.h | 1 + util/qlalr/cppgenerator.cpp | 71 ++++++++++++++++++++++-------------- util/qlalr/main.cpp | 4 +- util/qtscriptparser/make-parser.sh | 55 ---------------------------- 12 files changed, 188 insertions(+), 157 deletions(-) create mode 100755 src/script/parser/make-parser.sh delete mode 100644 util/qtscriptparser/make-parser.sh diff --git a/src/corelib/xml/make-parser.sh b/src/corelib/xml/make-parser.sh index 9866555..35289d2 100755 --- a/src/corelib/xml/make-parser.sh +++ b/src/corelib/xml/make-parser.sh @@ -42,7 +42,7 @@ me=$(dirname $0) mkdir -p $me/out -(cd $me/out && ../../../../util/qlalr/qlalr --troll --no-debug --no-lines ../qxmlstream.g) +(cd $me/out && ../../../../util/qlalr/qlalr --qt --no-debug --no-lines ../qxmlstream.g) for f in $me/out/*.h; do n=$(basename $f) diff --git a/src/corelib/xml/qxmlstream.g b/src/corelib/xml/qxmlstream.g index 6c0c0cf..22ba33d 100644 --- a/src/corelib/xml/qxmlstream.g +++ b/src/corelib/xml/qxmlstream.g @@ -158,6 +158,7 @@ public: if (tos + extraCapacity + 1 > cap) { cap = qMax(tos + extraCapacity + 1, cap << 1 ); data = reinterpret_cast(qRealloc(data, cap * sizeof(T))); + Q_CHECK_PTR(data); } } diff --git a/src/corelib/xml/qxmlstream_p.h b/src/corelib/xml/qxmlstream_p.h index eee3a13..253f8bd 100644 --- a/src/corelib/xml/qxmlstream_p.h +++ b/src/corelib/xml/qxmlstream_p.h @@ -1,4 +1,3 @@ -// This file was generated by qlalr - DO NOT EDIT! /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). @@ -51,6 +50,7 @@ // We mean it. // +// This file was generated by qlalr - DO NOT EDIT! #ifndef QXMLSTREAM_P_H #define QXMLSTREAM_P_H @@ -132,13 +132,13 @@ public: }; static const char *const spell []; - static const qint16 lhs []; - static const qint16 rhs []; - static const qint16 goto_default []; - static const qint16 action_default []; - static const qint16 action_index []; - static const qint16 action_info []; - static const qint16 action_check []; + static const short lhs []; + static const short rhs []; + static const short goto_default []; + static const short action_default []; + static const short action_index []; + static const short action_info []; + static const short action_check []; static inline int nt_action (int state, int nt) { @@ -169,7 +169,7 @@ const char *const QXmlStreamReader_Table::spell [] = { "EMPTY", "ANY", "PCDATA", 0, 0, 0, 0, "CDATA", "ID", "IDREF", "IDREFS", "ENTITIES", "NMTOKEN", "NMTOKENS", " #include -#include "qscriptengine.h" -#include "qscriptengine_p.h" -#include "qscriptvalueimpl_p.h" -#include "qscriptcontext_p.h" -#include "qscriptmember_p.h" -#include "qscriptobject_p.h" -#include "qscriptlexer_p.h" -#include "qscriptast_p.h" -#include "qscriptnodepool_p.h" - #define Q_SCRIPT_UPDATE_POSITION(node, startloc, endloc) do { \ node->startLine = startloc.startLine; \ node->startColumn = startloc.startColumn; \ @@ -131,8 +135,7 @@ ./ -/: -/**************************************************************************** +/:/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. @@ -140,10 +143,25 @@ ** ** This file is part of the QtScript module of the Qt Toolkit. ** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions ** contained in the Technology Preview License Agreement accompanying ** this package. -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** ** If you have questions regarding the use of this file, please contact ** Nokia at qt-info@nokia.com. ** @@ -153,10 +171,14 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ +// This file was generated by qlalr - DO NOT EDIT! + + // // W A R N I N G // ------------- diff --git a/src/script/parser/qscriptgrammar.cpp b/src/script/parser/qscriptgrammar.cpp index cbb1ab8..c7f661b 100644 --- a/src/script/parser/qscriptgrammar.cpp +++ b/src/script/parser/qscriptgrammar.cpp @@ -1,4 +1,3 @@ -// This file was generated by qlalr - DO NOT EDIT! /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). @@ -40,6 +39,7 @@ ** ****************************************************************************/ +// This file was generated by qlalr - DO NOT EDIT! #include "qscriptgrammar_p.h" QT_BEGIN_NAMESPACE @@ -68,7 +68,7 @@ const char *const QScriptGrammar::spell [] = { #endif // QLALR_NO_QSCRIPTGRAMMAR_DEBUG_INFO }; -const int QScriptGrammar::lhs [] = { +const short QScriptGrammar::lhs [] = { 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 87, 87, 92, 92, 86, 86, 89, 89, 93, 93, 93, 93, 94, 94, 94, @@ -97,7 +97,7 @@ const int QScriptGrammar::lhs [] = { 163, 97, 167, 167, 164, 164, 165, 165, 168, 84, 169, 169, 170, 170, 166, 166, 88, 88, 171}; -const int QScriptGrammar:: rhs[] = { +const short QScriptGrammar::rhs [] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 5, 3, 4, 3, 2, 4, 1, 2, 0, 1, 3, 5, 1, 1, 1, 1, 1, 1, 1, @@ -429,7 +429,7 @@ const int QScriptGrammar::rule_index [] = { 803, 805, 808, 810, 812, 813, 815, 816, 818}; #endif // QLALR_NO_QSCRIPTGRAMMAR_DEBUG_INFO -const int QScriptGrammar::action_default [] = { +const short QScriptGrammar::action_default [] = { 0, 98, 165, 129, 137, 133, 173, 180, 77, 149, 179, 187, 175, 125, 0, 176, 264, 62, 177, 178, 183, 78, 141, 145, 66, 95, 76, 81, 61, 0, @@ -478,7 +478,7 @@ const int QScriptGrammar::action_default [] = { 15, 88, 86, 90, 87, 85, 89, 204, 197, 0, 205, 201, 0, 203, 193, 0, 194, 198}; -const int QScriptGrammar::goto_default [] = { +const short QScriptGrammar::goto_default [] = { 29, 28, 439, 437, 113, 112, 14, 2, 438, 111, 114, 194, 24, 17, 190, 26, 8, 201, 21, 27, 77, 25, 1, 32, 30, 270, 13, 264, 3, 260, @@ -489,7 +489,7 @@ const int QScriptGrammar::goto_default [] = { 460, 324, 395, 399, 402, 398, 397, 417, 418, 16, 100, 107, 96, 99, 106, 108, 33, 0}; -const int QScriptGrammar::action_index [] = { +const short QScriptGrammar::action_index [] = { 1318, 79, -84, 56, 39, -17, -84, -84, 169, -84, -84, -84, -84, 216, 149, -84, -84, -84, -84, -84, -84, 475, 68, 100, 180, 184, -84, -84, -84, 99, @@ -586,7 +586,7 @@ const int QScriptGrammar::action_index [] = { -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, 5, -88, -88, -56, -88, -88}; -const int QScriptGrammar::action_info [] = { +const short QScriptGrammar::action_info [] = { 305, 307, 109, 400, 400, 400, 273, 105, 416, 302, 297, 295, 293, 423, 273, 151, 313, 321, 406, 407, 424, 295, 422, 198, 420, 149, 313, 353, -47, 396, @@ -777,7 +777,7 @@ const int QScriptGrammar::action_info [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const int QScriptGrammar::action_check [] = { +const short QScriptGrammar::action_check [] = { 61, 60, 55, 5, 5, 5, 1, 33, 33, 61, 8, 76, 48, 29, 1, 8, 2, 29, 55, 7, 60, 76, 36, 8, 20, 7, 2, 16, 7, 33, diff --git a/src/script/parser/qscriptgrammar_p.h b/src/script/parser/qscriptgrammar_p.h index 9e0f4f8..0cb6d22 100644 --- a/src/script/parser/qscriptgrammar_p.h +++ b/src/script/parser/qscriptgrammar_p.h @@ -39,11 +39,6 @@ ** ****************************************************************************/ -// This file was generated by qlalr - DO NOT EDIT! - -#ifndef QSCRIPTGRAMMAR_P_H -#define QSCRIPTGRAMMAR_P_H - // // W A R N I N G // ------------- @@ -55,6 +50,10 @@ // We mean it. // +// This file was generated by qlalr - DO NOT EDIT! +#ifndef QSCRIPTGRAMMAR_P_H +#define QSCRIPTGRAMMAR_P_H + #include QT_BEGIN_NAMESPACE @@ -159,33 +158,28 @@ public: GOTO_CHECK_OFFSET = 1562 }; - static const char *const spell []; - static const int lhs []; - static const int rhs []; + static const char *const spell []; + static const short lhs []; + static const short rhs []; #ifndef QLALR_NO_QSCRIPTGRAMMAR_DEBUG_INFO static const int rule_index []; static const int rule_info []; #endif // QLALR_NO_QSCRIPTGRAMMAR_DEBUG_INFO - static const int goto_default []; - static const int action_default []; - static const int action_index []; - static const int action_info []; - static const int action_check []; + static const short goto_default []; + static const short action_default []; + static const short action_index []; + static const short action_info []; + static const short action_check []; static inline int nt_action (int state, int nt) { - const int *const goto_index = &action_index [GOTO_INDEX_OFFSET]; - const int *const goto_check = &action_check [GOTO_CHECK_OFFSET]; - - const int yyn = goto_index [state] + nt; - - if (yyn < 0 || goto_check [yyn] != nt) + const int yyn = action_index [GOTO_INDEX_OFFSET + state] + nt; + if (yyn < 0 || action_check [GOTO_CHECK_OFFSET + yyn] != nt) return goto_default [nt]; - const int *const goto_info = &action_info [GOTO_INFO_OFFSET]; - return goto_info [yyn]; + return action_info [GOTO_INFO_OFFSET + yyn]; } static inline int t_action (int state, int token) @@ -199,6 +193,7 @@ public: } }; -QT_END_NAMESPACE +QT_END_NAMESPACE #endif // QSCRIPTGRAMMAR_P_H + diff --git a/src/script/parser/qscriptparser.cpp b/src/script/parser/qscriptparser.cpp index 197a486..5ea6c17 100644 --- a/src/script/parser/qscriptparser.cpp +++ b/src/script/parser/qscriptparser.cpp @@ -1,5 +1,3 @@ -// This file was generated by qlalr - DO NOT EDIT! - /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). @@ -41,12 +39,13 @@ ** ****************************************************************************/ +// This file was generated by qlalr - DO NOT EDIT! + + #include #include -#include "qscriptast_p.h" - #define Q_SCRIPT_UPDATE_POSITION(node, startloc, endloc) do { \ node->startLine = startloc.startLine; \ node->startColumn = startloc.startColumn; \ @@ -1136,9 +1135,9 @@ case 266: { error_message += QLatin1String (", "); first = false; - error_message += QLatin1Char('`'); + error_message += QLatin1String("`"); error_message += QLatin1String (spell [expected_tokens [s]]); - error_message += QLatin1Char('\''); + error_message += QLatin1String("'"); } } diff --git a/src/script/parser/qscriptparser_p.h b/src/script/parser/qscriptparser_p.h index 5f62db7..c940e1e 100644 --- a/src/script/parser/qscriptparser_p.h +++ b/src/script/parser/qscriptparser_p.h @@ -41,6 +41,7 @@ // This file was generated by qlalr - DO NOT EDIT! + // // W A R N I N G // ------------- diff --git a/util/qlalr/cppgenerator.cpp b/util/qlalr/cppgenerator.cpp index 39d94cd..91340d2 100644 --- a/util/qlalr/cppgenerator.cpp +++ b/util/qlalr/cppgenerator.cpp @@ -341,8 +341,8 @@ void CppGenerator::operator () () } QTextStream out (&f); - out << "// This file was generated by qlalr - DO NOT EDIT!\n"; + // copyright headers must come first, otherwise the headers tests will fail if (copyright) { out << copyrightHeader() @@ -350,8 +350,16 @@ void CppGenerator::operator () () << endl; } + out << "// This file was generated by qlalr - DO NOT EDIT!\n"; + out << startIncludeGuard(grammar.merged_output) << endl; + if (copyright) { + out << "#if defined(Q_OS_VXWORKS) && defined(ERROR)" << endl + << "# undef ERROR" << endl + << "#endif" << endl << endl; + } + generateDecl (out); generateImpl (out); out << p.decls(); @@ -371,10 +379,10 @@ void CppGenerator::operator () () QFile f (declFileName); f.open (QFile::WriteOnly); QTextStream out (&f); - out << "// This file was generated by qlalr - DO NOT EDIT!\n"; QString prot = declFileName.toUpper ().replace (QLatin1Char ('.'), QLatin1Char ('_')); + // copyright headers must come first, otherwise the headers tests will fail if (copyright) { out << copyrightHeader() @@ -382,11 +390,19 @@ void CppGenerator::operator () () << endl; } + out << "// This file was generated by qlalr - DO NOT EDIT!\n"; + out << "#ifndef " << prot << endl << "#define " << prot << endl << endl; + if (copyright) { + out << "#include " << endl << endl; + out << "QT_BEGIN_NAMESPACE" << endl << endl; + } generateDecl (out); + if (copyright) + out << "QT_END_NAMESPACE" << endl; out << "#endif // " << prot << endl << endl; } // end decls @@ -395,13 +411,19 @@ void CppGenerator::operator () () QFile f (bitsFileName); f.open (QFile::WriteOnly); QTextStream out (&f); - out << "// This file was generated by qlalr - DO NOT EDIT!\n"; + // copyright headers must come first, otherwise the headers tests will fail if (copyright) out << copyrightHeader(); + out << "// This file was generated by qlalr - DO NOT EDIT!\n"; + out << "#include \"" << declFileName << "\"" << endl << endl; + if (copyright) + out << "QT_BEGIN_NAMESPACE" << endl << endl; generateImpl(out); + if (copyright) + out << "QT_END_NAMESPACE" << endl; } // end bits @@ -410,7 +432,6 @@ void CppGenerator::operator () () QFile f (grammar.decl_file_name); f.open (QFile::WriteOnly); QTextStream out (&f); - out << "// This file was generated by qlalr - DO NOT EDIT!\n"; out << p.decls(); } @@ -419,7 +440,6 @@ void CppGenerator::operator () () QFile f (grammar.impl_file_name); f.open (QFile::WriteOnly); QTextStream out (&f); - out << "// This file was generated by qlalr - DO NOT EDIT!\n"; out << p.impls(); } } @@ -468,9 +488,9 @@ void CppGenerator::generateDecl (QTextStream &out) << " GOTO_CHECK_OFFSET = " << compressed_action.check.size () << endl << " };" << endl << endl - << " static const char *const spell [];" << endl - << " static const int lhs [];" << endl - << " static const int rhs [];" << endl; + << " static const char *const spell [];" << endl + << " static const short lhs [];" << endl + << " static const short rhs [];" << endl; if (debug_info) { @@ -482,24 +502,19 @@ void CppGenerator::generateDecl (QTextStream &out) << "#endif // " << prot << endl << endl; } - out << " static const int goto_default [];" << endl - << " static const int action_default [];" << endl - << " static const int action_index [];" << endl - << " static const int action_info [];" << endl - << " static const int action_check [];" << endl + out << " static const short goto_default [];" << endl + << " static const short action_default [];" << endl + << " static const short action_index [];" << endl + << " static const short action_info [];" << endl + << " static const short action_check [];" << endl << endl << " static inline int nt_action (int state, int nt)" << endl << " {" << endl - << " const int *const goto_index = &action_index [GOTO_INDEX_OFFSET];" << endl - << " const int *const goto_check = &action_check [GOTO_CHECK_OFFSET];" << endl - << endl - << " const int yyn = goto_index [state] + nt;" << endl - << endl - << " if (yyn < 0 || goto_check [yyn] != nt)" << endl + << " const int yyn = action_index [GOTO_INDEX_OFFSET + state] + nt;" << endl + << " if (yyn < 0 || action_check [GOTO_CHECK_OFFSET + yyn] != nt)" << endl << " return goto_default [nt];" << endl << endl - << " const int *const goto_info = &action_info [GOTO_INFO_OFFSET];" << endl - << " return goto_info [yyn];" << endl + << " return action_info [GOTO_INFO_OFFSET + yyn];" << endl << " }" << endl << endl << " static inline int t_action (int state, int token)" << endl @@ -567,7 +582,7 @@ void CppGenerator::generateImpl (QTextStream &out) out << "};" << endl << endl; - out << "const int " << grammar.table_name << "::lhs [] = {"; + out << "const short " << grammar.table_name << "::lhs [] = {"; idx = 0; for (RulePointer rule = grammar.rules.begin (); rule != grammar.rules.end (); ++rule, ++idx) { @@ -581,7 +596,7 @@ void CppGenerator::generateImpl (QTextStream &out) } out << "};" << endl << endl; - out << "const int " << grammar.table_name << ":: rhs[] = {"; + out << "const short " << grammar.table_name << "::rhs [] = {"; idx = 0; for (RulePointer rule = grammar.rules.begin (); rule != grammar.rules.end (); ++rule, ++idx) { @@ -636,7 +651,7 @@ void CppGenerator::generateImpl (QTextStream &out) << "#endif // " << prot << endl << endl; } - out << "const int " << grammar.table_name << "::action_default [] = {"; + out << "const short " << grammar.table_name << "::action_default [] = {"; idx = 0; for (StatePointer state = aut.states.begin (); state != aut.states.end (); ++state, ++idx) { @@ -653,7 +668,7 @@ void CppGenerator::generateImpl (QTextStream &out) } out << "};" << endl << endl; - out << "const int " << grammar.table_name << "::goto_default [] = {"; + out << "const short " << grammar.table_name << "::goto_default [] = {"; for (int i = 0; i < defgoto.size (); ++i) { if (i) @@ -666,7 +681,7 @@ void CppGenerator::generateImpl (QTextStream &out) } out << "};" << endl << endl; - out << "const int " << grammar.table_name << "::action_index [] = {"; + out << "const short " << grammar.table_name << "::action_index [] = {"; for (int i = 0; i < compressed_action.index.size (); ++i) { if (! (i % 10)) @@ -687,7 +702,7 @@ void CppGenerator::generateImpl (QTextStream &out) } out << "};" << endl << endl; - out << "const int " << grammar.table_name << "::action_info [] = {"; + out << "const short " << grammar.table_name << "::action_info [] = {"; for (int i = 0; i < compressed_action.info.size (); ++i) { if (! (i % 10)) @@ -708,7 +723,7 @@ void CppGenerator::generateImpl (QTextStream &out) } out << "};" << endl << endl; - out << "const int " << grammar.table_name << "::action_check [] = {"; + out << "const short " << grammar.table_name << "::action_check [] = {"; for (int i = 0; i < compressed_action.check.size (); ++i) { if (! (i % 10)) diff --git a/util/qlalr/main.cpp b/util/qlalr/main.cpp index 7041e4a..d864796 100644 --- a/util/qlalr/main.cpp +++ b/util/qlalr/main.cpp @@ -64,7 +64,7 @@ static void help_me () << " --no-debug\t\tno debug information" << endl << " --no-lines\t\tno #line directives" << endl << " --dot\t\t\tgenerate a graph" << endl - << " --troll\t\tadd the Trolltech copyright header" << endl + << " --qt\t\tadd the Qt copyright header and Qt-specific types and macros" << endl << endl; exit (0); } @@ -100,7 +100,7 @@ int main (int argc, char *argv[]) else if (arg == QLatin1String ("--no-debug")) debug_info = false; - else if (arg == QLatin1String ("--troll")) + else if (arg == QLatin1String ("--qt")) troll_copyright = true; else if (file_name.isEmpty ()) diff --git a/util/qtscriptparser/make-parser.sh b/util/qtscriptparser/make-parser.sh deleted file mode 100644 index cfe2513..0000000 --- a/util/qtscriptparser/make-parser.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh -############################################################################# -## -## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -## All rights reserved. -## Contact: Nokia Corporation (qt-info@nokia.com) -## -## This file is the build configuration utility of the Qt Toolkit. -## -## $QT_BEGIN_LICENSE:LGPL$ -## No Commercial Usage -## This file contains pre-release code and may not be distributed. -## You may use this file in accordance with the terms and conditions -## contained in the Technology Preview License Agreement accompanying -## this package. -## -## GNU Lesser General Public License Usage -## Alternatively, this file may be used under the terms of the GNU Lesser -## General Public License version 2.1 as published by the Free Software -## Foundation and appearing in the file LICENSE.LGPL included in the -## packaging of this file. Please review the following information to -## ensure the GNU Lesser General Public License version 2.1 requirements -## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -## -## In addition, as a special exception, Nokia gives you certain additional -## rights. These rights are described in the Nokia Qt LGPL Exception -## version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -## -## If you have questions regarding the use of this file, please contact -## Nokia at qt-info@nokia.com. -## -## -## -## -## -## -## -## -## $QT_END_LICENSE$ -## -############################################################################# - -me=$(dirname $0) -mkdir -p $me/out -(cd $me/out && ${QLALR-qlalr} --troll --no-lines ../qscript.g) - -for f in $me/out/*.{h,cpp}; do - n=$(basename $f) - p4 open $me/../../src/script/$n - cp $f $me/../../src/script/$n -done - -p4 revert -a $me/../../src/script/... -p4 diff -du $me/../../src/script/... - -- cgit v0.12 From afffa7cd099379d78ada4c96c2284e87f77d7bb2 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 21 Sep 2009 19:44:57 +0200 Subject: QNAM: Avoid using toLower for case insensitive comparision Using qstricmp is faster on the desktop than the alloc of QByteArray::toLower and the QByteArray::operator==. QChar::toLower will now be called for the input key from within the loop. In the measurements done this is still a performance improvement over the allocation done by QByteArray::toLower. For more header values this might not be the case anymore. RESULT : tst_Loading::byteArrayTestLower(): 0.00076 msec per iteration (total: 25, iterations: 32768) RESULT : tst_Loading::byteArrayTestCompare(): 0.00028 msec per iteration (total: 37, iterations: 131072) Reviewed-By: Markus Goetz --- src/network/access/qnetworkrequest.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index 86195c6..0e4326f 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -48,6 +48,8 @@ #include "QtCore/qlocale.h" #include "QtCore/qdatetime.h" +#include + QT_BEGIN_NAMESPACE /*! @@ -606,26 +608,25 @@ static QNetworkRequest::KnownHeaders parseHeaderName(const QByteArray &headerNam { // headerName is not empty here - QByteArray lower = headerName.toLower(); - switch (lower.at(0)) { + switch (tolower(headerName.at(0))) { case 'c': - if (lower == "content-type") + if (qstricmp(headerName.constData(), "content-type") == 0) return QNetworkRequest::ContentTypeHeader; - else if (lower == "content-length") + else if (qstricmp(headerName.constData(), "content-length") == 0) return QNetworkRequest::ContentLengthHeader; - else if (lower == "cookie") + else if (qstricmp(headerName.constData(), "cookie") == 0) return QNetworkRequest::CookieHeader; break; case 'l': - if (lower == "location") + if (qstricmp(headerName.constData(), "location") == 0) return QNetworkRequest::LocationHeader; - else if (lower == "last-modified") + else if (qstricmp(headerName.constData(), "last-modified") == 0) return QNetworkRequest::LastModifiedHeader; break; case 's': - if (lower == "set-cookie") + if (qstricmp(headerName.constData(), "set-cookie") == 0) return QNetworkRequest::SetCookieHeader; break; } @@ -697,11 +698,10 @@ static QVariant parseHeaderValue(QNetworkRequest::KnownHeaders header, const QBy QNetworkHeadersPrivate::RawHeadersList::ConstIterator QNetworkHeadersPrivate::findRawHeader(const QByteArray &key) const { - QByteArray lowerKey = key.toLower(); RawHeadersList::ConstIterator it = rawHeaders.constBegin(); RawHeadersList::ConstIterator end = rawHeaders.constEnd(); for ( ; it != end; ++it) - if (it->first.toLower() == lowerKey) + if (qstricmp(it->first.constData(), key.constData()) == 0) return it; return end; // not found @@ -775,10 +775,9 @@ void QNetworkHeadersPrivate::setCookedHeader(QNetworkRequest::KnownHeaders heade void QNetworkHeadersPrivate::setRawHeaderInternal(const QByteArray &key, const QByteArray &value) { - QByteArray lowerKey = key.toLower(); RawHeadersList::Iterator it = rawHeaders.begin(); while (it != rawHeaders.end()) { - if (it->first.toLower() == lowerKey) + if (qstricmp(it->first.constData(), key.constData()) == 0) it = rawHeaders.erase(it); else ++it; -- cgit v0.12 From a7dfc472b06966393a9d9c394d91ed8974b9cfb6 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Tue, 22 Sep 2009 12:35:29 +0200 Subject: QNAM: Remove some more occurences of toLower on the hot path toLower will force a memory allocation, and memory allocations are certainly adding a delay. Use qstricmp were this is easily possible. This change makes headerValues et all drop out of the profile. QChar::toLower will now be called more often, specially for loops that do linear searching. In the profile with real web content this is faster than using QByteArry::toLower in the inner loop and the forced memory allocations. Reviewed-By: Markus Goetz --- src/network/access/qhttpnetworkheader.cpp | 6 ++---- src/network/access/qhttpnetworkreply.cpp | 6 +++--- src/network/access/qnetworkaccesshttpbackend.cpp | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/network/access/qhttpnetworkheader.cpp b/src/network/access/qhttpnetworkheader.cpp index 68ed3e5..e9866ca 100644 --- a/src/network/access/qhttpnetworkheader.cpp +++ b/src/network/access/qhttpnetworkheader.cpp @@ -92,11 +92,10 @@ QByteArray QHttpNetworkHeaderPrivate::headerField(const QByteArray &name, const QList QHttpNetworkHeaderPrivate::headerFieldValues(const QByteArray &name) const { QList result; - QByteArray lowerName = name.toLower(); QList >::ConstIterator it = fields.constBegin(), end = fields.constEnd(); for ( ; it != end; ++it) - if (lowerName == it->first.toLower()) + if (qstricmp(name.constData(), it->first) == 0) result += it->second; return result; @@ -104,10 +103,9 @@ QList QHttpNetworkHeaderPrivate::headerFieldValues(const QByteArray void QHttpNetworkHeaderPrivate::setHeaderField(const QByteArray &name, const QByteArray &data) { - QByteArray lowerName = name.toLower(); QList >::Iterator it = fields.begin(); while (it != fields.end()) { - if (lowerName == it->first.toLower()) + if (qstricmp(name.constData(), it->first) == 0) it = fields.erase(it); else ++it; diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index e990704..2b0c252 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -239,7 +239,7 @@ qint64 QHttpNetworkReplyPrivate::bytesAvailable() const bool QHttpNetworkReplyPrivate::isGzipped() { QByteArray encoding = headerField("content-encoding"); - return encoding.toLower() == "gzip"; + return qstricmp(encoding.constData(), "gzip") == 0; } void QHttpNetworkReplyPrivate::removeAutoDecompressHeader() @@ -247,11 +247,10 @@ void QHttpNetworkReplyPrivate::removeAutoDecompressHeader() // The header "Content-Encoding = gzip" is retained. // Content-Length is removed since the actual one send by the server is for compressed data QByteArray name("content-length"); - QByteArray lowerName = name.toLower(); QList >::Iterator it = fields.begin(), end = fields.end(); while (it != end) { - if (name == it->first.toLower()) { + if (qstricmp(name.constData(), it->first.constData()) == 0) { fields.erase(it); break; } @@ -269,6 +268,7 @@ bool QHttpNetworkReplyPrivate::findChallenge(bool forProxy, QByteArray &challeng QList challenges = headerFieldValues(header); for (int i = 0; ifirst); if (!value.isEmpty()) { - if (it->first.toLower() == "set-cookie") + if (qstricmp(it->first.constData(), "set-cookie") == 0) value += "\n"; else value += ", "; -- cgit v0.12 From 0739771c29d38a4a2f2cb08560181195ad4e8e0c Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Tue, 22 Sep 2009 12:39:15 +0200 Subject: QNAM: Parse RFC1123 directly and don't go through QLocale The QDateTimeParser forces at least two QString allocations to convert the Month string into a integer. This makes parsing the date string the most expesnsive operation from within replyHeaderChanged. Use sscanf to parse the RFC1123 header to get a significant speedup. Use a switch case statement to convert the month name to a integer. Reviewed-By: Markus Goetz --- src/network/access/qnetworkrequest.cpp | 82 ++++++++++++++++++++++++++++++---- 1 file changed, 74 insertions(+), 8 deletions(-) diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index 0e4326f..c91c608 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -804,6 +804,68 @@ void QNetworkHeadersPrivate::parseAndSetHeader(const QByteArray &key, const QByt } } +// Fast month string to int conversion. This code +// assumes that the Month name is correct and that +// the string is at least three chars long. +static int name_to_month(const char* month_str) +{ + switch (month_str[0]) { + case 'J': + switch (month_str[1]) { + case 'a': + return 1; + break; + case 'u': + switch (month_str[2] ) { + case 'n': + return 6; + break; + case 'l': + return 7; + break; + } + } + break; + case 'F': + return 2; + break; + case 'M': + switch (month_str[2] ) { + case 'r': + return 3; + break; + case 'y': + return 5; + break; + } + break; + case 'A': + switch (month_str[1]) { + case 'p': + return 4; + break; + case 'u': + return 8; + break; + } + break; + case 'O': + return 10; + break; + case 'S': + return 9; + break; + case 'N': + return 11; + break; + case 'D': + return 12; + break; + } + + return 0; +} + QDateTime QNetworkHeadersPrivate::fromHttpDate(const QByteArray &value) { // HTTP dates have three possible formats: @@ -819,16 +881,20 @@ QDateTime QNetworkHeadersPrivate::fromHttpDate(const QByteArray &value) // no comma -> asctime(3) format dt = QDateTime::fromString(QString::fromLatin1(value), Qt::TextDate); } else { - // eat the weekday, the comma and the space following it - QString sansWeekday = QString::fromLatin1(value.constData() + pos + 2); - - QLocale c = QLocale::c(); - if (pos == 3) - // must be RFC 1123 date - dt = c.toDateTime(sansWeekday, QLatin1String("dd MMM yyyy hh:mm:ss 'GMT")); - else + // Use sscanf over QLocal/QDateTimeParser for speed reasons. See the + // QtWebKit performance benchmarks to get an idea. + if (pos == 3) { + char month_name[4]; + int day, year, hour, minute, second; + if (sscanf(value.constData(), "%*3s, %d %3s %d %d:%d:%d 'GMT'", &day, month_name, &year, &hour, &minute, &second) == 6) + dt = QDateTime(QDate(year, name_to_month(month_name), day), QTime(hour, minute, second)); + } else { + QLocale c = QLocale::c(); + // eat the weekday, the comma and the space following it + QString sansWeekday = QString::fromLatin1(value.constData() + pos + 2); // must be RFC 850 date dt = c.toDateTime(sansWeekday, QLatin1String("dd-MMM-yy hh:mm:ss 'GMT'")); + } } #endif // QT_NO_DATESTRING -- cgit v0.12 From f7a1117cbec5638e32ea04b6a93412b193e07913 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Wed, 11 Nov 2009 13:33:35 +0100 Subject: tst_qnetworkreply: Test LastModified parsing Someone complained about it giving wrong values, however this test passes at least here on my Linux box. Reviewed-by: Peter Hartmann --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 38 ++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 446fb53..bd83c47 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -225,6 +225,9 @@ private Q_SLOTS: void ioPostToHttpUploadProgress(); void ioPostToHttpEmtpyUploadProgress(); + void lastModifiedHeaderForFile(); + void lastModifiedHeaderForHttp(); + void rateControl_data(); void rateControl(); @@ -2964,6 +2967,41 @@ void tst_QNetworkReply::ioPostToHttpEmtpyUploadProgress() server.close(); } +void tst_QNetworkReply::lastModifiedHeaderForFile() +{ + QFileInfo fileInfo(SRCDIR "./bigfile"); + QUrl url = QUrl::fromLocalFile(fileInfo.filePath()); + + QNetworkRequest request(url); + QNetworkReplyPtr reply = manager.head(request); + QSignalSpy spy(reply, SIGNAL(uploadProgress(qint64,qint64))); + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + + QDateTime header = reply->header(QNetworkRequest::LastModifiedHeader).toDateTime(); + QCOMPARE(header, fileInfo.lastModified()); +} + +void tst_QNetworkReply::lastModifiedHeaderForHttp() +{ + // Tue, 22 May 2007 12:04:57 GMT according to webserver + QUrl url = "http://" + QtNetworkSettings::serverName() + "/gif/fluke.gif"; + + QNetworkRequest request(url); + QNetworkReplyPtr reply = manager.head(request); + QSignalSpy spy(reply, SIGNAL(uploadProgress(qint64,qint64))); + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + + QDateTime header = reply->header(QNetworkRequest::LastModifiedHeader).toDateTime(); + QDateTime realDate = QDateTime::fromString("2007-05-22T12:04:57", Qt::ISODate); + realDate.setTimeSpec(Qt::UTC); + + QCOMPARE(header, realDate); +} + void tst_QNetworkReply::rateControl_data() { QTest::addColumn("rate"); -- cgit v0.12 From 115e012adf98b0d4e0329e35fbfda63814695bfe Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 13 Nov 2009 10:53:56 +0100 Subject: doc: Fixed qdoc according to Bjarne's recommendation. Someone had changed an operator==() and an operator!=() from single parameter members to two-parameter friends but hadn't changed the qdoc comments. --- src/corelib/tools/qscopedpointer.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp index a3ca2c3..22e9bdf 100644 --- a/src/corelib/tools/qscopedpointer.cpp +++ b/src/corelib/tools/qscopedpointer.cpp @@ -174,18 +174,20 @@ QT_BEGIN_NAMESPACE */ /*! - \fn bool QScopedPointer::operator==(const QScopedPointer &other) const + \fn bool operator==(const QScopedPointer &lhs, const QScopedPointer &rhs) - Equality operator. Returns true if the scoped pointer \a other - is pointing to the same object as this pointer, otherwise returns false. + Equality operator. Returns true if the scoped pointers + \a lhs and \a rhs are pointing to the same object. + Otherwise returns false. */ /*! - \fn bool QScopedPointer::operator!=(const QScopedPointer &other) const + \fn bool operator!=(const QScopedPointer &lhs, const QScopedPointer &rhs) - Inequality operator. Returns true if the scoped pointer \a other - is not pointing to the same object as this pointer, otherwise returns false. + Inequality operator. Returns true if the scoped pointers + \a lhs and \a rhs are \e not pointing to the same object. + Otherwise returns false. */ /*! -- cgit v0.12