summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUray M. János <uray.janos@gmail.com>2012-07-31 08:04:06 +0200
committerAndras Timar <atimar@suse.com>2012-08-10 21:51:38 +0200
commite370b12af6e2c1e3fc3bf67350541c4e4503f40c (patch)
tree05bac71b73e7cb2f478aba5d481ccaf33371a152
parent3947c90f4bb15f272ecee86609953638302753f5 (diff)
fdo#42492: fixing Basic HEX command
Change-Id: I133590c9f2a34d8daab031da0c77bd049d275c29 Signed-off-by: Andras Timar <atimar@suse.com>
-rw-r--r--basic/source/runtime/methods.cxx13
1 files changed, 7 insertions, 6 deletions
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 9a5bb7d4f163..49ebf27877b8 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -872,13 +872,14 @@ 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()) );
- rPar.Get(0)->PutString( String::CreateFromAscii( aBuffer ) );
+ // 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 ) );
}
}