Changeset 769 for trunk/src/corelib/io
- Timestamp:
- Aug 2, 2010, 9:27:30 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.3 (added) merged: 768 /branches/vendor/nokia/qt/current merged: 767 /branches/vendor/nokia/qt/4.6.2 removed
- Property svn:mergeinfo changed
-
trunk/src/corelib/io/qdatastream.cpp
r651 r769 157 157 the data (apart from the length quint32) must be done by you. 158 158 159 160 161 162 163 164 159 165 \target Serializing Qt Classes 160 166 \section1 Reading and writing other Qt classes. -
trunk/src/corelib/io/qdir.cpp
r651 r769 1050 1050 /*! 1051 1051 \obsolete 1052 1053 1054 1052 1055 Adds \a path to the search paths searched in to find resources 1053 1056 that are not specified with an absolute path. The default search 1054 1057 path is to search only in the root (\c{:/}). 1055 1058 1056 Use QDir::addSearchPath() with a prefix instead. 1057 1058 \sa {The Qt Resource System}, QResource::addSearchPath() 1059 */ 1060 1059 \sa {The Qt Resource System} 1060 */ 1061 1061 void QDir::addResourceSearchPath(const QString &path) 1062 1062 { -
trunk/src/corelib/io/qfile.cpp
r651 r769 63 63 static QByteArray locale_encode(const QString &f) 64 64 { 65 #ifndef Q_OS_DARWIN 66 return f.toLocal8Bit(); 67 #else 65 #if defined(Q_OS_DARWIN) 68 66 // Mac always expects UTF-8... and decomposed... 69 67 return f.normalized(QString::NormalizationForm_D).toUtf8(); 68 69 70 71 70 72 #endif 71 73 } … … 73 75 static QString locale_decode(const QByteArray &f) 74 76 { 75 #ifndef Q_OS_DARWIN 76 return QString::fromLocal8Bit(f); 77 #else 77 #if defined(Q_OS_DARWIN) 78 78 // Mac always gives us UTF-8 and decomposed, we want that composed... 79 79 return QString::fromUtf8(f).normalized(QString::NormalizationForm_C); 80 81 82 83 80 84 #endif 81 85 } … … 87 91 QFilePrivate::QFilePrivate() 88 92 : fileEngine(0), lastWasWrite(false), 89 writeBuffer(QFILE_WRITEBUFFER_SIZE), error(QFile::NoError) 93 writeBuffer(QFILE_WRITEBUFFER_SIZE), error(QFile::NoError), 94 cachedSize(0) 90 95 { 91 96 } … … 1257 1262 if(d->fileEngine->setSize(sz)) { 1258 1263 unsetError(); 1264 1259 1265 return true; 1260 1266 } 1267 1261 1268 d->setError(QFile::ResizeError, d->fileEngine->errorString()); 1262 1269 return false; … … 1420 1427 if (!d->ensureFlushed()) 1421 1428 return 0; 1422 return fileEngine()->size(); 1429 d->cachedSize = fileEngine()->size(); 1430 return d->cachedSize; 1423 1431 } 1424 1432 … … 1446 1454 Q_D(const QFile); 1447 1455 1456 1457 1458 1459 1448 1460 if (!isOpen()) 1449 1461 return true; 1450 1462 1451 1463 if (!d->ensureFlushed()) 1452 return false;1453 1454 // If there's buffered data left, we're not at the end.1455 if (!d->buffer.isEmpty())1456 1464 return false; 1457 1465 … … 1463 1471 } 1464 1472 1473 1474 1475 1476 1477 1465 1478 // Fall back to checking how much is available (will stat files). 1466 1479 return bytesAvailable() == 0; … … 1502 1515 return -1; 1503 1516 1504 if (d->fileEngine->supportsExtension(QAbstractFileEngine::FastReadLineExtension)) 1505 return d->fileEngine->readLine(data, maxlen); 1506 1507 // Fall back to QIODevice's readLine implementation if the engine 1508 // cannot do it faster. 1509 return QIODevice::readLineData(data, maxlen); 1517 qint64 read; 1518 if (d->fileEngine->supportsExtension(QAbstractFileEngine::FastReadLineExtension)) { 1519 read = d->fileEngine->readLine(data, maxlen); 1520 } else { 1521 // Fall back to QIODevice's readLine implementation if the engine 1522 // cannot do it faster. 1523 read = QIODevice::readLineData(data, maxlen); 1524 } 1525 1526 if (read < maxlen) { 1527 // failed to read all requested, may be at the end of file, stop caching size so that it's rechecked 1528 d->cachedSize = 0; 1529 } 1530 1531 return read; 1510 1532 } 1511 1533 … … 1528 1550 d->setError(err, d->fileEngine->errorString()); 1529 1551 } 1552 1553 1554 1555 1556 1557 1530 1558 return read; 1531 1559 } -
trunk/src/corelib/io/qfile_p.h
r651 r769 85 85 void setError(QFile::FileError err, int errNum); 86 86 87 88 87 89 private: 88 90 static QFile::EncoderFn encoder; -
trunk/src/corelib/io/qfilesystemwatcher_kqueue.cpp
r651 r769 261 261 DEBUG() << "QKqueueFileSystemWatcherEngine: processing kevent" << kev.ident << kev.filter; 262 262 if (fd == kqpipe[0]) { 263 char c; 264 if (read(kqpipe[0], &c, 1) != 1) { 263 // read all pending data from the pipe 264 QByteArray ba; 265 ba.resize(kev.data); 266 if (read(kqpipe[0], ba.data(), ba.size()) != ba.size()) { 265 267 perror("QKqueueFileSystemWatcherEngine: error reading from pipe"); 266 268 return; 267 269 } 268 switch (c) { 270 // read the command from the buffer (but break and return on 'q') 271 char cmd = 0; 272 for (int i = 0; i < ba.size(); ++i) { 273 cmd = ba.constData()[i]; 274 if (cmd == 'q') 275 break; 276 } 277 // handle the command 278 switch (cmd) { 269 279 case 'q': 270 280 DEBUG() << "QKqueueFileSystemWatcherEngine: thread received 'q', exiting..."; … … 274 284 break; 275 285 default: 276 DEBUG() << "QKqueueFileSystemWatcherEngine: thread received unknow message" << c ;286 DEBUG() << "QKqueueFileSystemWatcherEngine: thread received unknow message" << c; 277 287 break; 278 288 } -
trunk/src/corelib/io/qfsfileengine.cpp
r690 r769 146 146 // Mac OS X 10.5.x doesn't support the realpath(X,0) extenstion we use here. 147 147 #if defined(Q_OS_LINUX) || defined(Q_OS_SYMBIAN) 148 149 148 150 char *ret = realpath(path.toLocal8Bit().constData(), (char*)0); 149 151 if (ret) { … … 152 154 return canonicalPath; 153 155 } 156 154 157 #endif 155 158 -
trunk/src/corelib/io/qfsfileengine_p.h
r651 r769 152 152 #endif 153 153 154 155 156 157 154 158 protected: 155 159 QFSFileEnginePrivate(); -
trunk/src/corelib/io/qfsfileengine_unix.cpp
r651 r769 82 82 || (fileName.at(0) == QLatin1Char('/') && fileName.at(1) == QLatin1Char('/'))))); 83 83 } 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 84 118 #endif 85 119 … … 99 133 && QT_STAT(QFile::encodeName(fileName), &statBuf) == 0 100 134 && (statBuf.st_mode & S_IFMT) == S_IFREG) { 101 mode += "+";135 mode += ; 102 136 } else { 103 137 mode = "wb+"; … … 428 462 ) // End TRAP 429 463 delete fm; 430 // ### Add error reporting on failure 431 return (err == KErrNone); 464 if (err == KErrNone) 465 return true; 466 d->setSymbianError(err, QFile::CopyError, QLatin1String("copy error")); 467 return false; 432 468 #else 433 469 Q_UNUSED(newName); … … 669 705 } else if (fd == -1) { 670 706 // ### actually covers two cases: d->fh and when the file is not open 707 708 709 710 711 712 713 714 715 716 671 717 could_stat = (QT_STAT(nativeFilePath.constData(), &st) == 0); 672 718 } else { … … 1271 1317 int extra = offset % pageSize; 1272 1318 1273 if ( size + extra > (size_t)-1) {1319 if () { 1274 1320 q->setError(QFile::UnspecifiedError, qt_error_string(int(EINVAL))); 1275 1321 return 0; -
trunk/src/corelib/io/qfsfileengine_win.cpp
r651 r769 1485 1485 //### what to do with permissions if we don't use NTFS 1486 1486 // for now just add all permissions and what about exe missions ?? 1487 // also qt_ntfs_permission_lookup is now not set by def ualt ... should it ?1487 // also qt_ntfs_permission_lookup is now not set by deflt ... should it ? 1488 1488 ret |= QAbstractFileEngine::ReadOtherPerm | QAbstractFileEngine::ReadGroupPerm 1489 1489 | QAbstractFileEngine::ReadOwnerPerm | QAbstractFileEngine::ReadUserPerm -
trunk/src/corelib/io/qiodevice.cpp
r651 r769 85 85 #endif 86 86 87 #ifndef QIODEVICE_BUFFERSIZE88 #define QIODEVICE_BUFFERSIZE Q_INT64_C(16384)89 #endif90 91 87 #define Q_VOID 92 88 … … 124 120 : openMode(QIODevice::NotOpen), buffer(QIODEVICE_BUFFERSIZE), 125 121 pos(0), devicePos(0) 122 126 123 , baseReadLineDataCalled(false) 124 127 125 , accessMode(Unset) 128 126 #ifdef QT_NO_QOBJECT … … 283 281 meaningless when used with some subclasses. Some of these 284 282 restrictions are implied by the type of device that is represented 285 by a subclass; for example, access to a QBuffer is always 286 unbuffered. In other cases, the restriction may be due to the 283 by a subclass. In other cases, the restriction may be due to the 287 284 implementation, or may be imposed by the underlying platform; for 288 285 example, QTcpSocket does not support \c Unbuffered mode, and … … 451 448 void QIODevice::setOpenMode(OpenMode openMode) 452 449 { 450 453 451 #if defined QIODEVICE_DEBUG 454 452 printf("%p QIODevice::setOpenMode(0x%x)\n", this, int(openMode)); 455 453 #endif 456 d_func()->openMode = openMode; 457 d_func()->accessMode = QIODevicePrivate::Unset; 454 d->openMode = openMode; 455 d->accessMode = QIODevicePrivate::Unset; 456 d->firstRead = true; 457 if (!isReadable()) 458 d->buffer.clear(); 458 459 } 459 460 … … 539 540 d->buffer.clear(); 540 541 d->accessMode = QIODevicePrivate::Unset; 542 541 543 #if defined QIODEVICE_DEBUG 542 544 printf("%p QIODevice::open(0x%x)\n", this, quint32(mode)); … … 568 570 d->pos = 0; 569 571 d->buffer.clear(); 572 570 573 } 571 574 … … 731 734 } 732 735 736 737 738 739 740 741 733 742 /*! 734 743 Reads at most \a maxSize bytes from the device into \a data, and … … 747 756 { 748 757 Q_D(QIODevice); 749 CHECK_READABLE(read, qint64(-1));750 CHECK_MAXLEN(read, qint64(-1));751 758 752 759 #if defined QIODEVICE_DEBUG … … 754 761 this, data, int(maxSize), int(d->pos), int(d->buffer.size())); 755 762 #endif 756 const bool sequential = d->isSequential();757 763 758 764 // Short circuit for getChar() … … 760 766 int chint; 761 767 while ((chint = d->buffer.getChar()) != -1) { 762 if (!sequential) 763 ++d->pos; 768 ++(*d->pPos); 764 769 765 770 char c = char(uchar(chint)); … … 775 780 } 776 781 782 777 783 qint64 readSoFar = 0; 778 784 bool moreToRead = true; 779 785 do { 780 int lastReadChunkSize = 0;781 782 786 // Try reading from the buffer. 783 if (!d->buffer.isEmpty()) { 784 lastReadChunkSize = d->buffer.read(data + readSoFar, maxSize - readSoFar); 787 int lastReadChunkSize = d->buffer.read(data, maxSize); 788 if (lastReadChunkSize > 0) { 789 *d->pPos += lastReadChunkSize; 785 790 readSoFar += lastReadChunkSize; 786 if (!sequential) 787 d->pos += lastReadChunkSize; 791 // fast exit when satisfied by buffer 792 if (lastReadChunkSize == maxSize && !(d->openMode & Text)) 793 return readSoFar; 794 795 data += lastReadChunkSize; 796 maxSize -= lastReadChunkSize; 788 797 #if defined QIODEVICE_DEBUG 789 798 printf("%p \treading %d bytes from buffer into position %d\n", this, lastReadChunkSize, 790 799 int(readSoFar) - lastReadChunkSize); 791 800 #endif 792 } else if ((d->openMode & Unbuffered) == 0 && maxSize < QIODEVICE_BUFFERSIZE) { 793 // In buffered mode, we try to fill up the QIODevice buffer before 794 // we do anything else. 795 int bytesToBuffer = qMax(maxSize - readSoFar, QIODEVICE_BUFFERSIZE); 796 char *writePointer = d->buffer.reserve(bytesToBuffer); 797 798 // Make sure the device is positioned correctly. 799 if (d->pos != d->devicePos && !sequential && !seek(d->pos)) 800 return qint64(-1); 801 qint64 readFromDevice = readData(writePointer, bytesToBuffer); 802 d->buffer.chop(bytesToBuffer - (readFromDevice < 0 ? 0 : int(readFromDevice))); 803 804 if (readFromDevice > 0) { 805 if (!sequential) 806 d->devicePos += readFromDevice; 807 #if defined QIODEVICE_DEBUG 808 printf("%p \treading %d from device into buffer\n", this, int(readFromDevice)); 809 #endif 810 811 if (readFromDevice < bytesToBuffer) 812 d->buffer.truncate(int(readFromDevice)); 813 if (!d->buffer.isEmpty()) { 814 lastReadChunkSize = d->buffer.read(data + readSoFar, maxSize - readSoFar); 815 readSoFar += lastReadChunkSize; 816 if (!sequential) 817 d->pos += lastReadChunkSize; 818 #if defined QIODEVICE_DEBUG 819 printf("%p \treading %d bytes from buffer at position %d\n", this, 820 lastReadChunkSize, int(readSoFar)); 821 #endif 801 } else { 802 if (d->firstRead) { 803 // this is the first time the file has been read, check it's valid and set up pos pointers 804 // for fast pos updates. 805 CHECK_READABLE(read, qint64(-1)); 806 d->firstRead = false; 807 if (d->isSequential()) { 808 d->pPos = &d->seqDumpPos; 809 d->pDevicePos = &d->seqDumpPos; 810 } 811 } 812 813 if (!maxSize) 814 return readSoFar; 815 816 if ((d->openMode & Unbuffered) == 0 && maxSize < QIODEVICE_BUFFERSIZE) { 817 // In buffered mode, we try to fill up the QIODevice buffer before 818 // we do anything else. 819 // buffer is empty at this point, try to fill it 820 int bytesToBuffer = QIODEVICE_BUFFERSIZE; 821 char *writePointer = d->buffer.reserve(bytesToBuffer); 822 823 // Make sure the device is positioned correctly. 824 if (d->pos != d->devicePos && !d->isSequential() && !seek(d->pos)) 825 return readSoFar ? readSoFar : qint64(-1); 826 qint64 readFromDevice = readData(writePointer, bytesToBuffer); 827 d->buffer.chop(bytesToBuffer - (readFromDevice < 0 ? 0 : int(readFromDevice))); 828 829 if (readFromDevice > 0) { 830 *d->pDevicePos += readFromDevice; 831 #if defined QIODEVICE_DEBUG 832 printf("%p \treading %d from device into buffer\n", this, int(readFromDevice)); 833 #endif 834 835 if (!d->buffer.isEmpty()) { 836 lastReadChunkSize = d->buffer.read(data, maxSize); 837 readSoFar += lastReadChunkSize; 838 data += lastReadChunkSize; 839 maxSize -= lastReadChunkSize; 840 *d->pPos += lastReadChunkSize; 841 #if defined QIODEVICE_DEBUG 842 printf("%p \treading %d bytes from buffer at position %d\n", this, 843 lastReadChunkSize, int(readSoFar)); 844 #endif 845 } 822 846 } 823 847 } … … 825 849 826 850 // If we need more, try reading from the device. 827 if ( readSoFar < maxSize) {851 if () { 828 852 // Make sure the device is positioned correctly. 829 if (d->pos != d->devicePos && ! sequential&& !seek(d->pos))830 return qint64(-1);831 qint64 readFromDevice = readData(data + readSoFar, maxSize - readSoFar);853 if (d->pos != d->devicePos && ! && !seek(d->pos)) 854 return qint64(-1); 855 qint64 readFromDevice = readData(data); 832 856 #if defined QIODEVICE_DEBUG 833 857 printf("%p \treading %d bytes from device (total %d)\n", this, int(readFromDevice), int(readSoFar)); … … 837 861 return -1; 838 862 } 839 if (readFromDevice <= 0) { 840 moreToRead = false; 841 } else { 842 // see if we read as much data as we asked for 843 if (readFromDevice < maxSize - readSoFar) 844 moreToRead = false; 845 863 if (readFromDevice > 0) { 846 864 lastReadChunkSize += int(readFromDevice); 847 865 readSoFar += readFromDevice; 848 if (!sequential) {849 d->pos += readFromDevice;850 d->devicePos += readFromDevice;851 }866 867 = readFromDevice; 868 Pos += readFromDevice; 869 852 870 } 853 } else {854 moreToRead = false;855 871 } 872 873 856 874 857 875 if (readSoFar && d->openMode & Text) { 858 char *readPtr = data + readSoFar- lastReadChunkSize;859 const char *endPtr = data + readSoFar;876 char *readPtr = data - lastReadChunkSize; 877 const char *endPtr = data; 860 878 861 879 if (readPtr < endPtr) { … … 872 890 if (ch != '\r') 873 891 *writePtr++ = ch; 874 else 892 else 875 893 --readSoFar; 894 895 896 876 897 } 877 898 … … 887 908 printf("%p \treturning %d, d->pos == %d, d->buffer.size() == %d\n", this, 888 909 int(readSoFar), int(d->pos), d->buffer.size()); 889 debugBinaryString(data , readSoFar);910 debugBinaryString(data, readSoFar); 890 911 #endif 891 912 return readSoFar; 892 913 } 914 915 916 917 893 918 894 919 /*! … … 999 1024 } 1000 1025 1026 1027 1028 1029 1030 1031 1001 1032 /*! 1002 1033 This function reads a line of ASCII characters from the device, up … … 1004 1035 data, and returns the number of bytes read. If a line could not be 1005 1036 read but no error ocurred, this function returns 0. If an error 1006 occurs, this function returns what it could the length of what1007 could be read, or-1 if nothing was read.1037 occurs, this function returns 1038 -1 if nothing was read. 1008 1039 1009 1040 A terminating '\0' byte is always appended to \a data, so \a … … 1230 1261 return readSoFar; 1231 1262 } 1263 1264 1265 1266 1232 1267 1233 1268 /*! … … 1418 1453 bool QIODevice::getChar(char *c) 1419 1454 { 1420 Q_D(QIODevice); 1421 CHECK_READABLE(getChar, false); 1422 1455 // readability checked in read() 1423 1456 char ch; 1424 1457 return (1 == read(c ? c : &ch, 1)); -
trunk/src/corelib/io/qiodevice_p.h
r651 r769 65 65 QT_BEGIN_NAMESPACE 66 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 67 187 class Q_CORE_EXPORT QIODevicePrivate 68 188 #ifndef QT_NO_QOBJECT … … 79 199 QString errorString; 80 200 81 Q RingBuffer buffer;201 QBuffer buffer; 82 202 qint64 pos; 83 203 qint64 devicePos; 204 205 206 207 84 208 bool baseReadLineDataCalled; 209 85 210 86 211 virtual bool putCharHelper(char c); -
trunk/src/corelib/io/qprocess.cpp
r651 r769 552 552 the interpreter to execute the desired command. 553 553 554 555 556 557 558 559 560 561 562 563 554 564 \sa QBuffer, QFile, QTcpSocket 555 565 */ … … 2030 2040 calling kill(). 2031 2041 2042 2043 2044 2032 2045 \note Terminating running processes from other processes will typically 2033 2046 cause a panic in Symbian due to platform security. 2034 2047 2048 2035 2049 \sa kill() 2036 2050 */ … … 2047 2061 SIGKILL signal is sent to the process. 2048 2062 2063 2064 2065 2066 2049 2067 \sa terminate() 2050 2068 */ -
trunk/src/corelib/io/qprocess_symbian.cpp
r651 r769 238 238 endQuote += QLatin1String("\\"); 239 239 } 240 commandLine += QLatin1String(" \"") + tmp.left(i) + endQuote;240 commandLine += QLatin1String("; 241 241 } else { 242 commandLine += QLatin1Char(' ') + tmp;242 commandLine += ; 243 243 } 244 244 } 245 246 247 248 245 249 } 246 250 … … 372 376 QProcessActive::~QProcessActive() 373 377 { 378 374 379 process = NULL; 375 380 pproc = NULL; … … 478 483 QProcessManagerMediator::~QProcessManagerMediator() 479 484 { 485 480 486 processManagerThread.Close(); 481 487 currentCommand = ENoCommand; -
trunk/src/corelib/io/qprocess_unix.cpp
r651 r769 784 784 // did we read an error message? 785 785 if (i > 0) 786 q_func()->setErrorString(QString ::fromUtf16(buf, i / sizeof(QChar)));786 q_func()->setErrorString(QStringbuf, i / sizeof(QChar))); 787 787 788 788 return i <= 0; -
trunk/src/corelib/io/qresource.cpp
r651 r769 556 556 \obsolete 557 557 558 559 558 560 Adds \a path to the search paths searched in to find resources that are 559 561 not specified with an absolute path. The \a path must be an absolute … … 562 564 The default search path is to search only in the root (\c{:/}). The last 563 565 path added will be consulted first upon next QResource creation. 564 565 Use QDir::addSearchPath() with a prefix instead. 566 */ 567 566 */ 568 567 void 569 568 QResource::addSearchPath(const QString &path) … … 579 578 580 579 /*! 580 581 582 583 581 584 Returns the current search path list. This list is consulted when 582 585 creating a relative resource. -
trunk/src/corelib/io/qsettings.cpp
r651 r769 1092 1092 } 1093 1093 1094 static QString getPath(QSettings::Format format, QSettings::Scope scope) 1095 { 1096 Q_ASSERT((int)QSettings::NativeFormat == 0); 1097 Q_ASSERT((int)QSettings::IniFormat == 1); 1098 1094 static void initDefaultPaths(QMutexLocker *locker) 1095 { 1096 PathHash *pathHash = pathHashFunc(); 1099 1097 QString homePath = QDir::homePath(); 1100 1098 QString systemPath; 1101 1099 1102 QMutexLocker locker(globalMutex()); 1103 PathHash *pathHash = pathHashFunc(); 1104 bool loadSystemPath = pathHash->isEmpty(); 1105 locker.unlock(); 1106 1107 if (loadSystemPath) { 1108 /* 1109 QLibraryInfo::location() uses QSettings, so in order to 1110 avoid a dead-lock, we can't hold the global mutex while 1111 calling it. 1112 */ 1113 systemPath = QLibraryInfo::location(QLibraryInfo::SettingsPath); 1114 systemPath += QLatin1Char('/'); 1115 } 1116 1117 locker.relock(); 1100 locker->unlock(); 1101 1102 /* 1103 QLibraryInfo::location() uses QSettings, so in order to 1104 avoid a dead-lock, we can't hold the global mutex while 1105 calling it. 1106 */ 1107 systemPath = QLibraryInfo::location(QLibraryInfo::SettingsPath); 1108 systemPath += QLatin1Char('/'); 1109 1110 locker->relock(); 1118 1111 if (pathHash->isEmpty()) { 1119 1112 /* … … 1173 1166 #endif 1174 1167 } 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1175 1179 1176 1180 QString result = pathHash->value(pathHashKey(format, scope)); … … 3483 3487 QMutexLocker locker(globalMutex()); 3484 3488 PathHash *pathHash = pathHashFunc(); 3489 3490 3485 3491 pathHash->insert(pathHashKey(format, scope), path + QDir::separator()); 3486 3492 } -
trunk/src/corelib/io/qurl.cpp
r651 r769 339 339 bool hasFragment; 340 340 bool isValid; 341 341 342 342 343 char valueDelimiter; … … 438 439 439 440 // scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) 440 static voidQT_FASTCALL _scheme(const char **ptr, QUrlParseData *parseData)441 static QT_FASTCALL _scheme(const char **ptr, QUrlParseData *parseData) 441 442 { 442 443 bool first = true; 444 443 445 444 446 parseData->scheme = *ptr; … … 447 449 if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) { 448 450 ; 449 } else if (!first && ((ch >= '0' && ch <= '9') || ch == '+' || ch == '-' || ch == '.')) { 450 ; 451 } else if ((ch >= '0' && ch <= '9') || ch == '+' || ch == '-' || ch == '.') { 452 if (first) 453 isSchemeValid = false; 451 454 } else { 452 455 break; … … 458 461 459 462 if (**ptr != ':') { 463 460 464 *ptr = parseData->scheme; 461 465 } else { … … 463 467 ++(*ptr); // skip ':' 464 468 } 469 470 465 471 } 466 472 … … 2986 2992 if (c == '-' || (c >= '0' && c <= '9') 2987 2993 || (c >= 'A' && c <= 'Z') 2988 || (c >= 'a' && c <= 'z')) 2994 || (c >= 'a' && c <= 'z') 2995 //underscore is not supposed to be allowed, but other browser accept it (QTBUG-7434) 2996 || c == '_') 2989 2997 continue; 2990 2998 … … 3125 3133 3126 3134 static const char * const idn_whitelist[] = { 3127 "ac", "a t",3128 "b r",3135 "ac", "at", 3136 "br", 3129 3137 "cat", "ch", "cl", "cn", 3130 3138 "de", "dk", 3139 3131 3140 "fi", 3132 3141 "gr", … … 3142 3151 "th", "tm", "tw", 3143 3152 "vn", 3153 3154 3155 3144 3156 }; 3145 3157 … … 3242 3254 int idx = nextDotDelimiter(domain, lastIdx); 3243 3255 int labelLength = idx - lastIdx; 3244 if (labelLength == 0) 3256 if (labelLength == 0) { 3257 if (idx == domain.length()) 3258 break; 3245 3259 return QString(); // two delimiters in a row -- empty label not allowed 3260 3246 3261 3247 3262 // RFC 3490 says, about the ToASCII operation: … … 3297 3312 labelLength = result.length() - prevLen; 3298 3313 register int toReserve = labelLength + 4 + 6; // "xn--" plus some extra bytes 3314 3299 3315 if (toReserve > aceForm.capacity()) 3300 3316 aceForm.reserve(toReserve); … … 3333 3349 port = -1; 3334 3350 isValid = false; 3351 3335 3352 parsingMode = QUrl::TolerantMode; 3336 3353 valueDelimiter = '='; … … 3359 3376 hasFragment(copy.hasFragment), 3360 3377 isValid(copy.isValid), 3378 3361 3379 valueDelimiter(copy.valueDelimiter), 3362 3380 pairDelimiter(copy.pairDelimiter), … … 3389 3407 } else { 3390 3408 that->host = qt_ACE_do(host, NormalizeAce); 3409 3410 3391 3411 } 3392 3412 return that->host; … … 3465 3485 void QUrlPrivate::setAuthority(const QString &auth) 3466 3486 { 3487 3467 3488 if (auth.isEmpty()) 3468 3489 return; … … 3741 3762 3742 3763 // optional scheme 3743 _scheme(ptr, &parseData); 3764 bool isSchemeValid = _scheme(ptr, &parseData); 3765 3766 if (isSchemeValid == false) { 3767 that->isValid = false; 3768 char ch = *((*ptr)++); 3769 that->errorInfo.setParams(*ptr, QT_TRANSLATE_NOOP(QUrl, "unexpected URL scheme"), 3770 0, ch); 3771 QURL_SETFLAG(that->stateFlags, Validated | Parsed); 3772 #if defined (QURL_DEBUG) 3773 qDebug("QUrlPrivate::parse(), unrecognized: %c%s", ch, *ptr); 3774 #endif 3775 return; 3776 } 3744 3777 3745 3778 // hierpart … … 4143 4176 if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Validated)) d->validate(); 4144 4177 4145 return d->isValid ;4178 return d->isValid; 4146 4179 } 4147 4180 … … 4395 4428 detach(); 4396 4429 QURL_UNSETFLAG(d->stateFlags, QUrlPrivate::Validated | QUrlPrivate::Normalized); 4397 4398 4430 d->setAuthority(authority); 4399 4431 } … … 4616 4648 if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse(); 4617 4649 detach(); 4650 4618 4651 QURL_UNSETFLAG(d->stateFlags, QUrlPrivate::Validated | QUrlPrivate::Normalized | QUrlPrivate::HostCanonicalized); 4619 4652
Note:
See TracChangeset
for help on using the changeset viewer.