summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUray M. János <uray.janos@gmail.com>2012-07-31 08:04:06 +0200
committerNoel Power <noel.power@novell.com>2012-07-31 14:27:42 +0100
commit556720fcdd419820814164ecafbedb6598b5bb20 (patch)
tree67c9a0136a1d632b14d798b006e2c5415d5acd44
parentae126d43e4737ab39e53827d9ad3bd6983577b1f (diff)
fdo#42492: fixing Basic HEX command
Change-Id: I133590c9f2a34d8daab031da0c77bd049d275c29
-rw-r--r--basic/source/runtime/methods.cxx11
1 files changed, 6 insertions, 5 deletions
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 3b511b2db6ec..06f319ce4bc6 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 ) );
}
}