diff options
author | Oliver Bolte <obo@openoffice.org> | 2008-01-10 12:25:29 +0000 |
---|---|---|
committer | Oliver Bolte <obo@openoffice.org> | 2008-01-10 12:25:29 +0000 |
commit | 5baa848c5a0873ad358fae86c185d8cd490dcc90 (patch) | |
tree | 1e74b957226306743a31464df972cd9dfb25c27e /sal/rtl/source | |
parent | 15f17b3dbe4609db908c56367ac008c28c9ed749 (diff) |
INTEGRATION: CWS xmlfilter02 (1.22.112); FILE MERGED
2007/05/08 10:27:55 dr 1.22.112.2: RESYNC: (1.22-1.24); FILE MERGED
2007/02/27 12:32:15 sb 1.22.112.1: #i74781# Fixed rtl::O[U]String::toInt32/64 to silently overflow instead of ignoring trailing input digits.
Diffstat (limited to 'sal/rtl/source')
-rw-r--r-- | sal/rtl/source/strtmpl.c | 47 |
1 files changed, 8 insertions, 39 deletions
diff --git a/sal/rtl/source/strtmpl.c b/sal/rtl/source/strtmpl.c index 5622e3f1f055..3b3387b11528 100644 --- a/sal/rtl/source/strtmpl.c +++ b/sal/rtl/source/strtmpl.c @@ -4,9 +4,9 @@ * * $RCSfile: strtmpl.c,v $ * - * $Revision: 1.24 $ + * $Revision: 1.25 $ * - * last change: $Author: rt $ $Date: 2007-04-03 14:06:07 $ + * last change: $Author: obo $ $Date: 2008-01-10 13:25:29 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -852,15 +852,10 @@ sal_Bool SAL_CALL IMPL_RTL_STRNAME( toBoolean )( const IMPL_RTL_STRCODE* pStr ) /* ----------------------------------------------------------------------- */ -#define INT32_MIN_VALUE ((sal_Int32)0x80000000); -#define INT32_MAX_VALUE ((sal_Int32)0x7fffffff); - sal_Int32 SAL_CALL IMPL_RTL_STRNAME( toInt32 )( const IMPL_RTL_STRCODE* pStr, sal_Int16 nRadix ) { sal_Bool bNeg; - sal_Int32 nLimit; - sal_Int32 nMultMin; sal_Int16 nDigit; sal_Int32 n = 0; @@ -874,7 +869,6 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( toInt32 )( const IMPL_RTL_STRCODE* pStr, if ( *pStr == '-' ) { bNeg = sal_True; - nLimit = INT32_MIN_VALUE; pStr++; } else @@ -882,9 +876,7 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( toInt32 )( const IMPL_RTL_STRCODE* pStr, if ( *pStr == '+' ) pStr++; bNeg = sal_False; - nLimit = -INT32_MAX_VALUE; } - nMultMin = nLimit / nRadix; while ( *pStr ) { @@ -892,39 +884,24 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( toInt32 )( const IMPL_RTL_STRCODE* pStr, if ( nDigit < 0 ) break; - if ( n < nMultMin ) - break; - n *= nRadix; - if ( n < (nLimit+nDigit) ) - break; - n -= nDigit; + n += nDigit; pStr++; } if ( bNeg ) - return n; - else return -n; + else + return n; } /* ----------------------------------------------------------------------- */ -#ifndef WNT -#define INT64_MIN_VALUE 0x8000000000000000LL; -#define INT64_MAX_VALUE 0x7fffffffffffffffLL; -#else -#define INT64_MIN_VALUE 0x8000000000000000L; -#define INT64_MAX_VALUE 0x7fffffffffffffffL; -#endif - sal_Int64 SAL_CALL IMPL_RTL_STRNAME( toInt64 )( const IMPL_RTL_STRCODE* pStr, sal_Int16 nRadix ) { sal_Bool bNeg; - sal_Int64 nLimit; - sal_Int64 nMultMin; sal_Int16 nDigit; sal_Int64 n = 0; @@ -938,7 +915,6 @@ sal_Int64 SAL_CALL IMPL_RTL_STRNAME( toInt64 )( const IMPL_RTL_STRCODE* pStr, if ( *pStr == '-' ) { bNeg = sal_True; - nLimit = INT64_MIN_VALUE; pStr++; } else @@ -946,9 +922,7 @@ sal_Int64 SAL_CALL IMPL_RTL_STRNAME( toInt64 )( const IMPL_RTL_STRCODE* pStr, if ( *pStr == '+' ) pStr++; bNeg = sal_False; - nLimit = -INT64_MAX_VALUE; } - nMultMin = nLimit / nRadix; while ( *pStr ) { @@ -956,21 +930,16 @@ sal_Int64 SAL_CALL IMPL_RTL_STRNAME( toInt64 )( const IMPL_RTL_STRCODE* pStr, if ( nDigit < 0 ) break; - if ( n < nMultMin ) - break; - n *= nRadix; - if ( n < (nLimit+nDigit) ) - break; - n -= nDigit; + n += nDigit; pStr++; } if ( bNeg ) - return n; - else return -n; + else + return n; } /* ======================================================================= */ |