From a4a8f47f115ca8f3ccb9ddf57ad6cbce17affb30 Mon Sep 17 00:00:00 2001 From: "David G. Holm" Date: Mon, 11 Sep 2000 17:49:08 +0000 Subject: [PATCH] See ChangeLog entry 2000-09-11 13:45 UTC-0400 David G. Holm --- harbour/ChangeLog | 7 +++++++ harbour/source/rdd/dbf1.c | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 163c3485d1..ff1c1a5533 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,10 @@ +2000-09-11 13:45 UTC-0400 David G. Holm + + * source/rdd/dbf1.c + ! Modified hb_dbfGetValue() and hb_dbfPutValue() to use double + conversions instead of long conversions when the length of a + numeric database field without any decimal places exceeds 9. + 2000-09-08 03:50 UTC+0800 Ron Pinkas * config/dos/djgpp.cf + Added support for $(C_USER) and $(L_USER) /* Could someone please verify, that this is the correct way. */ diff --git a/harbour/source/rdd/dbf1.c b/harbour/source/rdd/dbf1.c index fcc4552eaf..8734462dbb 100644 --- a/harbour/source/rdd/dbf1.c +++ b/harbour/source/rdd/dbf1.c @@ -1010,7 +1010,11 @@ ERRCODE hb_dbfGetValue( DBFAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) ( int ) pField->uiLen - ( ( int ) pField->uiDec + 1 ), ( int ) pField->uiDec ); else - hb_itemPutNLLen( pItem, atol( szBuffer ), ( int ) pField->uiLen ); + if( pField->uiLen > 9 ) + hb_itemPutNDLen( pItem, atof( szBuffer ), + ( int ) pField->uiLen, ( int ) pField->uiDec ); + else + hb_itemPutNLLen( pItem, atol( szBuffer ), ( int ) pField->uiLen ); } break; @@ -1194,8 +1198,14 @@ ERRCODE hb_dbfPutValue( DBFAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) if( HB_IS_DOUBLE( pItem ) ) { if( pField->uiDec == 0 ) - uiSize = sprintf( szBuffer, "%*li", pField->uiLen, + { + if( pField->uiLen > 9 ) + uiSize = sprintf( szBuffer, "%*.0f", pField->uiLen, + hb_numRound( hb_itemGetND( pItem ), 0 ) ); + else + uiSize = sprintf( szBuffer, "%*li", pField->uiLen, ( LONG ) hb_numRound( hb_itemGetND( pItem ), 0 ) ); + } else uiSize = sprintf( szBuffer, "%*.*f", pField->uiLen - pField->uiDec - 1, pField->uiDec, hb_numRound( hb_itemGetND( pItem ), @@ -1204,7 +1214,9 @@ ERRCODE hb_dbfPutValue( DBFAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) else { if( pField->uiDec == 0 ) + { uiSize = sprintf( szBuffer, "%*li", pField->uiLen, hb_itemGetNL( pItem ) ); + } else uiSize = sprintf( szBuffer, "%*.*f", pField->uiLen, pField->uiDec, hb_itemGetND( pItem ) );