[Libreoffice-commits] core.git: basic/source
Eike Rathke
erack at redhat.com
Fri Mar 22 09:47:39 PDT 2013
basic/source/runtime/methods.cxx | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
New commits:
commit e8638ad5a7196ea79d90415b86a99a4c9f110a5e
Author: Eike Rathke <erack at redhat.com>
Date: Fri Mar 22 17:42:20 2013 +0100
in Val() check status after stringToDouble()
instead of calling checkArithmeticOverflow()
Change-Id: I2e3307ee054db77bab0a106d886823dba9e56ea8
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 0318b82..76c8dd9 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -1782,9 +1782,20 @@ RTLFUNC(Val)
}
else
{
- // #57844 use localized function
- nResult = ::rtl::math::stringToDouble( aStr, '.', ',', NULL, NULL );
- checkArithmeticOverflow( nResult );
+ rtl_math_ConversionStatus eStatus = rtl_math_ConversionStatus_Ok;
+ sal_Int32 nParseEnd = 0;
+ nResult = ::rtl::math::stringToDouble( aStr, '.', ',', &eStatus, &nParseEnd );
+ if ( eStatus != rtl_math_ConversionStatus_Ok )
+ StarBASIC::Error( SbERR_MATH_OVERFLOW );
+ /* TODO: we should check whether all characters were parsed here,
+ * but earlier code silently ignored trailing nonsense such as "1x"
+ * resulting in 1 with the side effect that any alpha-only-string
+ * like "x" resulted in 0. Not changing that now (2013-03-22) as
+ * user macros may rely on it. */
+#if 0
+ else if ( nParseEnd != aStr.getLength() )
+ StarBASIC::Error( SbERR_CONVERSION );
+#endif
}
rPar.Get(0)->PutDouble( nResult );
More information about the Libreoffice-commits
mailing list