Darrell Anderson 13 years ago
commit 6d0157ea55

@ -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,10 +577,11 @@ TQDataStream &TQDataStream::operator>>( TQ_INT16 &i )
} else { // swap bytes
register uchar *p = (uchar *)(&i);
char b[2];
dev->readBlock( b, 2 );
if (dev->readBlock( b, 2 ) >= 2) {
*p++ = b[1];
*p = b[0];
}
}
return *this;
}
@ -606,12 +610,13 @@ TQDataStream &TQDataStream::operator>>( TQ_INT32 &i )
} else { // swap bytes
uchar *p = (uchar *)(&i);
char b[4];
dev->readBlock( b, 4 );
if (dev->readBlock( b, 4 ) >= 4) {
*p++ = b[3];
*p++ = b[2];
*p++ = b[1];
*p = b[0];
}
}
return *this;
}
@ -643,7 +648,7 @@ TQDataStream &TQDataStream::operator>>( TQ_INT64 &i )
} else { // swap bytes
uchar *p = (uchar *)(&i);
char b[8];
dev->readBlock( b, 8 );
if (dev->readBlock( b, 8 ) >= 8) {
*p++ = b[7];
*p++ = b[6];
*p++ = b[5];
@ -653,6 +658,7 @@ TQDataStream &TQDataStream::operator>>( TQ_INT64 &i )
*p++ = b[1];
*p = b[0];
}
}
return *this;
}
@ -683,10 +689,12 @@ 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; )
if (dev->readBlock( b, sizeof(TQ_LONG) ) >= (int)sizeof(TQ_LONG)) {
for ( int j = sizeof(TQ_LONG); j; ) {
*p++ = b[--j];
}
}
}
return *this;
}
#endif
@ -724,12 +732,13 @@ TQDataStream &TQDataStream::operator>>( float &f )
} else { // swap bytes
uchar *p = (uchar *)(&f);
char b[4];
dev->readBlock( b, 4 );
if (dev->readBlock( b, 4 ) >= 4) {
*p++ = b[3];
*p++ = b[2];
*p++ = b[1];
*p = b[0];
}
}
return *this;
}
@ -752,7 +761,7 @@ TQDataStream &TQDataStream::operator>>( double &f )
} else { // swap bytes
register uchar *p = (uchar *)(&f);
char b[8];
dev->readBlock( b, 8 );
if (dev->readBlock( b, 8 ) >= 8) {
*p++ = b[7];
*p++ = b[6];
*p++ = b[5];
@ -762,6 +771,7 @@ TQDataStream &TQDataStream::operator>>( double &f )
*p++ = b[1];
*p = b[0];
}
}
return *this;
}

Loading…
Cancel
Save