From caf47b723828c09493de7bb03f3f522e36f4b305 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Mon, 10 Nov 2008 13:40:43 +0000 Subject: [PATCH] 2008-11-10 14:41 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbapi.h * harbour/source/common/hbstr.c + added hb_numToStr() * harbour/source/vm/estack.c * harbour/source/compiler/genc.c * harbour/source/compiler/gencc.c * use hb_numToStr() for integer number conversions * harbour/source/vm/dlmalloc.c * disable #pragma warning ... in MinGW builds. If some newer MinGW versions support it and it's useful then it can be enabled after checking MinGW version --- harbour/ChangeLog | 15 ++++++++++++++ harbour/include/hbapi.h | 2 +- harbour/source/common/hbstr.c | 36 ++++++++++++++++++++++++++++++++- harbour/source/compiler/genc.c | 4 +++- harbour/source/compiler/gencc.c | 5 ++++- harbour/source/vm/dlmalloc.c | 2 ++ harbour/source/vm/estack.c | 5 ++++- 7 files changed, 64 insertions(+), 5 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 947bad042a..a48b006f52 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,21 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2008-11-10 14:41 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbapi.h + * harbour/source/common/hbstr.c + + added hb_numToStr() + + * harbour/source/vm/estack.c + * harbour/source/compiler/genc.c + * harbour/source/compiler/gencc.c + * use hb_numToStr() for integer number conversions + + * harbour/source/vm/dlmalloc.c + * disable #pragma warning ... in MinGW builds. If some newer MinGW + versions support it and it's useful then it can be enabled after + checking MinGW version + 2008-11-10 09:50 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * include/hbmath.h ! Fixed Pelles C 5.00 not having an 'inf' (HUGE_VAL) symbol diff --git a/harbour/include/hbapi.h b/harbour/include/hbapi.h index 94841e6256..207a143fa7 100644 --- a/harbour/include/hbapi.h +++ b/harbour/include/hbapi.h @@ -862,7 +862,7 @@ extern HB_EXPORT ULONG hb_strRTrimLen( const char * szText, ULONG ulLen, BOO extern HB_EXPORT double hb_strVal( const char * szText, ULONG ulLen ); extern HB_EXPORT HB_LONG hb_strValInt( const char * szText, int * iOverflow ); extern HB_EXPORT char * hb_strRemEscSeq( char * szText, ULONG * ulLen ); /* remove C ESC sequences and converts them to Clipper chars */ - +extern HB_EXPORT char * hb_numToStr( char * szBuf, ULONG ulSize, HB_LONG lNumber ); extern HB_EXPORT double hb_numRound( double dResult, int iDec ); /* round a number to a specific number of digits */ extern HB_EXPORT double hb_numInt( double dNum ); /* take the integer part of the number */ extern HB_EXPORT double hb_numDecConv( double dNum, int iDec ); diff --git a/harbour/source/common/hbstr.c b/harbour/source/common/hbstr.c index 645221394c..f76e75b61e 100644 --- a/harbour/source/common/hbstr.c +++ b/harbour/source/common/hbstr.c @@ -756,6 +756,41 @@ HB_LONG hb_strValInt( const char * szText, int * iOverflow ) return lVal; } +char * hb_numToStr( char * szBuf, ULONG ulSize, HB_LONG lNumber ) +{ + int iPos = ( int ) ulSize; + BOOL fNeg = FALSE; + + HB_TRACE(HB_TR_DEBUG, ("hb_numToStr(%p, %lu, %" PFHL "i)", szBuf, ulSize, lNumber)); + + szBuf[ --iPos ] = '\0'; + if( lNumber < 0 ) + { + fNeg = TRUE; + lNumber = -lNumber; + } + + while( --iPos >= 0 ) + { + szBuf[ iPos ] = '0' + ( char ) ( lNumber % 10 ); + lNumber /= 10; + if( lNumber == 0 ) + break; + } + if( fNeg && --iPos >= 0 ) + szBuf[ iPos ] = '-'; + + if( iPos > 0 ) + memset( szBuf, ' ', iPos ); + else if( iPos < 0 ) + { + memset( szBuf, '*', ulSize - 1 ); + iPos = 0; + } + + return &szBuf[ iPos ]; +} + /* * This function copies szText to destination buffer. * NOTE: Unlike the documentation for strncpy, this routine will always append @@ -1023,7 +1058,6 @@ char * hb_strRemEscSeq( char *str, ULONG *pLen ) } else break; - } *dst++ = ch; } diff --git a/harbour/source/compiler/genc.c b/harbour/source/compiler/genc.c index 772d5dbc1d..6cfa128eec 100644 --- a/harbour/source/compiler/genc.c +++ b/harbour/source/compiler/genc.c @@ -1583,7 +1583,9 @@ static HB_GENC_FUNC( hb_p_pushlonglong ) #ifdef HB_LONG_LONG_OFF fprintf( cargo->yyc, "\t/* %f */", HB_PCODE_MKLONGLONG( &pFunc->pCode[ lPCodePos + 1 ] ) ); #else - fprintf( cargo->yyc, "\t/* %" PFLL "i */", HB_PCODE_MKLONGLONG( &pFunc->pCode[ lPCodePos + 1 ] ) ); + char szBuf[ 24 ]; + fprintf( cargo->yyc, "\t/* %s */", hb_numToStr( szBuf, sizeof( szBuf ), + HB_PCODE_MKLONGLONG( &pFunc->pCode[ lPCodePos + 1 ] ) ) ); #endif } fprintf( cargo->yyc, "\n" ); diff --git a/harbour/source/compiler/gencc.c b/harbour/source/compiler/gencc.c index b7b95768a0..f76266f009 100644 --- a/harbour/source/compiler/gencc.c +++ b/harbour/source/compiler/gencc.c @@ -1243,8 +1243,11 @@ static HB_GENC_FUNC( hb_p_pushlonglong ) } return 9 + iSkip; #else + char szBuf[ 24 ]; HB_GENC_LABEL(); - fprintf( cargo->yyc, "\thb_xvmPushLongLong( HB_LL( %" PFLL "i ) );\n", HB_PCODE_MKLONGLONG( &pFunc->pCode[ lPCodePos + 1 ] ) ); + fprintf( cargo->yyc, "\thb_xvmPushLongLong( HB_LL( %s ) );\n", + hb_numToStr( szBuf, sizeof( szBuf ), + HB_PCODE_MKLONGLONG( &pFunc->pCode[ lPCodePos + 1 ] ) ) ); return 9; #endif } diff --git a/harbour/source/vm/dlmalloc.c b/harbour/source/vm/dlmalloc.c index 953b9d10cb..09338558e8 100644 --- a/harbour/source/vm/dlmalloc.c +++ b/harbour/source/vm/dlmalloc.c @@ -1141,7 +1141,9 @@ int mspace_mallopt(int, int); /*------------------------------ internal #includes ---------------------- */ #ifdef WIN32 +#ifndef __MINGW32__ #pragma warning( disable : 4146 ) /* no "unsigned" warnings */ +#endif /* __MINGW32__ */ #endif /* WIN32 */ #include /* for printing in malloc_stats */ diff --git a/harbour/source/vm/estack.c b/harbour/source/vm/estack.c index d8c310f789..fa7ee60904 100644 --- a/harbour/source/vm/estack.c +++ b/harbour/source/vm/estack.c @@ -1081,8 +1081,11 @@ void hb_stackDispLocal( void ) break; case HB_IT_LONG: - printf( HB_I_("LONG = %" PFHL "i ") , hb_itemGetNInt( *pBase ) ); + { + char szBuf[ 24 ]; + printf( HB_I_("LONG = %s ") , hb_numToStr( szBuf, sizeof( szBuf ), hb_itemGetNInt( *pBase ) ) ); break; + } case HB_IT_INTEGER: printf( HB_I_("INTEGER = %i "), hb_itemGetNI( *pBase ) );