summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorsahil <gautamsahil1947@gmail.com>2023-07-28 15:22:40 +0530
committerHossein <hossein@libreoffice.org>2023-08-09 09:58:21 +0200
commita00cf4bc779b1da85423371fec43f8638c77e423 (patch)
treedc8d763920cd1c5acdab78c3fb5e665376945c14 /basic
parentaf3e5bef6c4e6b3158a7ab5a97c22909a7a1faa5 (diff)
tdf#147132 Flatten Basic function implementations
Change-Id: I0ba6e7c1e128f3216eb3b77246c659a728df1324 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155011 Tested-by: Jenkins Reviewed-by: Hossein <hossein@libreoffice.org>
Diffstat (limited to 'basic')
-rw-r--r--basic/source/runtime/methods.cxx36
1 files changed, 12 insertions, 24 deletions
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 986860c935a3..0c01e31126f1 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -379,16 +379,12 @@ void SbRtl_CurDir(StarBASIC *, SbxArray & rPar, bool)
{
OUString aDrive = rPar.Get(1)->GetOUString();
if ( aDrive.getLength() != 1 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
- }
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
auto c = rtl::toAsciiUpperCase(aDrive[0]);
if ( !rtl::isAsciiUpperCase( c ) )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
- }
+ return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
+
nCurDir = c - 'A' + 1;
}
wchar_t pBuffer[ _MAX_PATH ];
@@ -398,14 +394,10 @@ void SbRtl_CurDir(StarBASIC *, SbxArray & rPar, bool)
auto const handler = _set_thread_local_invalid_parameter_handler(&invalidParameterHandler);
auto const ok = _wgetdcwd( nCurDir, pBuffer, _MAX_PATH ) != nullptr;
_set_thread_local_invalid_parameter_handler(handler);
- if ( ok )
- {
- rPar.Get(0)->PutString(OUString(o3tl::toU(pBuffer)));
- }
- else
- {
- StarBASIC::Error( ERRCODE_BASIC_NO_DEVICE );
- }
+ if ( !ok )
+ return StarBASIC::Error( ERRCODE_BASIC_NO_DEVICE );
+
+ rPar.Get(0)->PutString(OUString(o3tl::toU(pBuffer)));
#else
@@ -417,20 +409,16 @@ void SbRtl_CurDir(StarBASIC *, SbxArray & rPar, bool)
{
pMem.reset(new char[nSize]);
if( !pMem )
- {
- StarBASIC::Error( ERRCODE_BASIC_NO_MEMORY );
- return;
- }
+ return StarBASIC::Error( ERRCODE_BASIC_NO_MEMORY );
+
if( getcwd( pMem.get(), nSize-1 ) != nullptr )
{
rPar.Get(0)->PutString(OUString::createFromAscii(pMem.get()));
return;
}
if( errno != ERANGE )
- {
- StarBASIC::Error( ERRCODE_BASIC_INTERNAL_ERROR );
- return;
- }
+ return StarBASIC::Error( ERRCODE_BASIC_INTERNAL_ERROR );
+
nSize += PATH_INCR;
};