[Libreoffice-commits] core.git: basic/source

Arnaud Versini arnaud.versini at gmail.com
Sun Nov 6 08:09:13 UTC 2016


 basic/source/sbx/sbxbyte.cxx |    6 ++++--
 basic/source/sbx/sbxchar.cxx |    8 +++++---
 basic/source/sbx/sbxconv.hxx |    3 +--
 basic/source/sbx/sbxint.cxx  |   17 +++++++----------
 basic/source/sbx/sbxlng.cxx  |    8 +++++---
 5 files changed, 22 insertions(+), 20 deletions(-)

New commits:
commit 3db1e9ed4d0d11457684dd3d2c8cacf97d7e3333
Author: Arnaud Versini <arnaud.versini at gmail.com>
Date:   Tue Nov 1 13:50:03 2016 +0100

    BASIC : remove ImpRound and use std::(l)lround instead
    
    Change-Id: I1e8f58890395bc6bc29f56c258836db3dc52384c
    Reviewed-on: https://gerrit.libreoffice.org/30464
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>

diff --git a/basic/source/sbx/sbxbyte.cxx b/basic/source/sbx/sbxbyte.cxx
index 5527a56..562979b 100644
--- a/basic/source/sbx/sbxbyte.cxx
+++ b/basic/source/sbx/sbxbyte.cxx
@@ -21,6 +21,8 @@
 #include <basic/sbx.hxx>
 #include "sbxconv.hxx"
 
+#include <cmath>
+
 sal_uInt8 ImpGetByte( const SbxValues* p )
 {
     SbxValues aTmp;
@@ -121,7 +123,7 @@ start:
                 SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = 0;
             }
             else
-                nRes = (sal_uInt8) ImpRound( p->nSingle );
+                nRes = (sal_uInt8) std::lround( p->nSingle );
             break;
         case SbxDATE:
         case SbxDOUBLE:
@@ -147,7 +149,7 @@ start:
                 SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = 0;
             }
             else
-                nRes = (sal_uInt8) ImpRound( dVal );
+                nRes = (sal_uInt8) std::lround( dVal );
             break;
             }
         case SbxBYREF | SbxSTRING:
diff --git a/basic/source/sbx/sbxchar.cxx b/basic/source/sbx/sbxchar.cxx
index d03bcb9..81d195c 100644
--- a/basic/source/sbx/sbxchar.cxx
+++ b/basic/source/sbx/sbxchar.cxx
@@ -21,6 +21,8 @@
 #include <basic/sbx.hxx>
 #include "sbxconv.hxx"
 
+#include <cmath>
+
 sal_Unicode ImpGetChar( const SbxValues* p )
 {
     SbxValues aTmp;
@@ -109,7 +111,7 @@ start:
                 SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINCHAR;
             }
             else
-                nRes = (sal_Unicode) ImpRound( p->nSingle );
+                nRes = (sal_Unicode) std::lround( p->nSingle );
             break;
         case SbxDATE:
         case SbxDOUBLE:
@@ -135,7 +137,7 @@ start:
                 SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINCHAR;
             }
             else
-                nRes = (sal_uInt8) ImpRound( dVal );
+                nRes = (sal_uInt8) std::lround( dVal );
             break;
             }
         case SbxBYREF | SbxSTRING:
@@ -156,7 +158,7 @@ start:
                     SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINCHAR;
                 }
                 else
-                    nRes = (sal_Unicode) ImpRound( d );
+                    nRes = (sal_Unicode) std::lround( d );
             }
             break;
         case SbxOBJECT:
diff --git a/basic/source/sbx/sbxconv.hxx b/basic/source/sbx/sbxconv.hxx
index c14a3ac..08fa296 100644
--- a/basic/source/sbx/sbxconv.hxx
+++ b/basic/source/sbx/sbxconv.hxx
@@ -37,8 +37,7 @@ void ImpGetIntntlSep( sal_Unicode& rcDecimalSep, sal_Unicode& rcThousandSep );
 
 // SBXINT.CXX
 
-double      ImpRound( double );
-sal_Int16       ImpGetInteger( const SbxValues* );
+sal_Int16   ImpGetInteger( const SbxValues* );
 void        ImpPutInteger( SbxValues*, sal_Int16 );
 
 sal_Int64   ImpGetInt64( const SbxValues* );
diff --git a/basic/source/sbx/sbxint.cxx b/basic/source/sbx/sbxint.cxx
index c2d6fbe..b3d4cd3 100644
--- a/basic/source/sbx/sbxint.cxx
+++ b/basic/source/sbx/sbxint.cxx
@@ -21,10 +21,7 @@
 #include <basic/sbx.hxx>
 #include "sbxconv.hxx"
 
-double ImpRound( double d )
-{
-    return d + ( d < 0 ? -0.5 : 0.5 );
-}
+#include <cmath>
 
 sal_Int16 ImpGetInteger( const SbxValues* p )
 {
@@ -84,7 +81,7 @@ start:
                 SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMININT;
             }
             else
-                nRes = (sal_Int16) ImpRound( p->nSingle );
+                nRes = (sal_Int16) std::lround( p->nSingle );
             break;
         case SbxCURRENCY:
             {
@@ -145,7 +142,7 @@ start:
                 SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMININT;
             }
             else
-                nRes = (sal_Int16) ImpRound( dVal );
+                nRes = (sal_Int16) std::lround( dVal );
             break;
             }
         case SbxLPSTR:
@@ -168,7 +165,7 @@ start:
                     SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMININT;
                 }
                 else
-                    nRes = (sal_Int16) ImpRound( d );
+                    nRes = (sal_Int16) std::lround( d );
             }
             break;
         case SbxOBJECT:
@@ -350,7 +347,7 @@ sal_Int64 ImpDoubleToSalInt64( double d )
         SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINSALINT64;
     }
     else
-        nRes = (sal_Int64) ImpRound( d );
+        nRes = (sal_Int64) std::llround( d );
     return nRes;
 }
 
@@ -366,7 +363,7 @@ sal_uInt64 ImpDoubleToSalUInt64( double d )
         SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = 0;
     }
     else
-        nRes = (sal_uInt64) ImpRound( d );
+        nRes = (sal_uInt64) std::llround( d );
     return nRes;
 }
 
@@ -716,7 +713,7 @@ start:
                         SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = 0;
                     }
                     else
-                        nRes = (sal_uInt64) ImpRound( d );
+                        nRes = (sal_uInt64) std::llround( d );
                 }
                 else if( n64 < 0 )
                 {
diff --git a/basic/source/sbx/sbxlng.cxx b/basic/source/sbx/sbxlng.cxx
index b173e8c..a5fcbad 100644
--- a/basic/source/sbx/sbxlng.cxx
+++ b/basic/source/sbx/sbxlng.cxx
@@ -21,6 +21,8 @@
 #include <basic/sbx.hxx>
 #include "sbxconv.hxx"
 
+#include <cmath>
+
 sal_Int32 ImpGetLong( const SbxValues* p )
 {
     SbxValues aTmp;
@@ -63,7 +65,7 @@ start:
                 SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINLNG;
             }
             else
-                nRes = (sal_Int32) ImpRound( p->nSingle );
+                nRes = (sal_Int32) std::lround( p->nSingle );
             break;
         case SbxSALINT64:
             nRes = p->nInt64;
@@ -104,7 +106,7 @@ start:
                 SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINLNG;
             }
             else
-                nRes = (sal_Int32) ImpRound( dVal );
+                nRes = (sal_Int32) std::lround( dVal );
             break;
             }
         case SbxBYREF | SbxSTRING:
@@ -127,7 +129,7 @@ start:
                     SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINLNG;
                 }
                 else
-                    nRes = (sal_Int32) ImpRound( d );
+                    nRes = (sal_Int32) std::lround( d );
             }
             break;
         case SbxOBJECT:


More information about the Libreoffice-commits mailing list