? sal/sal.vpj
Index: sal/qa/rtl/oustring/rtl_OUString2.cxx
===================================================================
RCS file: /cvs/porting/sal/qa/rtl/oustring/rtl_OUString2.cxx,v
retrieving revision 1.11
retrieving revision 1.7.76.3
diff -u -b -I $Revision.*$ -I $Author.*$ -r1.11 -r1.7.76.3
--- sal/qa/rtl/oustring/rtl_OUString2.cxx	27 Jun 2007 13:25:26 -0000	1.11
+++ sal/qa/rtl/oustring/rtl_OUString2.cxx	24 Jul 2007 21:56:49 -0000	1.7.76.3
@@ -348,6 +348,33 @@
         
     };
 
+    class toInt: public CppUnit::TestFixture {
+    public:
+        void test() {
+            CPPUNIT_ASSERT_EQUAL(
+                static_cast< sal_Int32 >(-0x76543210),
+                (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-76543210")).
+                 toInt32(16)));
+            CPPUNIT_ASSERT_EQUAL(
+                static_cast< sal_Int32 >(0xFEDCBA98),
+                (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("+FEDCBA98")).
+                 toInt32(16)));
+            CPPUNIT_ASSERT_EQUAL(
+                static_cast< sal_Int64 >(-SAL_CONST_INT64(0x76543210FEDCBA98)),
+                (rtl::OUString(
+                    RTL_CONSTASCII_USTRINGPARAM("-76543210FEDCBA98")).
+                 toInt64(16)));
+            CPPUNIT_ASSERT_EQUAL(
+                static_cast< sal_Int64 >(SAL_CONST_INT64(0xFEDCBA9876543210)),
+                (rtl::OUString(
+                    RTL_CONSTASCII_USTRINGPARAM("+FEDCBA9876543210")).
+                 toInt64(16)));
+        }
+
+        CPPUNIT_TEST_SUITE(toInt);
+        CPPUNIT_TEST(test);
+        CPPUNIT_TEST_SUITE_END();
+    };
     
 // -----------------------------------------------------------------------------
 // - toDouble (tests)
@@ -1128,6 +1155,7 @@
 
 // -----------------------------------------------------------------------------
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_OUString::valueOf, "rtl_OUString");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_OUString::toInt, "rtl_OUString");
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_OUString::toDouble, "rtl_OUString");
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_OUString::toFloat, "rtl_OUString");
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_OUString::lastIndexOf, "rtl_OUString");
Index: sal/rtl/source/strtmpl.c
===================================================================
RCS file: /cvs/porting/sal/rtl/source/strtmpl.c,v
retrieving revision 1.24
retrieving revision 1.22.112.2
diff -u -b -I $Revision.*$ -I $Author.*$ -r1.24 -r1.22.112.2
--- sal/rtl/source/strtmpl.c	3 Apr 2007 14:06:07 -0000	1.24
+++ sal/rtl/source/strtmpl.c	8 May 2007 10:27:55 -0000	1.22.112.2
@@ -852,15 +852,10 @@
 
 /* ----------------------------------------------------------------------- */
 
-#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 @@
     if ( *pStr == '-' )
     {
         bNeg = sal_True;
-        nLimit = INT32_MIN_VALUE;
         pStr++;
     }
     else
@@ -882,9 +876,7 @@
         if ( *pStr == '+' )
             pStr++;
         bNeg = sal_False;
-        nLimit = -INT32_MAX_VALUE;
     }
-    nMultMin = nLimit / nRadix;
 
     while ( *pStr )
     {
@@ -892,39 +884,24 @@
         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 @@
     if ( *pStr == '-' )
     {
         bNeg = sal_True;
-        nLimit = INT64_MIN_VALUE;
         pStr++;
     }
     else
@@ -946,9 +922,7 @@
         if ( *pStr == '+' )
             pStr++;
         bNeg = sal_False;
-        nLimit = -INT64_MAX_VALUE;
     }
-    nMultMin = nLimit / nRadix;
 
     while ( *pStr )
     {
@@ -956,21 +930,16 @@
         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;
 }
 
 /* ======================================================================= */
