On Wed, 11 Feb 2009, Szak�ts Viktor wrote:
Hi,
> source\rtl\binnum.c
binnum.c is not in original version and was updated by me and
AFAIR Phil Krylow.
Anyhow all these functions are very easy can be written in simpler
and a little bit faster way. So let's write them from scratch in a
while:
#include "hbapi.h"
#include "hbapiitm.h"
HB_FUNC( BIN2W )
{
PHB_ITEM pItem = hb_param( 1, HB_IT_STRING );
UINT16 uiResult = 0;
if( pItem )
{
ULONG ulLen = hb_itemGetCLen( pItem );
if( ulLen )
{
const char * pszString = hb_itemGetCPtr( pItem );
uiResult = HB_GET_LE_INT16( pszString );
}
}
hb_retnint( uiResult );
}
HB_FUNC( BIN2I )
{
PHB_ITEM pItem = hb_param( 1, HB_IT_STRING );
INT16 iResult = 0;
if( pItem )
{
ULONG ulLen = hb_itemGetCLen( pItem );
if( ulLen )
{
const char * pszString = hb_itemGetCPtr( pItem );
iResult = HB_GET_LE_UINT16( pszString );
}
}
hb_retnint( iResult );
}
HB_FUNC( BIN2L )
{
PHB_ITEM pItem = hb_param( 1, HB_IT_STRING );
INT32 iResult = 0;
if( pItem )
{
ULONG ulLen = hb_itemGetCLen( pItem );
if( ulLen )
{
const char * pszString = hb_itemGetCPtr( pItem );
if( ulLen >= 3 )
iResult = HB_GET_LE_INT32( pszString );
else
iResult = HB_GET_LE_UINT16( pszString );
}
}
hb_retnint( iResult );
}
HB_FUNC( I2BIN )
{
char szResult[ 2 ];
INT16 iValue = ( INT16 ) hb_parni( 1 );
HB_PUT_LE_UINT16( szResult, iValue );
hb_retclen( szResult, 2 );
}
HB_FUNC( L2BIN )
{
char szResult[ 4 ];
INT32 iValue = ( INT32 ) hb_parnl( 1 );
HB_PUT_LE_UINT32( szResult, iValue );
hb_retclen( szResult, 4 );
}
Just simply use the above code instead.
NOTE. Not testsed.
best regards,
Przemek
_______________________________________________
Harbour mailing list
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour