* source/rtl/transfrm.c

! Fix with numeric values and pictures with spaces and pictures with
      severals dot.
      The return values are compliant with Clipper.
      eg: Transform( 1234, "9 999" )
      eg: Transform( 123.123456, "999.99.99.99" )

      Reported by Richard Chidiak
This commit is contained in:
Walter Negro
2002-07-07 04:13:13 +00:00
parent 12fe4566e1
commit f95a192bee

View File

@@ -402,7 +402,7 @@ HB_FUNC( TRANSFORM )
BOOL bFound = FALSE;
BOOL bInit = FALSE;
BOOL bEnd = FALSE;
BOOL bPDec = FALSE;
dValue = hb_itemGetND( pValue );
hb_itemGetNLen( pValue, &iOrigWidth, &iOrigDec );
@@ -492,11 +492,9 @@ HB_FUNC( TRANSFORM )
{
cPic = szPic[ i ];
if( bInit && cPic == ' ' )
bEnd = TRUE;
if( !bInit && ( cPic == '9' || cPic == '#' || cPic == '$' || cPic == '*' ) )
bInit = TRUE;
if( cPic == '9' || cPic == '#' )
{
if( iCount < iWidth )
@@ -504,16 +502,18 @@ HB_FUNC( TRANSFORM )
else
szResult[ i ] = ' ';
}
else if( cPic == '.' && bInit && !bEnd )
else if( cPic == '.' && bInit )
{
if( uiPicFlags & PF_EXCHANG ) /* Exchange . and , */
bPDec = TRUE;
if( uiPicFlags & PF_EXCHANG ) /* Exchange . and , */
{
szResult[ i ] = ',';
iCount++;
}
else
{
if( uiPicFlags & PF_NUMDATE ) /* Dot in date */
if( uiPicFlags & PF_NUMDATE || bPDec ) /* Dot in date */
{
szResult[ i ] = cPic;
iCount++;
@@ -524,7 +524,7 @@ HB_FUNC( TRANSFORM )
}
}
}
else if( ( cPic == '$' || cPic == '*' ) && !bEnd )
else if( cPic == '$' || cPic == '*' )
{
if( szStr[ iCount ] == ' ' )
{
@@ -534,7 +534,7 @@ HB_FUNC( TRANSFORM )
else
szResult[ i ] = szStr[ iCount++ ];
}
else if( cPic == ',' && bInit && !bEnd ) /* Comma */
else if( cPic == ',' && bInit ) /* Comma */
{
if( iCount && isdigit( ( int ) szStr[ iCount - 1 ] ) )
{ /* May we place it */