summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-04-28 16:12:54 +0200
committerEike Rathke <erack@redhat.com>2017-04-28 16:13:36 +0200
commitd6fd4252bf248d2872c713a1d83817a2dc88a9d2 (patch)
treea92271b2aff71e5380eed1b5d95916be118adc48 /basic
parent2f3060d40a7c6972a2054514e59cea36e0437951 (diff)
Use invalid parameter error for malformed input, tdf#106956 follow-up
... instead of invalid procedure call. Change-Id: I812f4c7041db9a116e65a24afb85164b4dd498b6
Diffstat (limited to 'basic')
-rw-r--r--basic/source/runtime/methods.cxx88
1 files changed, 46 insertions, 42 deletions
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 1bb3a474bc60..f4e60a51b2ca 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -2051,58 +2051,62 @@ RTLFUNC(CDateFromIso)
(void)pBasic;
(void)bWrite;
- do
+ if ( rPar.Count() == 2 )
{
- if ( rPar.Count() != 2 )
- break;
-
- OUString aStr = rPar.Get(1)->GetOUString();
- const sal_Int32 nLen = aStr.getLength();
- if (nLen != 8 && nLen != 10)
- break;
-
- OUString aYearStr, aMonthStr, aDayStr;
- if (nLen == 8)
+ do
{
- // YYYYMMDD
- if (!comphelper::string::isdigitAsciiString(aStr))
+ OUString aStr = rPar.Get(1)->GetOUString();
+ const sal_Int32 nLen = aStr.getLength();
+ if (nLen != 8 && nLen != 10)
break;
- aYearStr = aStr.copy( 0, 4 );
- aMonthStr = aStr.copy( 4, 2 );
- aDayStr = aStr.copy( 6, 2 );
- }
- else
- {
- // YYYY-MM-DD
- const sal_Int32 nSep1 = aStr.indexOf('-');
- if (nSep1 != 4)
- break;
- const sal_Int32 nSep2 = aStr.indexOf('-', nSep1+1);
- if (nSep2 != 7)
- break;
+ OUString aYearStr, aMonthStr, aDayStr;
+ if (nLen == 8)
+ {
+ // YYYYMMDD
+ if (!comphelper::string::isdigitAsciiString(aStr))
+ break;
- aYearStr = aStr.copy( 0, 4 );
- aMonthStr = aStr.copy( 5, 2 );
- aDayStr = aStr.copy( 8, 2 );
- if ( !comphelper::string::isdigitAsciiString(aYearStr) ||
- !comphelper::string::isdigitAsciiString(aMonthStr) ||
- !comphelper::string::isdigitAsciiString(aDayStr))
+ aYearStr = aStr.copy( 0, 4 );
+ aMonthStr = aStr.copy( 4, 2 );
+ aDayStr = aStr.copy( 6, 2 );
+ }
+ else
+ {
+ // YYYY-MM-DD
+ const sal_Int32 nSep1 = aStr.indexOf('-');
+ if (nSep1 != 4)
+ break;
+ const sal_Int32 nSep2 = aStr.indexOf('-', nSep1+1);
+ if (nSep2 != 7)
+ break;
+
+ aYearStr = aStr.copy( 0, 4 );
+ aMonthStr = aStr.copy( 5, 2 );
+ aDayStr = aStr.copy( 8, 2 );
+ if ( !comphelper::string::isdigitAsciiString(aYearStr) ||
+ !comphelper::string::isdigitAsciiString(aMonthStr) ||
+ !comphelper::string::isdigitAsciiString(aDayStr))
+ break;
+ }
+
+ double dDate;
+ if (!implDateSerial( (sal_Int16)aYearStr.toInt32(),
+ (sal_Int16)aMonthStr.toInt32(), (sal_Int16)aDayStr.toInt32(), dDate ))
break;
- }
- double dDate;
- if (!implDateSerial( (sal_Int16)aYearStr.toInt32(),
- (sal_Int16)aMonthStr.toInt32(), (sal_Int16)aDayStr.toInt32(), dDate ))
- break;
+ rPar.Get(0)->PutDate( dDate );
- rPar.Get(0)->PutDate( dDate );
+ return;
+ }
+ while (false);
- return;
+ SbxBase::SetError( ERRCODE_SBX_BAD_PARAMETER );
+ }
+ else
+ {
+ StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
- while (false);
-
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
}
RTLFUNC(DateSerial)