summaryrefslogtreecommitdiffstats
path: root/src/tools/qdatastream.cpp
diff options
context:
space:
mode:
authorDarrell Anderson <[email protected]>2012-06-27 22:55:53 -0500
committerDarrell Anderson <[email protected]>2012-06-27 22:55:53 -0500
commit6d0157ea558089bb957f35263424a405e42a6931 (patch)
tree9ec67137382e70a331acd12cdc8cdf9a6505dd8a /src/tools/qdatastream.cpp
parente07167f4f6448ad4f5565609e5cd56a918d256f8 (diff)
parent224903aa91433fc0d155b26c83823c177a9c3eee (diff)
downloadtqt3-6d0157ea558089bb957f35263424a405e42a6931.tar.gz
tqt3-6d0157ea558089bb957f35263424a405e42a6931.zip
Merge branch 'master' of http://scm.trinitydesktop.org/scm/git/tqt3
Diffstat (limited to 'src/tools/qdatastream.cpp')
-rw-r--r--src/tools/qdatastream.cpp80
1 files changed, 45 insertions, 35 deletions
diff --git a/src/tools/qdatastream.cpp b/src/tools/qdatastream.cpp
index 33cec9b37..7b4f605a7 100644
--- a/src/tools/qdatastream.cpp
+++ b/src/tools/qdatastream.cpp
@@ -544,7 +544,10 @@ TQDataStream &TQDataStream::operator>>( TQ_INT8 &i )
i = (buf[2] & 0x07)+((buf[1] & 0x07) << 3)+((buf[0] & 0x07) << 6);
}
} else { // data or text
- i = (TQ_INT8)dev->getch();
+ int ret = dev->getch();
+ if (ret >= 0) {
+ i = (TQ_INT8)ret;
+ }
}
return *this;
}
@@ -574,9 +577,10 @@ TQDataStream &TQDataStream::operator>>( TQ_INT16 &i )
} else { // swap bytes
register uchar *p = (uchar *)(&i);
char b[2];
- dev->readBlock( b, 2 );
- *p++ = b[1];
- *p = b[0];
+ if (dev->readBlock( b, 2 ) >= 2) {
+ *p++ = b[1];
+ *p = b[0];
+ }
}
return *this;
}
@@ -606,11 +610,12 @@ TQDataStream &TQDataStream::operator>>( TQ_INT32 &i )
} else { // swap bytes
uchar *p = (uchar *)(&i);
char b[4];
- dev->readBlock( b, 4 );
- *p++ = b[3];
- *p++ = b[2];
- *p++ = b[1];
- *p = b[0];
+ if (dev->readBlock( b, 4 ) >= 4) {
+ *p++ = b[3];
+ *p++ = b[2];
+ *p++ = b[1];
+ *p = b[0];
+ }
}
return *this;
}
@@ -643,15 +648,16 @@ TQDataStream &TQDataStream::operator>>( TQ_INT64 &i )
} else { // swap bytes
uchar *p = (uchar *)(&i);
char b[8];
- dev->readBlock( b, 8 );
- *p++ = b[7];
- *p++ = b[6];
- *p++ = b[5];
- *p++ = b[4];
- *p++ = b[3];
- *p++ = b[2];
- *p++ = b[1];
- *p = b[0];
+ if (dev->readBlock( b, 8 ) >= 8) {
+ *p++ = b[7];
+ *p++ = b[6];
+ *p++ = b[5];
+ *p++ = b[4];
+ *p++ = b[3];
+ *p++ = b[2];
+ *p++ = b[1];
+ *p = b[0];
+ }
}
return *this;
}
@@ -683,9 +689,11 @@ TQDataStream &TQDataStream::operator>>( TQ_LONG &i )
} else { // swap bytes
register uchar *p = (uchar *)(&i);
char b[sizeof(TQ_LONG)];
- dev->readBlock( b, sizeof(TQ_LONG) );
- for ( int j = sizeof(TQ_LONG); j; )
- *p++ = b[--j];
+ if (dev->readBlock( b, sizeof(TQ_LONG) ) >= (int)sizeof(TQ_LONG)) {
+ for ( int j = sizeof(TQ_LONG); j; ) {
+ *p++ = b[--j];
+ }
+ }
}
return *this;
}
@@ -724,11 +732,12 @@ TQDataStream &TQDataStream::operator>>( float &f )
} else { // swap bytes
uchar *p = (uchar *)(&f);
char b[4];
- dev->readBlock( b, 4 );
- *p++ = b[3];
- *p++ = b[2];
- *p++ = b[1];
- *p = b[0];
+ if (dev->readBlock( b, 4 ) >= 4) {
+ *p++ = b[3];
+ *p++ = b[2];
+ *p++ = b[1];
+ *p = b[0];
+ }
}
return *this;
}
@@ -752,15 +761,16 @@ TQDataStream &TQDataStream::operator>>( double &f )
} else { // swap bytes
register uchar *p = (uchar *)(&f);
char b[8];
- dev->readBlock( b, 8 );
- *p++ = b[7];
- *p++ = b[6];
- *p++ = b[5];
- *p++ = b[4];
- *p++ = b[3];
- *p++ = b[2];
- *p++ = b[1];
- *p = b[0];
+ if (dev->readBlock( b, 8 ) >= 8) {
+ *p++ = b[7];
+ *p++ = b[6];
+ *p++ = b[5];
+ *p++ = b[4];
+ *p++ = b[3];
+ *p++ = b[2];
+ *p++ = b[1];
+ *p = b[0];
+ }
}
return *this;
}