See changelog entry

This commit is contained in:
Antonio Linares
2002-01-30 08:25:54 +00:00
parent 573968128c
commit 48aa89d98e
31 changed files with 126 additions and 134 deletions

View File

@@ -301,9 +301,10 @@ extern BOOL HB_EXPORT hb_extIsArray( int iParam );
#define hb_ret() hb_itemClear( &hb_stack.Return )
#define hb_reta( ulLen ) hb_arrayNew( &hb_stack.Return, ulLen )
#define hb_retc( szText ) hb_itemPutC( &hb_stack.Return, szText )
#define hb_retc_buffer( szText, ulLen ) hb_itemPutCPtr( &hb_stack.Return, szText, ulLen )
#define hb_retc_buffer( szText ) hb_itemPutCPtr( &hb_stack.Return, szText, strlen( szText ) )
#define hb_retc_const( szText ) hb_itemPutCConst( &hb_stack.Return, szText )
#define hb_retclen( szText, ulLen ) hb_itemPutCL( &hb_stack.Return, szText, ulLen )
#define hb_retclen_buffer( szText, ulLen ) hb_itemPutCPtr( &hb_stack.Return, szText, ulLen )
#define hb_retds( szDate ) hb_itemPutDS( &hb_stack.Return, szDate )
#define hb_retd( lYear, lMonth, lDay ) hb_itemPutD( &hb_stack.Return, lYear, lMonth, lDay )
#define hb_retdl( lJulian ) hb_itemPutDL( &hb_stack.Return, lJulian )
@@ -322,9 +323,10 @@ extern int HB_EXPORT hb_pcount( void ); /* returns the number of sup
extern void HB_EXPORT hb_ret( void ); /* post a NIL return value */
extern void HB_EXPORT hb_retc( char * szText ); /* returns a string */
extern void HB_EXPORT hb_retcbuffer( char * szText, ULONG ulLen ); /* returns a string without duplicating it */
extern void HB_EXPORT hb_retcconst( char * szText ); /* returns a string as a pcode based string */
extern void HB_EXPORT hb_retc_buffer( char * szText ); /* sames as above, but accepts an allocated buffer */
extern void HB_EXPORT hb_retc_const( char * szText ); /* returns a string as a pcode based string */
extern void HB_EXPORT hb_retclen( char * szText, ULONG ulLen ); /* returns a string with a specific length */
extern void HB_EXPORT hb_retclen_buffer( char * szText, ULONG ulLen ); /* sames as above, but accepts an allocated buffer */
extern void HB_EXPORT hb_retds( char * szDate ); /* returns a date, must use yyyymmdd format */
extern void HB_EXPORT hb_retd( long lYear, long lMonth, long lDay ); /* returns a date */
extern void HB_EXPORT hb_retdl( long lJulian ); /* returns a long value as a julian date */

View File

@@ -91,7 +91,6 @@ HB_FUNC( AMPM )
strcpy( pszResult + ulTimeLen, bAM ? " am" : " pm" );
hb_retclen( pszResult, ulTimeLen + 3 );
hb_xfree( pszResult );
hb_retclen_buffer( pszResult, ulTimeLen + 3 );
}

View File

@@ -80,11 +80,10 @@ HB_FUNC( DESCEND )
{
char * szBuffer = ( char * ) hb_xgrab( ulLen );
hb_strDescend( szBuffer, hb_itemGetCPtr( pItem ), ulLen );
hb_retclen( szBuffer, ulLen );
hb_xfree( szBuffer );
hb_retclen_buffer( szBuffer, ulLen );
}
else
hb_retc( "" );
hb_retc( NULL );
}
else if( HB_IS_DATE( pItem ) )
hb_retnl( 5231808 - hb_itemGetDL( pItem ) );

View File

@@ -102,18 +102,20 @@ HB_FUNC( GETENV )
szValue = hb_getenv( pszName );
hb_retc( szValue && szValue[ 0 ] != '\0' ? szValue : ( ( ISCHAR( 2 ) ? hb_parc( 2 ) : "" ) ) );
if( szValue )
hb_xfree( ( void * ) szValue );
if( szValue && szValue[ 0 ] != '\0' )
hb_retc_buffer( szValue );
else if( ISCHAR( 2 ) )
hb_retc( hb_parc( 2 ) );
else
hb_retc( NULL );
}
else
hb_retc( "" );
hb_retc( NULL );
hb_itemFreeC( pszName );
}
else
hb_retc( "" );
hb_retc( NULL );
}
/* NOTE: Undocumented Clipper function. [vszakats] */

View File

@@ -222,9 +222,7 @@ HB_FUNC( HB_LANGSELECT )
HB_FUNC( HB_LANGNAME )
{
char * pszName = hb_langName();
hb_retc( pszName );
hb_xfree( pszName );
hb_retc_buffer( hb_langName() );
}
HB_FUNC( HB_LANGERRMSG )

View File

@@ -95,16 +95,16 @@ HB_FUNC( MEMOREAD )
hb_fsClose( fhnd );
hb_itemPutCPtr( hb_itemReturnPtr(), ( char * ) pbyBuffer, ulSize );
hb_retclen_buffer( ( char * ) pbyBuffer, ulSize );
}
else
hb_retc( "" );
hb_retc( NULL );
}
else
hb_retc( "" );
hb_retc( NULL );
}
else
hb_retc( "" );
hb_retc( NULL );
}
HB_FUNC( MEMOWRIT )

View File

@@ -55,7 +55,7 @@
HB_FUNC( MEMOLINE )
{
char * pszString = ISCHAR( 1 ) ? hb_parc( 1 ) : "";
char * pszString = hb_parc( 1 );
ULONG ulLineLength = ISNUM( 2 ) ? hb_parni( 2 ) : 79;
ULONG ulLineNumber = ISNUM( 3 ) ? hb_parni( 3 ) : 1;
ULONG ulTabLength = ISNUM( 4 ) ? hb_parni( 4 ) : 4;
@@ -171,10 +171,9 @@ HB_FUNC( MEMOLINE )
}
hb_retclen( pszLine, ulLineLength );
hb_xfree( pszLine );
hb_retclen_buffer( pszLine, ulLineLength );
}
else
hb_retc( "" );
hb_retc( NULL );
}

View File

@@ -54,7 +54,7 @@
HB_FUNC( MLCOUNT )
{
char * pszString = ISCHAR( 1 ) ? hb_parc( 1 ) : "";
char * pszString = hb_parc( 1 );
ULONG ulLineLength = ISNUM( 2 ) ? hb_parni( 2 ) : 79;
ULONG ulTabLength = ISNUM( 3 ) ? hb_parni( 3 ) : 4;
ULONG ulLastSpace = 0;

View File

@@ -54,7 +54,7 @@
HB_FUNC( MLCTOPOS )
{
char * pszString = ISCHAR( 1 ) ? hb_parc( 1 ) : "";
char * pszString = hb_parc( 1 );
ULONG ulLineLength = ISNUM( 2 ) ? hb_parni( 2 ) : 79;
ULONG ulLine = ISNUM( 3 ) ? hb_parnl( 3 ) : 1;
ULONG ulCol = ISNUM( 4 ) ? hb_parnl( 4 ) : 0;

View File

@@ -54,7 +54,7 @@
HB_FUNC( MLPOS )
{
char * pszString = ISCHAR( 1 ) ? hb_parc( 1 ) : "";
char * pszString = hb_parc( 1 );
ULONG ulLineLength = hb_parni( 2 );
ULONG ulLine = hb_parni( 3 );
ULONG ulTabLength = ISNUM( 4 ) ? hb_parni( 4 ) : 4;

View File

@@ -254,9 +254,7 @@ HB_FUNC( MSAVESTATE )
uiPos += sizeof( int );
*( pBuffer + uiPos ) = iRight;
hb_retclen( ( char * ) pBuffer, uiLen );
hb_xfree( pBuffer );
hb_retclen_buffer( ( char * ) pBuffer, uiLen );
}
HB_FUNC( MRESTSTATE )

View File

@@ -54,7 +54,7 @@
HB_FUNC( MPOSTOLC )
{
char * pszString = ISCHAR( 1 ) ? hb_parc( 1 ) : "";
char * pszString = hb_parc( 1 );
ULONG ulLineLength = ISNUM( 2 ) ? hb_parni( 2 ) : 79;
ULONG ulPos = ISNUM( 3 ) ? hb_parnl( 3 ) : 1;
ULONG ulTabLength = ISNUM( 4 ) ? hb_parni( 4 ) : 4;

View File

@@ -99,11 +99,9 @@ HB_FUNC( MEMOTRAN )
ULONG ulResultLen;
hb_strMemotran( pszResult, &ulResultLen, hb_itemGetCPtr( pString ), hb_itemGetCLen( pString ), cHardcr, cSoftcr );
hb_retclen( pszResult, ulResultLen );
hb_xfree( pszResult );
hb_retclen_buffer( pszResult, ulResultLen );
}
else
hb_retc( "" );
hb_retc( NULL );
}

View File

@@ -72,14 +72,13 @@ HB_FUNC( HB_ANSITOOEM )
CharToOemBuff( ( LPCSTR ) hb_itemGetCPtr( pString ), ( LPSTR ) pszDst, ulLen );
hb_retclen( pszDst, ulLen );
hb_xfree( pszDst );
hb_retclen_buffer( pszDst, ulLen );
}
#else
hb_itemReturn( pString );
#endif
else
hb_retc( "" );
hb_retc( NULL );
}
HB_FUNC( HB_OEMTOANSI )
@@ -94,14 +93,13 @@ HB_FUNC( HB_OEMTOANSI )
OemToCharBuff( ( LPCSTR ) hb_itemGetCPtr( pString ), ( LPSTR ) pszDst, ulLen );
hb_retclen( pszDst, ulLen );
hb_xfree( pszDst );
hb_retclen_buffer( pszDst, ulLen );
}
#else
hb_itemReturn( pString );
#endif
else
hb_retc( "" );
hb_retc( NULL );
}
#endif

View File

@@ -68,7 +68,7 @@ HB_FUNC( __BOX )
hb_itemGetNI( pLeft),
hb_itemGetNI( pBottom ),
hb_itemGetNI( pRight ),
( BYTE * ) ( ISCHAR( 5 ) ? hb_parc( 5 ) : " " ) );
( BYTE * ) hb_parc( 5 ) );
}
HB_FUNC( __BOXD )

View File

@@ -83,8 +83,7 @@ HB_FUNC( PADC )
szResult[ lLen ] = '\0';
hb_retclen( szResult, lLen );
hb_xfree( szResult );
hb_retclen_buffer( szResult, lLen );
}
else
{
@@ -95,6 +94,6 @@ HB_FUNC( PADC )
}
}
else
hb_retc( "" );
hb_retc( NULL );
}

View File

@@ -78,8 +78,7 @@ HB_FUNC( PADL )
for(; lPos > 0; lPos-- )
szResult[ lPos - 1 ] = cPad;
hb_retclen( szResult, lLen );
hb_xfree( szResult );
hb_retclen_buffer( szResult, lLen );
}
else
{
@@ -90,6 +89,6 @@ HB_FUNC( PADL )
}
}
else
hb_retc( "" );
hb_retc( NULL );
}

View File

@@ -78,8 +78,7 @@ HB_FUNC( PADR )
for( lPos = ( long ) ulSize; lPos < lLen; lPos++ )
szResult[ lPos ] = cPad;
hb_retclen( szResult, ( ULONG ) lLen );
hb_xfree( szResult );
hb_retclen_buffer( szResult, ( ULONG ) lLen );
}
else
{
@@ -90,6 +89,6 @@ HB_FUNC( PADR )
}
}
else
hb_retc( "" );
hb_retc( NULL );
}

View File

@@ -146,7 +146,7 @@ HB_FUNC( FERASE )
{
hb_fsSetError( 3 );
hb_retni( ( ISCHAR( 1 ) &&
hb_retni( ( ISCHAR( 1 ) &&
hb_fsDelete( ( BYTE * ) hb_parc( 1 ) ) ) ? 0 : -1 );
}
@@ -154,7 +154,7 @@ HB_FUNC( FRENAME )
{
hb_fsSetError( 2 );
hb_retni( ( ISCHAR( 1 ) && ISCHAR( 2 ) &&
hb_retni( ( ISCHAR( 1 ) && ISCHAR( 2 ) &&
hb_fsRename( ( BYTE * ) hb_parc( 1 ), ( BYTE * ) hb_parc( 2 ) ) ) ? 0 : -1 );
}
@@ -185,15 +185,13 @@ HB_FUNC( FREADSTR )
/* NOTE: Clipper will not return zero chars from this functions. */
hb_retc( ( char * ) buffer );
hb_xfree( buffer );
hb_retc_buffer( ( char * ) buffer );
}
else
hb_retc( "" );
hb_retc( NULL );
}
else
hb_retc( "" );
hb_retc( NULL );
}
/* NOTE: This function should not return the leading and trailing */
@@ -203,14 +201,13 @@ HB_FUNC( FREADSTR )
HB_FUNC( CURDIR )
{
BYTE byBuffer[ _POSIX_PATH_MAX + 1 ];
USHORT uiErrorOld = hb_fsError();
BYTE * pbyBuffer = ( BYTE * ) hb_xgrab( _POSIX_PATH_MAX + 1 );
hb_fsCurDirBuff( ( ISCHAR( 1 ) && hb_parclen( 1 ) > 0 ) ?
( USHORT )( toupper( *hb_parc( 1 ) ) - 'A' + 1 ) : 0, pbyBuffer, _POSIX_PATH_MAX + 1 );
( USHORT )( toupper( *hb_parc( 1 ) ) - 'A' + 1 ) : 0, byBuffer, _POSIX_PATH_MAX + 1 );
hb_retc( ( char * ) pbyBuffer );
hb_xfree( pbyBuffer );
hb_retc( ( char * ) byBuffer );
hb_fsSetError( uiErrorOld );
}

View File

@@ -79,14 +79,13 @@ HB_FUNC( REPLICATE )
szPtr += ulLen;
}
hb_retclen( szResult, ulLen * lTimes );
hb_xfree( szResult );
hb_retclen_buffer( szResult, ulLen * lTimes );
}
else
hb_errRT_BASE_SubstR( EG_STROVERFLOW, 1234, NULL, "REPLICATE", 2, hb_paramError( 1 ), hb_paramError( 2 ) );
}
else
hb_retc( "" );
hb_retc( NULL );
}
else
hb_errRT_BASE_SubstR( EG_ARG, 1106, NULL, "REPLICATE", 2, hb_paramError( 1 ), hb_paramError( 2 ) );

View File

@@ -67,9 +67,7 @@ HB_FUNC( SAVESCREEN )
pBuffer = hb_xgrab( uiSize );
hb_gtSave( uiTop, uiLeft, uiBottom, uiRight, pBuffer );
hb_retclen( ( char * ) pBuffer, uiSize );
hb_xfree( ( char * ) pBuffer );
hb_retclen_buffer( ( char * ) pBuffer, uiSize );
}
HB_FUNC( RESTSCREEN )

View File

@@ -72,11 +72,10 @@ HB_FUNC( SPACE )
/* hb_errRT_BASE( EG_STROVERFLOW, 1233, NULL, "SPACE" ); */
hb_xmemset( szResult, ' ', lLen );
hb_retclen( szResult, lLen );
hb_xfree( szResult );
hb_retclen_buffer( szResult, lLen );
}
else
hb_retc( "" );
hb_retc( NULL );
}
else
hb_errRT_BASE_SubstR( EG_ARG, 1105, NULL, "SPACE", 1, hb_paramError( 1 ) );

View File

@@ -87,12 +87,9 @@ HB_FUNC( STR )
char * szResult = hb_itemStr( pNumber, pWidth, pDec );
if( szResult )
{
hb_retc( szResult );
hb_xfree( szResult );
}
hb_retc_buffer( szResult );
else
hb_retc( "" );
hb_retc( NULL );
}
else
hb_errRT_BASE_SubstR( EG_ARG, 1099, NULL, "STR", 3, hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError( 3 ) );

View File

@@ -85,7 +85,7 @@ HB_FUNC( STRTRAN )
if( !ulStart )
{
/* Clipper seems to work this way */
hb_retc( "" );
hb_retc( NULL );
}
else if( ulStart > 0 )
{
@@ -174,8 +174,7 @@ HB_FUNC( STRTRAN )
i++;
}
}
hb_retclen( szResult, ulLength );
hb_xfree( szResult );
hb_retclen_buffer( szResult, ulLength );
}
else
hb_retclen( szText, ulText );

View File

@@ -116,11 +116,10 @@ HB_FUNC( STRZERO )
szResult[ ulPos++ ] = '0';
}
hb_retc( szResult );
hb_xfree( szResult );
hb_retc_buffer( szResult );
}
else
hb_retc( "" );
hb_retc( NULL );
}
else
#ifdef HB_C52_STRICT

View File

@@ -83,13 +83,12 @@ HB_FUNC( STUFF )
hb_xmemcpy( szResult + ulPos + ulInsert, szText + ulPos + ulDel, ulText - ( ulPos + ulDel ) );
szResult[ ulTotalLen ] = '\0';
hb_retclen( szResult, ulTotalLen );
hb_xfree( szResult );
hb_retclen_buffer( szResult, ulTotalLen );
}
else
hb_retc( "" );
hb_retc( NULL );
}
else
hb_retc( "" );
hb_retc( NULL );
}

View File

@@ -590,8 +590,7 @@ HB_FUNC( TRANSFORM )
if( uiPicFlags & PF_EMPTY )
memset( szResult, ' ', ulResultPos );
hb_retclen( szResult, ( uiPicFlags & PF_WIDTH && ulResultPos > ulParamS ) ? ulParamS : ulResultPos );
hb_xfree( szResult );
hb_retclen_buffer( szResult, ( uiPicFlags & PF_WIDTH && ulResultPos > ulParamS ) ? ulParamS : ulResultPos );
}
}
else if( pPic || ISNIL( 2 ) ) /* Picture is an empty string or NIL */
@@ -605,12 +604,9 @@ HB_FUNC( TRANSFORM )
char * szStr = hb_itemStr( pValue, NULL, NULL );
if( szStr )
{
hb_retc( szStr );
hb_xfree( szStr );
}
hb_retc_buffer( szStr );
else
hb_retc( "" );
hb_retc( NULL );
}
else if( HB_IS_DATE( pValue ) )
{

View File

@@ -61,10 +61,10 @@ HB_FUNC( HB_VALTOSTR )
BOOL bFreeReq;
char * buffer = hb_itemString( hb_param( 1, HB_IT_ANY ), &ulLen, &bFreeReq );
hb_retclen( buffer, ulLen );
if( bFreeReq )
hb_xfree( buffer );
hb_retclen_buffer( buffer, ulLen );
else
hb_retclen( buffer, ulLen );
}
#endif

View File

@@ -65,22 +65,16 @@
HB_FUNC( OS )
{
char * pszPlatform = hb_verPlatform();
hb_retc( pszPlatform );
hb_xfree( pszPlatform );
hb_retc_buffer( hb_verPlatform() );
}
HB_FUNC( HB_COMPILER )
{
char * pszCompiler = hb_verCompiler();
hb_retc( pszCompiler );
hb_xfree( pszCompiler );
hb_retc_buffer( hb_verCompiler() );
}
HB_FUNC( VERSION )
{
char * pszVersion = hb_verHarbour();
hb_retc( pszVersion );
hb_xfree( pszVersion );
hb_retc_buffer( hb_verHarbour() );
}

View File

@@ -502,11 +502,11 @@ void HB_EXPORT hb_retc( char * szText )
hb_itemPutC( &hb_stack.Return, szText );
}
void HB_EXPORT hb_retc_buffer( char * szText, ULONG ulLen )
void HB_EXPORT hb_retc_buffer( char * szText )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retcbuffer(%s, %lu)", szText, ulLen));
hb_itemPutCPtr( &hb_stack.Return, szText, ulLen );
hb_itemPutCPtr( &hb_stack.Return, szText, strlen( szText ) );
}
void HB_EXPORT hb_retc_const( char * szText )
@@ -523,6 +523,13 @@ void HB_EXPORT hb_retclen( char * szText, ULONG ulLen )
hb_itemPutCL( &hb_stack.Return, szText, ulLen );
}
void HB_EXPORT hb_retclen_buffer( char * szText, ULONG ulLen )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retclen_buffer(%s, %lu)", szText, ulLen));
hb_itemPutCPtr( &hb_stack.Return, szText, ulLen );
}
/* szDate must have YYYYMMDD format */
void HB_EXPORT hb_retds( char * szDate )
@@ -786,4 +793,4 @@ void HB_EXPORT hb_stornd( double dNumber, int iParam, ... )
else if( bByRef || iParam == -1 )
hb_itemPutND( pItem, dNumber );
}
}
}

View File

@@ -65,6 +65,7 @@
* hb_itemGetCPtr()
* hb_itemGetCLen()
* hb_itemGetNLen()
* hb_itemPutCConst()
* hb_itemPutNLen()
* hb_itemPutNDLen()
* hb_itemPutNILen()
@@ -192,16 +193,23 @@ PHB_ITEM hb_itemPutC( PHB_ITEM pItem, char * szText )
else
pItem = hb_itemNew( NULL );
if( szText == NULL )
szText = "";
pItem->type = HB_IT_STRING;
pItem->item.asString.length = strlen( szText );
pItem->item.asString.value = ( char * ) hb_xgrab( pItem->item.asString.length + 1 );
pItem->item.asString.bPcode = FALSE;
pItem->item.asString.puiHolders = ( USHORT * ) hb_xgrab( sizeof( USHORT ) );
* ( pItem->item.asString.puiHolders ) = 1;
strcpy( pItem->item.asString.value, szText );
if( szText == NULL )
{
pItem->item.asString.length = 0;
pItem->item.asString.value = "";
pItem->item.asString.bPcode = TRUE;
}
else
{
pItem->item.asString.length = strlen( szText );
pItem->item.asString.value = ( char * ) hb_xgrab( pItem->item.asString.length + 1 );
pItem->item.asString.bPcode = FALSE;
pItem->item.asString.puiHolders = ( USHORT * ) hb_xgrab( sizeof( USHORT ) );
* ( pItem->item.asString.puiHolders ) = 1;
strcpy( pItem->item.asString.value, szText );
}
return pItem;
}
@@ -215,14 +223,20 @@ PHB_ITEM hb_itemPutCConst( PHB_ITEM pItem, char * szText )
else
pItem = hb_itemNew( NULL );
if( szText == NULL )
szText = "";
pItem->type = HB_IT_STRING;
pItem->item.asString.length = strlen( szText );
pItem->item.asString.value = szText;
pItem->item.asString.bPcode = TRUE;
if( szText == NULL )
{
pItem->item.asString.length = 0;
pItem->item.asString.value = "";
}
else
{
pItem->item.asString.length = strlen( szText );
pItem->item.asString.value = szText;
}
return pItem;
}
@@ -239,20 +253,24 @@ PHB_ITEM hb_itemPutCL( PHB_ITEM pItem, char * szText, ULONG ulLen )
trash if the szText buffer is NULL, at least with hb_retclen().
[vszakats] */
pItem->type = HB_IT_STRING;
if( szText == NULL )
{
szText = "";
ulLen = 0;
pItem->item.asString.length = 0;
pItem->item.asString.value = "";
pItem->item.asString.bPcode = TRUE;
}
else
{
pItem->item.asString.length = ulLen;
pItem->item.asString.value = ( char * ) hb_xgrab( ulLen + 1 );
hb_xmemcpy( pItem->item.asString.value, szText, ulLen );
pItem->item.asString.value[ ulLen ] = '\0';
pItem->item.asString.bPcode = FALSE;
pItem->item.asString.puiHolders = ( USHORT * ) hb_xgrab( sizeof( USHORT ) );
* ( pItem->item.asString.puiHolders ) = 1;
}
pItem->type = HB_IT_STRING;
pItem->item.asString.length = ulLen;
pItem->item.asString.value = ( char * ) hb_xgrab( ulLen + 1 );
hb_xmemcpy( pItem->item.asString.value, szText, ulLen );
pItem->item.asString.value[ ulLen ] = '\0';
pItem->item.asString.bPcode = FALSE;
pItem->item.asString.puiHolders = ( USHORT * ) hb_xgrab( sizeof( USHORT ) );
* ( pItem->item.asString.puiHolders ) = 1;
return pItem;
}