[PATCH 1/1] fix 32 bit overflow with 64 bit constants=0A=
John LeMoyne Castle
jlc at mail2lee.com
Sun Oct 24 23:14:54 PDT 2010
=0A=
---=0A=
vcl/source/control/field.cxx | 42 =
++++++++++++++++++++----------------------=0A=
1 files changed, 20 insertions(+), 22 deletions(-)=0A=
=0A=
diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx=0A=
index 733781e..1f0f7af 100644=0A=
--- a/vcl/source/control/field.cxx=0A=
+++ b/vcl/source/control/field.cxx=0A=
@@ -2,7 +2,7 @@=0A=
=
/************************************************************************=
*=0A=
*=0A=
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.=0A=
- * =0A=
+ *=0A=
* Copyright 2000, 2010 Oracle and/or its affiliates.=0A=
*=0A=
* OpenOffice.org - a multi-platform office productivity suite=0A=
@@ -48,7 +48,6 @@=0A=
=0A=
#include "rtl/math.hxx"=0A=
=0A=
-=0A=
#include <unotools/localedatawrapper.hxx>=0A=
=0A=
using namespace ::com::sun::star;=0A=
@@ -231,7 +230,7 @@ static void ImplUpdateSeparators( const String& =
rOldDecSep, const String& rNewDe=0A=
{=0A=
bool bChangeDec =3D (rOldDecSep !=3D rNewDecSep);=0A=
bool bChangeTh =3D (rOldThSep !=3D rNewThSep );=0A=
- =0A=
+=0A=
if( bChangeDec || bChangeTh )=0A=
{=0A=
BOOL bUpdateMode =3D pEdit->IsUpdateMode();=0A=
@@ -242,7 +241,7 @@ static void ImplUpdateSeparators( const String& =
rOldDecSep, const String& rNewDe=0A=
if( bChangeTh )=0A=
aText.SearchAndReplaceAll( rNewThSep, rOldThSep );=0A=
pEdit->SetText( aText );=0A=
- =0A=
+=0A=
ComboBox* pCombo =3D dynamic_cast<ComboBox*>(pEdit);=0A=
if( pCombo )=0A=
{=0A=
@@ -479,19 +478,19 @@ void NumericFormatter::ImplLoadRes( const ResId& =
rResId )=0A=
if( pMgr )=0A=
{=0A=
ULONG nMask =3D pMgr->ReadLong();=0A=
- =0A=
+=0A=
if ( NUMERICFORMATTER_MIN & nMask )=0A=
mnMin =3D pMgr->ReadLong();=0A=
- =0A=
+=0A=
if ( NUMERICFORMATTER_MAX & nMask )=0A=
mnMax =3D pMgr->ReadLong();=0A=
- =0A=
+=0A=
if ( NUMERICFORMATTER_STRICTFORMAT & nMask )=0A=
SetStrictFormat( (BOOL)pMgr->ReadShort() );=0A=
- =0A=
+=0A=
if ( NUMERICFORMATTER_DECIMALDIGITS & nMask )=0A=
SetDecimalDigits( pMgr->ReadShort() );=0A=
- =0A=
+=0A=
if ( NUMERICFORMATTER_VALUE & nMask )=0A=
{=0A=
mnFieldValue =3D pMgr->ReadLong();=0A=
@@ -1080,7 +1079,7 @@ static XubString ImplMetricGetUnitText( const =
XubString& rStr )=0A=
}=0A=
}=0A=
return aStr;=0A=
- =0A=
+=0A=
/*=0A=
// MT: #90545# Preparation for translated strings...=0A=
String aMetricText;=0A=
@@ -1099,7 +1098,7 @@ static XubString ImplMetricGetUnitText( const =
XubString& rStr )=0A=
break;=0A=
}=0A=
}=0A=
-*/ =0A=
+*/=0A=
}=0A=
=0A=
// =
-----------------------------------------------------------------------=0A=
@@ -1151,33 +1150,32 @@ static FieldUnit ImplMetricGetUnit( const =
XubString& rStr )=0A=
}=0A=
=0A=
#define K *1000L=0A=
-#define M *1000000L=0A=
+#define M *1000000LL=0A=
#define X *5280L=0A=
=0A=
-// Amelia : about measurement unit, 'char' and 'line'=0A=
-//static const sal_Int64 aImplFactor[FUNIT_MILE+1][FUNIT_MILE+1] =3D=0A=
+// twip in km =3D 254 / 14 400 000 000=0A=
+// expressions too big for default size 32 bit need LL to avoid overflow=0A=
+=0A=
static const sal_Int64 aImplFactor[FUNIT_LINE+1][FUNIT_LINE+1] =3D=0A=
{ /*=0A=
-mm/100 mm cm m km twip point pica inch foot =
mile char line*/=0A=
+mm/100 mm cm m km twip point pica inch foot =
mile char line */=0A=
{ 1, 100, 1 K, 100 K, 100 M, 2540, 2540, 2540, =
2540,2540*12,2540*12 X , 53340, 396240},=0A=
{ 1, 1, 10, 1 K, 1 M, 2540, 2540, 2540, =
2540,2540*12,2540*12 X , 5334, 396240},=0A=
{ 1, 1, 1, 100, 100 K, 254, 254, 254, 254, 254*12, =
254*12 X , 5334, 39624},=0A=
{ 1, 1, 1, 1, 1 K, 254, 254, 254, 254, 254*12, =
254*12 X , 533400, 39624},=0A=
-{ 1, 1, 1, 1, 1, 0, 254, 254, 254, 254*12, =
254*12 X ,533400 K, 39624},=0A=
-{ 1440,144 K,144 K,14400 K, 0, 1, 20, 240, =
1440,1440*12,1440*12 X , 210, 3120},=0A=
+{ 1, 1, 1, 1, 1, 254, 254, 254, 254, 254*12, =
254*12 X ,533400 K, 39624},=0A=
+{ 1440,144 K,144 K,14400 K,14400LL M, 1, 20, 240, =
1440,1440*12,1440*12 X , 210, 3120},=0A=
{ 72, 7200, 7200, 720 K, 720 M, 1, 1, 12, 72, 72*12, =
72*12 X , 210, 156},=0A=
{ 6, 600, 600, 60 K, 60 M, 1, 1, 1, 6, 6*12, =
6*12 X , 210, 10},=0A=
{ 1, 100, 100, 10 K, 10 M, 1, 1, 1, 1, 12, =
12 X , 210, 45},=0A=
{ 1, 100, 100, 10 K, 10 M, 1, 1, 1, 1, 1, =
1 X , 210, 45},=0A=
{ 1, 100, 100, 10 K, 10 M, 1, 1, 1, 1, 1, =
1 , 210, 45},=0A=
{ 144, 1440,14400, 14400, 14400, 1, 20, 240, 1440,1440*12, =
1440*12 X, 1, 156 },=0A=
-{ 720,72000,72000, 7200 K,7200 M, 20, 10, 13, 11, 11*12, =
11*12 X, 105, 1 }=0A=
+{ 720,72000,72000, 7200 K,7200LL M, 20, 10, 13, 11, 11*12, =
11*12 X, 105, 1 }=0A=
};=0A=
-=0A=
#undef X=0A=
#undef M=0A=
#undef K=0A=
-// twip in km 254/14400 M=0A=
=0A=
static FieldUnit eDefaultUnit =3D FUNIT_NONE;=0A=
=0A=
@@ -1505,10 +1503,10 @@ void MetricFormatter::ImplLoadRes( const ResId& =
rResId )=0A=
if( pMgr )=0A=
{=0A=
ULONG nMask =3D pMgr->ReadLong();=0A=
- =0A=
+=0A=
if ( METRICFORMATTER_UNIT & nMask )=0A=
meUnit =3D (FieldUnit)pMgr->ReadLong();=0A=
- =0A=
+=0A=
if ( METRICFORMATTER_CUSTOMUNITTEXT & nMask )=0A=
maCustomUnitText =3D pMgr->ReadString();=0A=
}=0A=
-- =0A=
1.7.0.4=0A=
=0A=
------=_NextPart_000_000C_01CB740B.F8F13250--
More information about the LibreOffice
mailing list