Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/tools/assistant/lib/qhelp_global.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4040****************************************************************************/
    4141
     42#include <QtCore/QCoreApplication>
    4243#include <QtCore/QRegExp>
    4344#include <QtCore/QMutexLocker>
     
    5657
    5758    return QString::fromLatin1("%1-%2-%3").
    58         arg(name).arg(long(pointer)).arg(counter);
     59        arg(name).arg(quintptr(pointer)).arg(counter);
    5960}
    6061
    6162QString QHelpGlobal::documentTitle(const QString &content)
    6263{
    63     QString title = QObject::tr("Untitled");
     64    QString title = QCoreApplication::translate("QHelp", "Untitled");
    6465    if (!content.isEmpty()) {
    6566        int start = content.indexOf(QLatin1String("<title>"), 0, Qt::CaseInsensitive) + 7;
     
    8788QString QHelpGlobal::codecFromHtmlData(const QByteArray &data)
    8889{
    89     QString content = QString::fromUtf8(data.constData(), data.size());
    90     int start = content.indexOf(QLatin1String("<meta"), 0, Qt::CaseInsensitive);
     90    QString head = QString::fromUtf8(data.constData(), qMin(1000, data.size()));
     91    int start = head.indexOf(QLatin1String("<meta"), 0, Qt::CaseInsensitive);
    9192    if (start > 0) {
    92         int end;
    9393        QRegExp r(QLatin1String("charset=([^\"\\s]+)"));
    9494        while (start != -1) {
    95             end = content.indexOf(QLatin1Char('>'), start) + 1;
    96             const QString &meta = content.mid(start, end - start).toLower();
     95            const int end = head.indexOf(QLatin1Char('>'), start) + 1;
     96            if (end <= start)
     97                break;
     98            const QString &meta = head.mid(start, end - start).toLower();
    9799            if (r.indexIn(meta) != -1)
    98100                return r.cap(1);
    99             start = content.indexOf(QLatin1String("<meta"), end,
     101            start = head.indexOf(QLatin1String("<meta"), end,
    100102                                    Qt::CaseInsensitive);
    101103        }
     
    106108QString QHelpGlobal::codecFromXmlData(const QByteArray &data)
    107109{
    108     QString content = QString::fromUtf8(data.constData(), data.size());
     110    QString head = QString::fromUtf8(data.constData(), qMin(1000, data.size()));
    109111    const QRegExp encodingExp(QLatin1String("^\\s*<\\?xml version="
    110112        "\"\\d\\.\\d\" encoding=\"([^\"]+)\"\\?>.*"));
    111     return encodingExp.exactMatch(content) ? encodingExp.cap(1) : QString();
     113    return encodingExp.exactMatch(head) ? encodingExp.cap(1) : QString();
    112114}
Note: See TracChangeset for help on using the changeset viewer.