Changeset 561 for trunk/src/corelib/tools/qstring.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/corelib/tools/qstring.cpp
r421 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information ([email protected]) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation ([email protected]) 5 6 ** 6 7 ** This file is part of the QtCore module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you 37 ** @nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 46 46 #include <qtextcodec.h> 47 47 #endif 48 48 49 #include <qdatastream.h> 49 50 #include <qlist.h> … … 175 176 static int ucstrcmp(const QChar *a, int alen, const QChar *b, int blen) 176 177 { 177 if (a == b )178 if (a == b) 178 179 return 0; 179 180 int l = qMin(alen, blen); … … 201 202 } 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 203 266 204 267 /*! … … 302 365 \internal 303 366 304 \ingroup text367 \ingroup 305 368 306 369 When you get an object of type QCharRef, if you can assign to it, … … 324 387 \ingroup tools 325 388 \ingroup shared 326 \ingroup text327 \mainclass 389 \ingroup 390 328 391 329 392 QString stores a string of 16-bit \l{QChar}s, where each QChar … … 607 670 significant digits (trailing zeroes are omitted). 608 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 609 740 \sa fromRawData(), QChar, QLatin1String, QByteArray, QStringRef 610 741 */ … … 749 880 \since 4.2 750 881 751 Returns a copy of the \a string string encoded in ucs4. 882 Returns a copy of the \a string, where the encoding of \a string depends on 883 the size of wchar. If wchar is 4 bytes, the \a string is interpreted as ucs-4, 884 if wchar is 2 bytes it is interpreted as ucs-2. 752 885 753 886 If \a size is -1 (default), the \a string has to be 0 terminated. … … 838 971 of the QChar array \a unicode. 839 972 840 QString makes a deep copy of the string data. 973 QString makes a deep copy of the string data. The unicode data is copied as 974 is and the Byte Order Mark is preserved if present. 841 975 */ 842 976 QString::QString(const QChar *unicode, int size) … … 850 984 } else { 851 985 d = (Data*) qMalloc(sizeof(Data)+size*sizeof(QChar)); 986 852 987 d->ref = 1; 853 988 d->alloc = d->size = size; … … 873 1008 } else { 874 1009 d = (Data*) qMalloc(sizeof(Data)+size*sizeof(QChar)); 1010 875 1011 d->ref = 1; 876 1012 d->alloc = d->size = size; … … 886 1022 } 887 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 888 1041 /*! \fn QString::QString(const QLatin1String &str) 889 1042 … … 898 1051 QString::QString(QChar ch) 899 1052 { 900 d = (Data *)qMalloc(sizeof(Data) + sizeof(QChar)); 1053 void *buf = qMalloc(sizeof(Data) + sizeof(QChar)); 1054 Q_CHECK_PTR(buf); 1055 d = reinterpret_cast<Data *>(buf); 901 1056 d->ref = 1; 902 1057 d->alloc = d->size = 1; … … 1068 1223 if (d->ref != 1 || d->data != d->array) { 1069 1224 Data *x = static_cast<Data *>(qMalloc(sizeof(Data) + alloc * sizeof(QChar))); 1070 if (!x) 1071 return; 1225 Q_CHECK_PTR(x); 1072 1226 x->size = qMin(alloc, d->size); 1073 1227 ::memcpy(x->array, d->data, x->size * sizeof(QChar)); … … 1091 1245 } 1092 1246 #endif 1093 Data *x = static_cast<Data *>(qRealloc(d, sizeof(Data) + alloc * sizeof(QChar))); 1094 if (!x) 1095 return; 1096 x->alloc = alloc; 1097 x->data = x->array; 1098 d = x; 1247 d = static_cast<Data *>(q_check_ptr(qRealloc(d, sizeof(Data) + alloc * sizeof(QChar)))); 1248 d->alloc = alloc; 1249 d->data = d->array; 1099 1250 } 1100 1251 } … … 1250 1401 // Part of me - take a copy 1251 1402 ushort *tmp = static_cast<ushort *>(qMalloc(size * sizeof(QChar))); 1403 1252 1404 memcpy(tmp, s, size * sizeof(QChar)); 1253 1405 insert(i, reinterpret_cast<const QChar *>(tmp), size); … … 1444 1596 QString &QString::remove(int pos, int len) 1445 1597 { 1446 if (pos < 0) 1598 if (pos < 0) 1447 1599 pos += d->size; 1448 1600 if (pos < 0 || pos >= d->size) { 1449 1601 // range problems 1450 } else if ( pos + len >= d->size) { // pos ok1451 resize(pos); 1602 } else if ( 1603 resize(pos); 1452 1604 } else if (len > 0) { 1453 1605 detach(); … … 1604 1756 void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar *after, int alen) 1605 1757 { 1606 if (blen == alen) { 1758 // copy *after in case it lies inside our own d->data area 1759 // (which we could possibly invalidate via a realloc or corrupt via memcpy operations.) 1760 QChar *afterBuffer = const_cast<QChar *>(after); 1761 if (after >= reinterpret_cast<QChar *>(d->data) && after < reinterpret_cast<QChar *>(d->data) + d->size) { 1762 afterBuffer = static_cast<QChar *>(qMalloc(alen*sizeof(QChar))); 1763 Q_CHECK_PTR(afterBuffer); 1764 ::memcpy(afterBuffer, after, alen*sizeof(QChar)); 1765 } 1766 1767 QT_TRY { 1607 1768 detach(); 1608 for (int i = 0; i < nIndices; ++i) 1609 memcpy(d->data + indices[i], after, alen * sizeof(QChar)); 1610 } else if (alen < blen) { 1611 detach(); 1612 uint to = indices[0]; 1613 if (alen) 1614 memcpy(d->data+to, after, alen*sizeof(QChar)); 1615 to += alen; 1616 uint movestart = indices[0] + blen; 1617 for (int i = 1; i < nIndices; ++i) { 1618 int msize = indices[i] - movestart; 1619 if (msize > 0) { 1769 if (blen == alen) { 1770 // replace in place 1771 for (int i = 0; i < nIndices; ++i) 1772 memcpy(d->data + indices[i], afterBuffer, alen * sizeof(QChar)); 1773 } else if (alen < blen) { 1774 // replace from front 1775 uint to = indices[0]; 1776 if (alen) 1777 memcpy(d->data+to, after, alen*sizeof(QChar)); 1778 to += alen; 1779 uint movestart = indices[0] + blen; 1780 for (int i = 1; i < nIndices; ++i) { 1781 int msize = indices[i] - movestart; 1782 if (msize > 0) { 1783 memmove(d->data + to, d->data + movestart, msize * sizeof(QChar)); 1784 to += msize; 1785 } 1786 if (alen) { 1787 memcpy(d->data + to, afterBuffer, alen*sizeof(QChar)); 1788 to += alen; 1789 } 1790 movestart = indices[i] + blen; 1791 } 1792 int msize = d->size - movestart; 1793 if (msize > 0) 1620 1794 memmove(d->data + to, d->data + movestart, msize * sizeof(QChar)); 1621 to += msize; 1795 resize(d->size - nIndices*(blen-alen)); 1796 } else { 1797 // replace from back 1798 int adjust = nIndices*(alen-blen); 1799 int newLen = d->size + adjust; 1800 int moveend = d->size; 1801 resize(newLen); 1802 1803 while (nIndices) { 1804 --nIndices; 1805 int movestart = indices[nIndices] + blen; 1806 int insertstart = indices[nIndices] + nIndices*(alen-blen); 1807 int moveto = insertstart + alen; 1808 memmove(d->data + moveto, d->data + movestart, 1809 (moveend - movestart)*sizeof(QChar)); 1810 memcpy(d->data + insertstart, afterBuffer, alen*sizeof(QChar)); 1811 moveend = movestart-blen; 1622 1812 } 1623 if (alen) {1624 memcpy(d->data + to, after, alen*sizeof(QChar));1625 to += alen;1626 }1627 movestart = indices[i] + blen;1628 1813 } 1629 int msize = d->size - movestart; 1630 if (msize > 0) 1631 memmove(d->data + to, d->data + movestart, msize * sizeof(QChar)); 1632 resize(d->size - nIndices*(blen-alen)); 1633 } else { 1634 // we have a table of replacement positions, use them for fast replacing 1635 int adjust = nIndices*(alen-blen); 1636 int newLen = d->size + adjust; 1637 int moveend = d->size; 1638 resize(newLen); 1639 1640 while (nIndices) { 1641 --nIndices; 1642 int movestart = indices[nIndices] + blen; 1643 int insertstart = indices[nIndices] + nIndices*(alen-blen); 1644 int moveto = insertstart + alen; 1645 memmove(d->data + moveto, d->data + movestart, 1646 (moveend - movestart)*sizeof(QChar)); 1647 memcpy(d->data + insertstart, after, alen*sizeof(QChar)); 1648 moveend = movestart-blen; 1649 } 1650 } 1814 } QT_CATCH(const std::bad_alloc &) { 1815 if (afterBuffer != after) 1816 qFree(afterBuffer); 1817 QT_RETHROW; 1818 } 1819 if (afterBuffer != after) 1820 qFree(afterBuffer); 1651 1821 } 1652 1822 … … 1676 1846 return *this; 1677 1847 1678 // protect against before or after being part of this 1679 const QChar *a = after; 1680 const QChar *b = before; 1681 if (after >= (const QChar *)d->data && after < (const QChar *)d->data + d->size) { 1682 QChar *copy = (QChar *)malloc(alen*sizeof(QChar)); 1683 memcpy(copy, after, alen*sizeof(QChar)); 1684 a = copy; 1685 } 1686 if (before >= (const QChar *)d->data && before < (const QChar *)d->data + d->size) { 1687 QChar *copy = (QChar *)malloc(blen*sizeof(QChar)); 1688 memcpy(copy, before, blen*sizeof(QChar)); 1689 b = copy; 1690 } 1691 1692 QStringMatcher matcher(b, blen, cs); 1848 QStringMatcher matcher(before, blen, cs); 1693 1849 1694 1850 int index = 0; … … 1709 1865 break; 1710 1866 1711 replace_helper(indices, pos, blen, a , alen);1867 replace_helper(indices, pos, blen, a, alen); 1712 1868 1713 1869 if (index == -1) … … 1716 1872 index += pos*(alen-blen); 1717 1873 } 1718 1719 if (a != after)1720 ::free((QChar *)a);1721 if (b != before)1722 ::free((QChar *)b);1723 1874 1724 1875 return *this; … … 1912 2063 bool QString::operator==(const QString &other) const 1913 2064 { 1914 return (size() == other.size()) && 1915 (memcmp((char*)unicode(),(char*)other.unicode(), size()*sizeof(QChar))==0); 2065 if (d->size != other.d->size) 2066 return false; 2067 2068 return qMemEquals(d->data, other.d->data, d->size); 1916 2069 } 1917 2070 … … 2534 2687 2535 2688 int index = 0; 2536 int numCaptures = rx2. numCaptures();2689 int numCaptures = rx2.(); 2537 2690 int al = after.length(); 2538 2691 QRegExp::CaretMode caretMode = QRegExp::CaretAtZero; … … 3140 3293 return false; 3141 3294 if (cs == Qt::CaseSensitive) { 3142 return memcmp((char*)d->data, (char*)s.d->data, s.d->size*sizeof(QChar)) == 0;3295 return ; 3143 3296 } else { 3144 3297 uint last = 0; … … 3211 3364 return false; 3212 3365 if (cs == Qt::CaseSensitive) { 3213 return memcmp((char*)&d->data[pos], (char*)s.d->data, s.d->size*sizeof(QChar)) == 0;3366 return ; 3214 3367 } else { 3215 3368 uint last = 0; … … 3336 3489 } 3337 3490 3338 #if !defined(Q_WS_MAC) && !defined(Q_OS_OS2)3491 #if !defined(Q_WS_MAC) && !defined(Q_OS_OS2) 3339 3492 static QByteArray toLocal8Bit_helper(const QChar *data, int length) 3340 3493 { … … 3454 3607 size = qstrlen(str); 3455 3608 d = static_cast<Data *>(qMalloc(sizeof(Data) + size * sizeof(QChar))); 3609 3456 3610 d->ref = 1; 3457 3611 d->alloc = d->size = size; … … 3461 3615 d->array[size] = '\0'; 3462 3616 while (size--) 3463 *i++ = (uchar)*str++;3617 *i++ = (uchar)*str++; 3464 3618 } 3465 3619 return d; … … 3570 3724 QByteArray mb(4096, 0); 3571 3725 int len; 3572 while (!(len=WideCharToMultiByte(CP_ACP, 0, (const WCHAR*)ch, uclen,3726 while (!(len=WideCharToMultiByte(CP_ACP, 0, (const *)ch, uclen, 3573 3727 mb.data(), mb.size()-1, 0, &used_def))) 3574 3728 { … … 3576 3730 if (r == ERROR_INSUFFICIENT_BUFFER) { 3577 3731 mb.resize(1+WideCharToMultiByte(CP_ACP, 0, 3578 (const WCHAR*)ch, uclen,3732 (const *)ch, uclen, 3579 3733 0, 0, 0, &used_def)); 3580 3734 // and try again... … … 3597 3751 return QString(); 3598 3752 const int wclen_auto = 4096; 3599 WCHARwc_auto[wclen_auto];3753 wc_auto[wclen_auto]; 3600 3754 int wclen = wclen_auto; 3601 WCHAR*wc = wc_auto;3755 *wc = wc_auto; 3602 3756 int len; 3603 3757 while (!(len=MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, … … 3612 3766 wclen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, 3613 3767 mb, mblen, 0, 0); 3614 wc = new WCHAR[wclen];3768 wc = new [wclen]; 3615 3769 // and try again... 3616 3770 } … … 3655 3809 if (size == 0 || (!*str && size < 0)) 3656 3810 return QLatin1String(""); 3657 #if defined(Q_OS_WIN32)3658 if(QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based) {3659 return qt_winMB2QString(str, size);3660 }3661 #endif3662 3811 #if !defined(QT_NO_TEXTCODEC) 3663 3812 if (size < 0) … … 3704 3853 size = qstrlen(str); 3705 3854 3706 QString result; 3707 result.resize(size); // worst case 3708 ushort *qch = result.d->data; 3709 uint uc = 0; 3710 uint min_uc = 0; 3711 int need = 0; 3712 int error = -1; 3713 uchar ch; 3714 int i = 0; 3715 3716 // skip utf8-encoded byte order mark 3717 if (size >= 3 3718 && (uchar)str[0] == 0xef && (uchar)str[1] == 0xbb && (uchar)str[2] == 0xbf) 3719 i += 3; 3720 3721 for (; i < size; ++i) { 3722 ch = str[i]; 3723 if (need) { 3724 if ((ch&0xc0) == 0x80) { 3725 uc = (uc << 6) | (ch & 0x3f); 3726 need--; 3727 if (!need) { 3728 if (uc > 0xffffU && uc < 0x110000U) { 3729 // surrogate pair 3730 *qch++ = QChar::highSurrogate(uc); 3731 uc = QChar::lowSurrogate(uc); 3732 } else if ((uc < min_uc) || (uc >= 0xd800 && uc <= 0xdfff) || (uc >= 0xfffe)) { 3733 // overlong seqence, UTF16 surrogate or BOM 3734 uc = QChar::ReplacementCharacter; 3735 } 3736 *qch++ = uc; 3737 } 3738 } else { 3739 i = error; 3740 need = 0; 3741 *qch++ = QChar::ReplacementCharacter; 3742 } 3743 } else { 3744 if (ch < 128) { 3745 *qch++ = ch; 3746 } else if ((ch & 0xe0) == 0xc0) { 3747 uc = ch & 0x1f; 3748 need = 1; 3749 error = i; 3750 min_uc = 0x80; 3751 } else if ((ch & 0xf0) == 0xe0) { 3752 uc = ch & 0x0f; 3753 need = 2; 3754 error = i; 3755 min_uc = 0x800; 3756 } else if ((ch&0xf8) == 0xf0) { 3757 uc = ch & 0x07; 3758 need = 3; 3759 error = i; 3760 min_uc = 0x10000; 3761 } else { 3762 // Error 3763 *qch++ = QChar::ReplacementCharacter; 3764 } 3765 } 3766 } 3767 if (need) { 3768 // we have some invalid characters remaining we need to add to the string 3769 for (int i = error; i < size; ++i) 3770 *qch++ = QChar::ReplacementCharacter; 3771 } 3772 3773 result.truncate(qch - result.d->data); 3774 return result; 3855 return QUtf8::convertToUnicode(str, size, 0); 3775 3856 } 3776 3857 … … 3795 3876 ++size; 3796 3877 } 3797 return Q String((const QChar *)unicode, size);3878 return Q); 3798 3879 } 3799 3880 … … 3819 3900 ++size; 3820 3901 } 3821 3822 QString s; 3823 s.resize(size*2); // worst case 3824 ushort *uc = s.d->data; 3825 for (int i = 0; i < size; ++i) { 3826 uint u = unicode[i]; 3827 if (u > 0xffff) { 3828 // decompose into a surrogate pair 3829 *uc++ = QChar::highSurrogate(u); 3830 u = QChar::lowSurrogate(u); 3831 } 3832 *uc++ = u; 3833 } 3834 s.resize(uc - s.d->data); 3835 return s; 3902 return QUtf32::convertToUnicode((const char *)unicode, size*4, 0); 3836 3903 } 3837 3904 … … 3884 3951 if (d->size == 0) 3885 3952 return *this; 3886 QString result; 3887 result.resize(d->size); 3953 QString result(d->size, Qt::Uninitialized); 3888 3954 const QChar *from = (const QChar*) d->data; 3889 3955 const QChar *fromend = (const QChar*) from+d->size; … … 4556 4622 4557 4623 #if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) 4558 int res; 4559 QT_WA({ 4560 const TCHAR* s1 = (TCHAR*)data1; 4561 const TCHAR* s2 = (TCHAR*)data2; 4562 res = CompareStringW(GetUserDefaultLCID(), 0, s1, length1, s2, length2); 4563 } , { 4564 QByteArray s1 = toLocal8Bit_helper(data1, length1); 4565 QByteArray s2 = toLocal8Bit_helper(data2, length2); 4566 res = CompareStringA(GetUserDefaultLCID(), 0, s1.data(), s1.length(), s2.data(), s2.length()); 4567 }); 4624 int res = CompareString(GetUserDefaultLCID(), 0, (wchar_t*)data1, length1, (wchar_t*)data2, length2); 4568 4625 4569 4626 switch (res) { … … 4762 4819 const QUnicodeTables::Properties *prop = qGetProp(c); 4763 4820 if (prop->lowerCaseDiff || prop->lowerCaseSpecial) { 4764 QString s; 4765 s.resize(d->size); 4821 QString s(d->size, Qt::Uninitialized); 4766 4822 memcpy(s.d->data, d->data, (p - d->data)*sizeof(ushort)); 4767 4823 ushort *pp = s.d->data + (p - d->data); … … 4854 4910 const QUnicodeTables::Properties *prop = qGetProp(c); 4855 4911 if (prop->upperCaseDiff || prop->upperCaseSpecial) { 4856 QString s; 4857 s.resize(d->size); 4912 QString s(d->size, Qt::Uninitialized); 4858 4913 memcpy(s.d->data, d->data, (p - d->data)*sizeof(ushort)); 4859 4914 ushort *pp = s.d->data + (p - d->data); … … 6006 6061 } 6007 6062 6063 6008 6064 /*! 6009 6065 \overload … … 6015 6071 QString QString::normalized(QString::NormalizationForm mode, QChar::UnicodeVersion version) const 6016 6072 { 6073 6074 6075 6076 6077 6078 6079 6017 6080 bool simple = true; 6018 for (int i = 0; i < d->size; ++i) { 6019 if (d->data[i] >= 0x80) { 6081 const QChar *p = data->constData(); 6082 int len = data->length(); 6083 for (int i = from; i < len; ++i) { 6084 if (p[i].unicode() >= 0x80) { 6020 6085 simple = false; 6021 6086 break; … … 6023 6088 } 6024 6089 if (simple) 6025 return *this;6026 6027 QString s = *this;6090 return; 6091 6092 QString ; 6028 6093 if (version != CURRENT_VERSION) { 6029 6094 for (int i = 0; i < NumNormalizationCorrections; ++i) { 6030 6095 const NormalizationCorrection &n = uc_normalization_corrections[i]; 6031 6096 if (n.version > version) { 6097 6032 6098 if (n.ucs4 > 0xffff) { 6033 6099 ushort ucs4High = QChar::highSurrogate(n.ucs4); … … 6035 6101 ushort oldHigh = QChar::highSurrogate(n.old_mapping); 6036 6102 ushort oldLow = QChar::lowSurrogate(n.old_mapping); 6037 int pos = 0; 6038 while (pos < s.d->size - 1) { 6039 if (s.d->data[pos] == ucs4High && s.d->data[pos + 1] == ucs4Low) { 6040 s.detach(); 6041 s.d->data[pos] = oldHigh; 6042 s.d->data[pos + 1] = oldLow; 6103 while (pos < s.length() - 1) { 6104 if (s.at(pos).unicode() == ucs4High && s.at(pos + 1).unicode() == ucs4Low) { 6105 s[pos] = oldHigh; 6106 s[pos + 1] = oldLow; 6043 6107 ++pos; 6044 6108 } … … 6046 6110 } 6047 6111 } else { 6048 int pos = 0; 6049 while (pos < s.d->size) { 6050 if (s.d->data[pos] == n.ucs4) { 6051 s.detach(); 6052 s.d->data[pos] = n.old_mapping; 6112 while (pos < s.length()) { 6113 if (s.at(pos).unicode() == n.ucs4) { 6114 s[pos] = n.old_mapping; 6053 6115 } 6054 6116 ++pos; … … 6058 6120 } 6059 6121 } 6060 s = decomposeHelper(s, mode < QString::NormalizationForm_KD, version);6061 6062 s = canonicalOrderHelper(s, version);6122 ); 6123 6124 ); 6063 6125 6064 6126 if (mode == QString::NormalizationForm_D || mode == QString::NormalizationForm_KD) 6065 return s; 6066 6067 return composeHelper(s); 6068 6127 return; 6128 6129 composeHelper(data, from); 6069 6130 } 6070 6131 … … 6152 6213 *qMax(abs_field_width, larg.length()); 6153 6214 6154 QString result; 6155 result.resize(result_len); 6215 QString result(result_len, Qt::Uninitialized); 6156 6216 QChar *result_buff = (QChar*) result.unicode(); 6157 6217 … … 6452 6512 6453 6513 if (d.occurrences == 0) { 6454 qWarning( "QString::arg: Argument missing: %s, %lld", toLocal8Bit().data(), a);6514 qWarning(; 6455 6515 return *this; 6456 6516 } … … 6495 6555 6496 6556 if (d.occurrences == 0) { 6497 qWarning( "QString::arg: Argument missing: %s, %llu", toLocal8Bit().data(), a);6557 qWarning(; 6498 6558 return *this; 6499 6559 } … … 6896 6956 { 6897 6957 Data *x = static_cast<Data *>(qMalloc(sizeof(Data))); 6958 6898 6959 if (unicode) { 6899 6960 x->data = (ushort *)unicode; … … 6912 6973 \brief The QLatin1String class provides a thin wrapper around an ASCII/Latin-1 encoded string literal. 6913 6974 6914 \ingroup text6975 \ingroup 6915 6976 \reentrant 6916 6977 … … 7174 7235 7175 7236 7176 #if ndef QT_NO_DATASTREAM7237 #if 7177 7238 /*! 7178 7239 \fn QDataStream &operator<<(QDataStream &stream, const QString &string) … … 7534 7595 \reentrant 7535 7596 \ingroup tools 7536 \ingroup text7597 \ingroup 7537 7598 7538 7599 QStringRef provides a read-only subset of the QString API. … … 7721 7782 bool operator==(const QStringRef &s1,const QStringRef &s2) 7722 7783 { return (s1.size() == s2.size() && 7723 (memcmp((char*)s1.unicode(), (char*)s2.unicode(), s1.size()*sizeof(QChar))==0)); } 7784 qMemEquals((const ushort *)s1.unicode(), (const ushort *)s2.unicode(), s1.size())); 7785 } 7724 7786 7725 7787 /*! \relates QStringRef … … 7730 7792 bool operator==(const QString &s1,const QStringRef &s2) 7731 7793 { return (s1.size() == s2.size() && 7732 (memcmp((char*)s1.unicode(), (char*)s2.unicode(), s1.size()*sizeof(QChar))==0)); } 7794 qMemEquals((const ushort *)s1.unicode(), (const ushort *)s2.unicode(), s1.size())); 7795 } 7733 7796 7734 7797 /*! \relates QStringRef
Note:
See TracChangeset
for help on using the changeset viewer.