diff options
Diffstat (limited to 'src/corelib/io/qiodevice.cpp')
-rw-r--r-- | src/corelib/io/qiodevice.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index cf430cf937..b0029e2af7 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -9,17 +9,14 @@ #include "qfile.h" #include "qstringlist.h" #include "qdir.h" -#include "private/qbytearray_p.h" +#include "private/qtools_p.h" #include <algorithm> -#ifdef QIODEVICE_DEBUG -# include <ctype.h> -#endif - QT_BEGIN_NAMESPACE using namespace Qt::StringLiterals; +using namespace QtMiscUtils; [[maybe_unused]] static void debugBinaryString(const char *input, qint64 maxlen) @@ -38,7 +35,7 @@ static void debugBinaryString(const char *input, qint64 maxlen) for (qsizetype j = tmp.size(); j < 16 + 1; ++j) printf(" "); for (qsizetype j = 0; j < tmp.size(); ++j) - printf("%c", isprint(int(uchar(tmp[j]))) ? tmp[j] : '.'); + printf("%c", isAsciiPrintable(tmp[j]) ? tmp[j] : '.'); tmp.clear(); } } @@ -47,6 +44,7 @@ static void debugBinaryString(const char *input, qint64 maxlen) #define Q_VOID +Q_DECL_COLD_FUNCTION static void checkWarnMessage(const QIODevice *device, const char *function, const char *what) { #ifndef QT_NO_WARNING_OUTPUT @@ -90,9 +88,9 @@ static void checkWarnMessage(const QIODevice *device, const char *function, cons #define CHECK_MAXBYTEARRAYSIZE(function) \ do { \ - if (maxSize >= MaxByteArraySize) { \ + if (maxSize >= QByteArray::max_size()) { \ checkWarnMessage(this, #function, "maxSize argument exceeds QByteArray size limit"); \ - maxSize = MaxByteArraySize - 1; \ + maxSize = QByteArray::max_size() - 1; \ } \ } while (0) @@ -1011,7 +1009,7 @@ qint64 QIODevice::read(char *data, qint64 maxSize) *data = c; #if defined QIODEVICE_DEBUG printf("%p \tread 0x%hhx (%c) returning 1 (shortcut)\n", this, - int(c), isprint(c) ? c : '?'); + int(c), isAsciiPrintable(c) ? c : '?'); #endif if (d->buffer.isEmpty()) readData(data, 0); @@ -1244,7 +1242,7 @@ QByteArray QIODevice::readAll() : d->buffer.size()); qint64 readResult; do { - if (readBytes + readChunkSize >= MaxByteArraySize) { + if (readBytes + readChunkSize >= QByteArray::max_size()) { // If resize would fail, don't read more, return what we have. break; } @@ -1258,8 +1256,8 @@ QByteArray QIODevice::readAll() } else { // Read it all in one go. readBytes -= d->pos; - if (readBytes >= MaxByteArraySize) - readBytes = MaxByteArraySize; + if (readBytes >= QByteArray::max_size()) + readBytes = QByteArray::max_size(); result.resize(readBytes); readBytes = d->read(result.data(), readBytes); } @@ -1450,7 +1448,7 @@ QByteArray QIODevice::readLine(qint64 maxSize) qint64 readBytes = 0; if (maxSize == 0) { // Size is unknown, read incrementally. - maxSize = MaxByteArraySize - 1; + maxSize = QByteArray::max_size() - 1; // The first iteration needs to leave an extra byte for the terminating null result.resize(1); @@ -1502,7 +1500,7 @@ qint64 QIODevice::readLineData(char *data, qint64 maxSize) Q_D(QIODevice); qint64 readSoFar = 0; char c; - int lastReadReturn = 0; + qint64 lastReadReturn = 0; d->baseReadLineDataCalled = true; while (readSoFar < maxSize && (lastReadReturn = read(&c, 1)) == 1) { @@ -1792,7 +1790,7 @@ void QIODevice::ungetChar(char c) } #if defined QIODEVICE_DEBUG - printf("%p QIODevice::ungetChar(0x%hhx '%c')\n", this, c, isprint(c) ? c : '?'); + printf("%p QIODevice::ungetChar(0x%hhx '%c')\n", this, c, isAsciiPrintable(c) ? c : '?'); #endif d->buffer.ungetChar(c); |