summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorKeith McRae <keithcoder@gmail.com>2012-01-18 14:51:03 +0000
committerKohei Yoshida <kohei.yoshida@suse.com>2012-01-18 22:56:12 -0500
commit7b2a0e541567be9750dfc7d98374555967da3470 (patch)
tree4b61fc9c79db8417d2474f872e1353e8e9db3d25 /tools
parent80fb2e397a60550de72b378215c2e305b29257a9 (diff)
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
Diffstat (limited to 'tools')
-rw-r--r--tools/inc/tools/stream.hxx14
-rw-r--r--tools/source/stream/stream.cxx77
2 files changed, 50 insertions, 41 deletions
diff --git a/tools/inc/tools/stream.hxx b/tools/inc/tools/stream.hxx
index e96f3e14f022..37b7c3f96ab7 100644
--- a/tools/inc/tools/stream.hxx
+++ b/tools/inc/tools/stream.hxx
@@ -338,9 +338,10 @@ public:
SvStream& operator>>( sal_uInt16& rUInt16 );
SvStream& operator>>( sal_uInt32& rUInt32 );
SvStream& operator>>( sal_uInt64& rUInt64 );
- SvStream& operator>>( long& rLong );
- SvStream& operator>>( short& rShort );
- SvStream& operator>>( int& rInt );
+ SvStream& operator>>( sal_Int16& rInt16 );
+ SvStream& operator>>( sal_Int32& rInt32 );
+ SvStream& operator>>( sal_Int64& rInt64 );
+
SvStream& operator>>( signed char& rChar );
SvStream& operator>>( char& rChar );
SvStream& operator>>( unsigned char& rChar );
@@ -351,9 +352,10 @@ public:
SvStream& operator<<( sal_uInt16 nUInt16 );
SvStream& operator<<( sal_uInt32 nUInt32 );
SvStream& operator<<( sal_uInt64 nuInt64 );
- SvStream& operator<<( long nLong );
- SvStream& operator<<( short nShort );
- SvStream& operator<<( int nInt );
+ SvStream& operator<<( sal_Int16 nInt16 );
+ SvStream& operator<<( sal_Int32 nInt32 );
+ SvStream& operator<<( sal_Int64 nInt64 );
+
SvStream& operator<<( signed char nChar );
SvStream& operator<<( char nChar );
SvStream& operator<<( unsigned char nChar );
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 7a9bf0df18a3..6064a77ed9e9 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -91,6 +91,25 @@ inline static void SwapUInt64( sal_uInt64& r )
s.c[1] = SWAPLONG(s.c[1]);
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
inline static void SwapFloat( float& r )
{
@@ -1067,7 +1086,6 @@ SvStream& SvStream::operator>>(sal_uInt32& r)
return *this;
}
-
SvStream& SvStream::operator>>(sal_uInt64& r)
{
sal_uInt64 n = 0;
@@ -1081,47 +1099,41 @@ SvStream& SvStream::operator>>(sal_uInt64& r)
return *this;
}
-SvStream& SvStream::operator >>(long& r) //puke!, kill this
+
+SvStream& SvStream::operator>>(sal_Int16& r)
{
-#if(SAL_TYPES_SIZEOFLONG != 4)
- int n;
- *this >> n;
- if (good())
- r = n;
-#else
- long n = 0;
- READNUMBER_WITHOUT_SWAP(long, n)
+ sal_Int16 n = 0;
+ READNUMBER_WITHOUT_SWAP(sal_Int16, n)
if (good())
{
if (bSwap)
- SwapLong(n);
+ SwapShort(n);
r = n;
}
-#endif
return *this;
}
-SvStream& SvStream::operator>>(short& r)
+SvStream& SvStream::operator>>(sal_Int32& r)
{
- short n = 0;
- READNUMBER_WITHOUT_SWAP(short, n)
+ sal_Int32 n = 0;
+ READNUMBER_WITHOUT_SWAP(sal_Int32, n)
if (good())
{
- if(bSwap)
- SwapShort(n);
+ if (bSwap)
+ SwapLongInt(n);
r = n;
}
return *this;
}
-SvStream& SvStream::operator>>(int& r)
+SvStream& SvStream::operator>>(sal_Int64& r)
{
- int n = 0;
- READNUMBER_WITHOUT_SWAP(int, n)
+ sal_Int64 n = 0;
+ READNUMBER_WITHOUT_SWAP(sal_Int64, n)
if (good())
{
if (bSwap)
- SwapLongInt(n);
+ SwapInt64(n);
r = n;
}
return *this;
@@ -1249,32 +1261,27 @@ SvStream& SvStream::operator<< ( sal_uInt64 v )
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 )
- SwapLong(v);
- WRITENUMBER_WITHOUT_SWAP(long,v)
-#endif
+ SwapShort(v);
+ WRITENUMBER_WITHOUT_SWAP(sal_Int16,v)
return *this;
}
-SvStream& SvStream::operator<< ( short v )
+SvStream& SvStream::operator<< ( sal_Int32 v )
{
if( bSwap )
- SwapShort(v);
- WRITENUMBER_WITHOUT_SWAP(short,v)
+ SwapLongInt(v);
+ WRITENUMBER_WITHOUT_SWAP(sal_Int32,v)
return *this;
}
-SvStream& SvStream::operator<<( int v )
+SvStream& SvStream::operator<< ( sal_Int64 v )
{
if( bSwap )
- SwapLongInt( v );
- WRITENUMBER_WITHOUT_SWAP(int,v)
+ SwapInt64(v);
+ WRITENUMBER_WITHOUT_SWAP(sal_Int64,v)
return *this;
}