summaryrefslogtreecommitdiff
path: root/qmake/tools/qdatastream.cpp
Side-by-side diff
Diffstat (limited to 'qmake/tools/qdatastream.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/tools/qdatastream.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/qmake/tools/qdatastream.cpp b/qmake/tools/qdatastream.cpp
index 9c573c7..51a1448 100644
--- a/qmake/tools/qdatastream.cpp
+++ b/qmake/tools/qdatastream.cpp
@@ -729,50 +729,58 @@ QDataStream &QDataStream::readBytes( char *&s, uint &l )
} else {
s = new char[len]; // create char array
Q_CHECK_PTR( s );
if ( !s ) // no memory
return *this;
return readRawBytes( s, (uint)len );
}
}
/*!
Reads \a len bytes from the stream into \a s and returns a
reference to the stream.
The buffer \a s must be preallocated. The data is \e not encoded.
\sa readBytes(), QIODevice::readBlock(), writeRawBytes()
*/
QDataStream &QDataStream::readRawBytes( char *s, uint len )
{
CHECK_STREAM_PRECOND
if ( printable ) { // printable data
register Q_INT8 *p = (Q_INT8*)s;
- while ( len-- )
- *this >> *p++;
+ if ( version() < 4 ) {
+ while ( len-- ) {
+ Q_INT32 tmp;
+ *this >> tmp;
+ *p++ = tmp;
+ }
+ } else {
+ while ( len-- )
+ *this >> *p++;
+ }
} else { // read data char array
dev->readBlock( s, len );
}
return *this;
}
/*****************************************************************************
QDataStream write functions
*****************************************************************************/
/*!
\overload QDataStream &QDataStream::operator<<( Q_UINT8 i )
Writes an unsigned byte, \a i, to the stream and returns a
reference to the stream.
*/
/*!
Writes a signed byte, \a i, to the stream and returns a reference
to the stream.
*/
@@ -991,34 +999,40 @@ QDataStream &QDataStream::operator<<( const char *s )
\sa writeRawBytes(), readBytes()
*/
QDataStream &QDataStream::writeBytes(const char *s, uint len)
{
CHECK_STREAM_PRECOND
*this << (Q_UINT32)len; // write length specifier
if ( len )
writeRawBytes( s, len );
return *this;
}
/*!
Writes \a len bytes from \a s to the stream and returns a
reference to the stream. The data is \e not encoded.
\sa writeBytes(), QIODevice::writeBlock(), readRawBytes()
*/
QDataStream &QDataStream::writeRawBytes( const char *s, uint len )
{
CHECK_STREAM_PRECOND
if ( printable ) { // write printable
- register Q_INT8 *p = (Q_INT8*)s;
- while ( len-- )
- *this << *p++;
+ if ( version() < 4 ) {
+ register char *p = (char *)s;
+ while ( len-- )
+ *this << *p++;
+ } else {
+ register Q_INT8 *p = (Q_INT8*)s;
+ while ( len-- )
+ *this << *p++;
+ }
} else { // write data char array
dev->writeBlock( s, len );
}
return *this;
}
#endif // QT_NO_DATASTREAM