Kaydet (Commit) 7b2a0e54 authored tarafından Keith McRae's avatar Keith McRae Kaydeden (comit) Kohei Yoshida

fdo#39428 Remove/audit SvStream operator>>/<<(long)

Removed declarations & definitions for operator<<(long),(int)&(short)
Removed declarations & definitions for operator>>(long),(int)&(short)
Added (where necessary) operator<< for sal_Int & sal_uInt types
Added (where necessary) operator>> for sal_Int & sal_uInt types
Added SwapInt64 function, basically a copy of SwapUInt64
üst 80fb2e39
...@@ -338,9 +338,10 @@ public: ...@@ -338,9 +338,10 @@ public:
SvStream& operator>>( sal_uInt16& rUInt16 ); SvStream& operator>>( sal_uInt16& rUInt16 );
SvStream& operator>>( sal_uInt32& rUInt32 ); SvStream& operator>>( sal_uInt32& rUInt32 );
SvStream& operator>>( sal_uInt64& rUInt64 ); SvStream& operator>>( sal_uInt64& rUInt64 );
SvStream& operator>>( long& rLong ); SvStream& operator>>( sal_Int16& rInt16 );
SvStream& operator>>( short& rShort ); SvStream& operator>>( sal_Int32& rInt32 );
SvStream& operator>>( int& rInt ); SvStream& operator>>( sal_Int64& rInt64 );
SvStream& operator>>( signed char& rChar ); SvStream& operator>>( signed char& rChar );
SvStream& operator>>( char& rChar ); SvStream& operator>>( char& rChar );
SvStream& operator>>( unsigned char& rChar ); SvStream& operator>>( unsigned char& rChar );
...@@ -351,9 +352,10 @@ public: ...@@ -351,9 +352,10 @@ public:
SvStream& operator<<( sal_uInt16 nUInt16 ); SvStream& operator<<( sal_uInt16 nUInt16 );
SvStream& operator<<( sal_uInt32 nUInt32 ); SvStream& operator<<( sal_uInt32 nUInt32 );
SvStream& operator<<( sal_uInt64 nuInt64 ); SvStream& operator<<( sal_uInt64 nuInt64 );
SvStream& operator<<( long nLong ); SvStream& operator<<( sal_Int16 nInt16 );
SvStream& operator<<( short nShort ); SvStream& operator<<( sal_Int32 nInt32 );
SvStream& operator<<( int nInt ); SvStream& operator<<( sal_Int64 nInt64 );
SvStream& operator<<( signed char nChar ); SvStream& operator<<( signed char nChar );
SvStream& operator<<( char nChar ); SvStream& operator<<( char nChar );
SvStream& operator<<( unsigned char nChar ); SvStream& operator<<( unsigned char nChar );
......
...@@ -91,6 +91,25 @@ inline static void SwapUInt64( sal_uInt64& r ) ...@@ -91,6 +91,25 @@ inline static void SwapUInt64( sal_uInt64& r )
s.c[1] = SWAPLONG(s.c[1]); s.c[1] = SWAPLONG(s.c[1]);
r = s.n; r = s.n;
} }
inline static void SwapInt64( sal_Int64& r )
{
union
{
sal_Int64 n;
sal_Int32 c[2];
} s;
s.n = r;
s.c[0] ^= s.c[1]; // swap the 32 bit words
s.c[1] ^= s.c[0];
s.c[0] ^= s.c[1];
// swap the bytes in the words
s.c[0] = SWAPLONG(s.c[0]);
s.c[1] = SWAPLONG(s.c[1]);
r = s.n;
}
#ifdef UNX #ifdef UNX
inline static void SwapFloat( float& r ) inline static void SwapFloat( float& r )
{ {
...@@ -1067,7 +1086,6 @@ SvStream& SvStream::operator>>(sal_uInt32& r) ...@@ -1067,7 +1086,6 @@ SvStream& SvStream::operator>>(sal_uInt32& r)
return *this; return *this;
} }
SvStream& SvStream::operator>>(sal_uInt64& r) SvStream& SvStream::operator>>(sal_uInt64& r)
{ {
sal_uInt64 n = 0; sal_uInt64 n = 0;
...@@ -1081,47 +1099,41 @@ SvStream& SvStream::operator>>(sal_uInt64& r) ...@@ -1081,47 +1099,41 @@ SvStream& SvStream::operator>>(sal_uInt64& r)
return *this; return *this;
} }
SvStream& SvStream::operator >>(long& r) //puke!, kill this
SvStream& SvStream::operator>>(sal_Int16& r)
{ {
#if(SAL_TYPES_SIZEOFLONG != 4) sal_Int16 n = 0;
int n; READNUMBER_WITHOUT_SWAP(sal_Int16, n)
*this >> n;
if (good())
r = n;
#else
long n = 0;
READNUMBER_WITHOUT_SWAP(long, n)
if (good()) if (good())
{ {
if (bSwap) if (bSwap)
SwapLong(n); SwapShort(n);
r = n; r = n;
} }
#endif
return *this; return *this;
} }
SvStream& SvStream::operator>>(short& r) SvStream& SvStream::operator>>(sal_Int32& r)
{ {
short n = 0; sal_Int32 n = 0;
READNUMBER_WITHOUT_SWAP(short, n) READNUMBER_WITHOUT_SWAP(sal_Int32, n)
if (good()) if (good())
{ {
if(bSwap) if (bSwap)
SwapShort(n); SwapLongInt(n);
r = n; r = n;
} }
return *this; return *this;
} }
SvStream& SvStream::operator>>(int& r) SvStream& SvStream::operator>>(sal_Int64& r)
{ {
int n = 0; sal_Int64 n = 0;
READNUMBER_WITHOUT_SWAP(int, n) READNUMBER_WITHOUT_SWAP(sal_Int64, n)
if (good()) if (good())
{ {
if (bSwap) if (bSwap)
SwapLongInt(n); SwapInt64(n);
r = n; r = n;
} }
return *this; return *this;
...@@ -1249,32 +1261,27 @@ SvStream& SvStream::operator<< ( sal_uInt64 v ) ...@@ -1249,32 +1261,27 @@ SvStream& SvStream::operator<< ( sal_uInt64 v )
return *this; return *this;
} }
SvStream& SvStream::operator<< ( long v ) SvStream& SvStream::operator<< ( sal_Int16 v )
{ {
#if(SAL_TYPES_SIZEOFLONG != 4)
int tmp = v;
*this << tmp;
#else
if( bSwap ) if( bSwap )
SwapLong(v); SwapShort(v);
WRITENUMBER_WITHOUT_SWAP(long,v) WRITENUMBER_WITHOUT_SWAP(sal_Int16,v)
#endif
return *this; return *this;
} }
SvStream& SvStream::operator<< ( short v ) SvStream& SvStream::operator<< ( sal_Int32 v )
{ {
if( bSwap ) if( bSwap )
SwapShort(v); SwapLongInt(v);
WRITENUMBER_WITHOUT_SWAP(short,v) WRITENUMBER_WITHOUT_SWAP(sal_Int32,v)
return *this; return *this;
} }
SvStream& SvStream::operator<<( int v ) SvStream& SvStream::operator<< ( sal_Int64 v )
{ {
if( bSwap ) if( bSwap )
SwapLongInt( v ); SwapInt64(v);
WRITENUMBER_WITHOUT_SWAP(int,v) WRITENUMBER_WITHOUT_SWAP(sal_Int64,v)
return *this; return *this;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment