[Libreoffice-commits] .: 2 commits - basic/source
Noel Power
noelp at kemper.freedesktop.org
Tue Jul 31 06:27:48 PDT 2012
basic/source/runtime/methods.cxx | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
New commits:
commit 02a7dfb729799f9e1437a718951566640d0fde02
Author: Noel Power <noel.power at novell.com>
Date: Tue Jul 31 14:25:29 2012 +0100
tweak for commit 8181dddb7bf166be4a00e9280d52f8d7a1741290 fdo#42492
avoid char buffer and snprintf.
Change-Id: Ia83cfc9333591bcb3b191679ccf2be587b4be243
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 06f319c..c8d8c0f 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -861,14 +861,12 @@ RTLFUNC(Hex)
StarBASIC::Error( SbERR_BAD_ARGUMENT );
else
{
- char aBuffer[17];
SbxVariableRef pArg = rPar.Get( 1 );
- // converting value to unsigned
+ // converting value to unsigned and limit to 2 or 4 byte representation
sal_uInt32 nVal = pArg->IsInteger() ?
static_cast<sal_uInt16>(pArg->GetInteger()) :
static_cast<sal_uInt32>(pArg->GetLong());
- snprintf( aBuffer, sizeof(aBuffer), "%"SAL_PRIXUINT32, nVal );
- rPar.Get(0)->PutString( rtl::OUString::createFromAscii( aBuffer ) );
+ rPar.Get(0)->PutString( rtl::OUString::valueOf( sal_Int64(nVal), 16 ) );
}
}
commit 556720fcdd419820814164ecafbedb6598b5bb20
Author: Uray M. János <uray.janos at gmail.com>
Date: Tue Jul 31 08:04:06 2012 +0200
fdo#42492: fixing Basic HEX command
Change-Id: I133590c9f2a34d8daab031da0c77bd049d275c29
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 3b511b2..06f319c 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -861,12 +861,13 @@ RTLFUNC(Hex)
StarBASIC::Error( SbERR_BAD_ARGUMENT );
else
{
- char aBuffer[16];
+ char aBuffer[17];
SbxVariableRef pArg = rPar.Get( 1 );
- if ( pArg->IsInteger() )
- snprintf( aBuffer, sizeof(aBuffer), "%X", pArg->GetInteger() );
- else
- snprintf( aBuffer, sizeof(aBuffer), "%lX", static_cast<long unsigned int>(pArg->GetLong()) );
+ // converting value to unsigned
+ sal_uInt32 nVal = pArg->IsInteger() ?
+ static_cast<sal_uInt16>(pArg->GetInteger()) :
+ static_cast<sal_uInt32>(pArg->GetLong());
+ snprintf( aBuffer, sizeof(aBuffer), "%"SAL_PRIXUINT32, nVal );
rPar.Get(0)->PutString( rtl::OUString::createFromAscii( aBuffer ) );
}
}
More information about the Libreoffice-commits
mailing list