From d379101ce1afb39e2c77f3e94a90705da24db156 Mon Sep 17 00:00:00 2001 From: Antonio Carlos Pantaglione Date: Wed, 9 Jul 2003 10:18:20 +0000 Subject: [PATCH] Some changes in transfrm.c to be Clipper compliant. --- harbour/ChangeLog | 9 +++++++++ harbour/source/rtl/transfrm.c | 17 +++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 49be737861..a638d68c71 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,15 @@ 2002-12-01 23:12 UTC+0100 Foo Bar */ +2003-07-09 07:20 UTC-0300 Antonio Carlos Pantaglione + * source/rtl/transfrm.c + ! Fix with numeric values and pictures with spaces and pictures with + severals dot. Changes by Walter Negro, borrow from xharbour. + The return values are compliant with Clipper. + eg: Transform( 1234, "9 999" ) + eg: Transform( 123.123456, "999.99.99.99" ) + PS: I comment ALL old lines with //Toninho@fwi and. If all is Ok, I delete it. + 2003-07-08 23:00 UTC-0300 Antonio Carlos Pantaglione ! Sync with changes made in xHarbour by Walter Negro * contrib/rdd_ads/ace.h diff --git a/harbour/source/rtl/transfrm.c b/harbour/source/rtl/transfrm.c index a7a4faf838..edf5c03c65 100644 --- a/harbour/source/rtl/transfrm.c +++ b/harbour/source/rtl/transfrm.c @@ -422,7 +422,8 @@ HB_FUNC( TRANSFORM ) } /* TODO: maybe replace this 16 with something else */ - szResult = ( char * ) hb_xgrab( ulPicLen + 16 ); /* Grab enough */ +//Toninho@fwi szResult = ( char * ) hb_xgrab( ulPicLen + 16 ); /* Grab enough */ + szResult = ( char * ) hb_xgrab( ulPicLen + (ULONG) iOrigWidth + (ULONG) iOrigDec + 16 ); /* Grab enough */ *szResult = '\0'; for( i = 0; i < ulPicLen && !bFound; i++ ) /* Count number in front */ @@ -471,7 +472,8 @@ HB_FUNC( TRANSFORM ) } pNumber = hb_itemPutNDLen( NULL, dPush, -1, iDec ); - pWidth = hb_itemPutNI( NULL, iWidth + ( !ulPicLen && iDec > 0 ? iDec + 1 : 0 ) ); +//Toninho@fwi pWidth = hb_itemPutNI( NULL, iWidth + ( !ulPicLen && iDec > 0 ? iDec + 1 : 0 ) ); + pWidth = hb_itemPutNI( NULL, iWidth + ( ( ulPicLen || iDec == 0 ) ? 0 : ( iDec + 1 ) ) ); pDec = hb_itemPutNI( NULL, iDec ); szStr = hb_itemStr( pNumber, pWidth, pDec ); @@ -484,7 +486,7 @@ HB_FUNC( TRANSFORM ) { iCount = 0; - /* Pad with Zero's */ + /* Pad with padding char */ if( uiPicFlags & PF_PADL ) { for( i = 0; szStr[ i ] == ' ' && i < ( ULONG ) iWidth; i++ ) @@ -512,7 +514,8 @@ HB_FUNC( TRANSFORM ) if( uiPicFlags & PF_EXCHANG ) /* Exchange . and , */ { - szResult[ i ] = '.'; +//Toninho@fwi szResult[ i ] = '.'; + szResult[ i ] = ','; iCount++; } else @@ -552,7 +555,8 @@ HB_FUNC( TRANSFORM ) if( i && szResult[ i - 1 ] == '*' ) szResult[ i ] = '*'; else - szResult[ i ] = '0'; +//Toninho@fwi szResult[ i ] = '0'; + szResult[ i ] = ' '; } } else @@ -822,7 +826,8 @@ HB_FUNC( TRANSFORM ) hb_xfree( szStr ); } else - hb_retc( NULL ); +//Toninho@fwi hb_retc( NULL ); + hb_retc( "" ); } else if( HB_IS_DATE( pValue ) ) {