19990917-00:05 GMT+1

This commit is contained in:
Viktor Szakats
1999-09-16 22:21:29 +00:00
parent 84037dd9fe
commit ded1f1389e
8 changed files with 223 additions and 197 deletions

View File

@@ -1,3 +1,29 @@
19990917-00:05 GMT+1 Victor Szel <info@szelvesz.hu>
* include/hbdefs.h
+ typedef BYTE HB_CHAR;
+ typedef BYTE HB_ATTR;
* source/rtl/mtran.c
% Some Extend API calls changed for Item API, for speed.
+ const keyword added.
* source/rtl/tone.c
% TONE() parameters checking simplified.
* Variable names standardized.
* source/rtl/set.c
* Removed all direct item access, replaced them with Item API calls.
* Some variable names standardized.
! int -> BOOL in one place.
! int -> USHORT for hb_fsError() retvals.
* source/rtl/console.c
! int -> USHORT for hb_fsError() retvals.
* Variable names changed ( len -> ulLen, count -> ulCount, uiCount )
* pcount() > x -> pcount() >= x+1
* source/vm/hvm.c
* pcount() > x -> pcount() >= x+1 (ERRORLEVEL())
* source/rtl/setcolor.c
! 0 -> '\0'
! SETCOLOR() now doesn't accept a non string parameter.
19990916-23:00 GMT+1 Victor Szel <info@szelvesz.hu>
* source/rtl/gtapi.c

View File

@@ -76,9 +76,6 @@ typedef unsigned char BYTE; /* 1 byte unsigned */
#undef SHORT /* 2 bytes signed */
typedef short int SHORT;
#undef WORD /* 2 bytes unsigned */
typedef unsigned short int WORD;
#undef USHORT /* 2 bytes unsigned */
typedef unsigned short int USHORT;
@@ -88,6 +85,11 @@ typedef long LONG;
#undef ULONG /* 4 bytes unsigned */
typedef unsigned long ULONG;
/* TODO: Remove this */
#undef WORD /* 2 bytes unsigned */
typedef unsigned short int WORD;
/* TODO: Remove this */
#undef DWORD /* 4 bytes unsigned */
typedef unsigned long DWORD;
@@ -145,6 +147,9 @@ typedef unsigned long DWORD;
#define __HARBOUR__
typedef BYTE HB_CHAR;
typedef BYTE HB_ATTR;
typedef HARBOUR ( * PHB_FUNC )( void );
typedef PHB_FUNC HB_FUNC_PTR;

View File

@@ -163,12 +163,12 @@ USHORT hb_max_col( void )
}
#ifndef HARBOUR_USE_GTAPI
static void adjust_pos( BYTE * pStr, ULONG len, USHORT * row, USHORT * col, USHORT max_row, USHORT max_col )
static void adjust_pos( BYTE * pStr, ULONG ulLen, USHORT * row, USHORT * col, USHORT max_row, USHORT max_col )
{
ULONG count;
ULONG ulCount;
BYTE * pPtr = pStr;
for( count = 0; count < len; count++ )
for( ulCount = 0; ulCount < ulLen; ulCount++ )
{
switch( *pPtr++ )
{
@@ -250,17 +250,17 @@ static void hb_out( USHORT uiParam, hb_out_func_typedef * hb_out_func )
}
/* Output an item to STDOUT */
static void hb_outstd( BYTE * pStr, ULONG len )
static void hb_outstd( BYTE * pStr, ULONG ulLen )
{
ULONG count = len;
ULONG ulCount = ulLen;
BYTE * pPtr = pStr;
#ifdef HARBOUR_USE_GTAPI
hb_gtPreExt();
#endif
if( strlen( pStr ) != count )
while( count-- ) printf( "%c", *pPtr++ );
if( strlen( pStr ) != ulCount )
while( ulCount-- ) printf( "%c", *pPtr++ );
else
printf( "%s", pStr );
fflush( stdout );
@@ -275,22 +275,22 @@ static void hb_outstd( BYTE * pStr, ULONG len )
}
hb_gtPostExt();
#else
adjust_pos( pStr, len, &s_uiDevRow, &s_uiDevCol, hb_max_row(), hb_max_col() );
adjust_pos( pStr, ulLen, &s_uiDevRow, &s_uiDevCol, hb_max_row(), hb_max_col() );
#endif
}
/* Output an item to STDERR */
static void hb_outerr( BYTE * pStr, ULONG len )
static void hb_outerr( BYTE * pStr, ULONG ulLen )
{
ULONG count = len;
ULONG ulCount = ulLen;
BYTE * pPtr = pStr;
#ifdef HARBOUR_USE_GTAPI
hb_gtPreExt();
#endif
if( strlen( pStr ) != count )
while( count-- ) fprintf( stderr, "%c", *pPtr++ );
if( strlen( pStr ) != ulCount )
while( ulCount-- ) fprintf( stderr, "%c", *pPtr++ );
else
fprintf( stderr, "%s", pStr );
fflush( stderr );
@@ -305,47 +305,47 @@ static void hb_outerr( BYTE * pStr, ULONG len )
}
hb_gtPostExt();
#else
adjust_pos( pStr, len, &s_uiDevRow, &s_uiDevCol, hb_max_row(), hb_max_col() );
adjust_pos( pStr, ulLen, &s_uiDevRow, &s_uiDevCol, hb_max_row(), hb_max_col() );
#endif
}
/* Output an item to the screen and/or printer and/or alternate */
static void hb_altout( BYTE * pStr, ULONG len )
static void hb_altout( BYTE * pStr, ULONG ulLen )
{
BYTE * pPtr = pStr;
if( hb_set.HB_SET_CONSOLE )
{
#ifdef HARBOUR_USE_GTAPI
hb_gtWriteCon( pStr, len );
hb_gtWriteCon( pStr, ulLen );
hb_gtGetPos( &s_uiDevRow, &s_uiDevCol );
#else
ULONG count = len;
if( strlen( pStr ) != count )
while( count-- ) printf( "%c", *pPtr++ );
ULONG ulCount = ulLen;
if( strlen( pStr ) != ulCount )
while( ulCount-- ) printf( "%c", *pPtr++ );
else
printf( "%s", pStr );
adjust_pos( pStr, len, &s_uiDevRow, &s_uiDevCol, hb_max_row(), hb_max_col() );
adjust_pos( pStr, ulLen, &s_uiDevRow, &s_uiDevCol, hb_max_row(), hb_max_col() );
#endif
}
if( hb_set.HB_SET_ALTERNATE && hb_set_althan >= 0 )
{
/* Print to alternate file if SET ALTERNATE ON and valid alternate file */
int user_ferror = hb_fsError(); /* Save current user file error code */
USHORT user_ferror = hb_fsError(); /* Save current user file error code */
unsigned write_len;
ULONG count = len;
ULONG ulCount = ulLen;
pPtr = pStr;
while( count )
while( ulCount )
{
if( count > UINT_MAX )
if( ulCount > UINT_MAX )
{
write_len = UINT_MAX;
count -= UINT_MAX;
ulCount -= UINT_MAX;
}
else
{
write_len = count;
count = 0;
write_len = ulCount;
ulCount = 0;
}
hb_fsWrite( hb_set_althan, ( BYTE * ) pPtr, write_len );
pPtr += write_len;
@@ -355,21 +355,21 @@ static void hb_altout( BYTE * pStr, ULONG len )
if( hb_set_extrahan >= 0 )
{
/* Print to extra file if valid alternate file */
int user_ferror = hb_fsError(); /* Save current user file error code */
USHORT user_ferror = hb_fsError(); /* Save current user file error code */
unsigned write_len;
ULONG count = len;
ULONG ulCount = ulLen;
pPtr = pStr;
while( count )
while( ulCount )
{
if( count > UINT_MAX )
if( ulCount > UINT_MAX )
{
write_len = UINT_MAX;
count -= UINT_MAX;
ulCount -= UINT_MAX;
}
else
{
write_len = count;
count = 0;
write_len = ulCount;
ulCount = 0;
}
hb_fsWrite( hb_set_extrahan, ( BYTE * ) pPtr, write_len );
pPtr += write_len;
@@ -379,93 +379,93 @@ static void hb_altout( BYTE * pStr, ULONG len )
if( hb_set.HB_SET_PRINTER && hb_set_printhan >= 0 )
{
/* Print to printer if SET PRINTER ON and valid printer file */
int user_ferror = hb_fsError(); /* Save current user file error code */
USHORT user_ferror = hb_fsError(); /* Save current user file error code */
unsigned write_len;
ULONG count = len;
ULONG ulCount = ulLen;
pPtr = pStr;
while( count )
while( ulCount )
{
if( count > UINT_MAX )
if( ulCount > UINT_MAX )
{
write_len = UINT_MAX;
count -= UINT_MAX;
ulCount -= UINT_MAX;
}
else
{
write_len = count;
count = 0;
write_len = ulCount;
ulCount = 0;
}
hb_fsWrite( hb_set_printhan, ( BYTE * ) pPtr, write_len );
pPtr += write_len;
}
if( len + s_uiPCol > USHRT_MAX ) s_uiPCol = USHRT_MAX;
else s_uiPCol += len;
if( ulLen + s_uiPCol > USHRT_MAX ) s_uiPCol = USHRT_MAX;
else s_uiPCol += ulLen;
hb_fsSetError( user_ferror ); /* Restore last user file error code */
}
}
/* Output an item to the screen and/or printer */
static void hb_devout( BYTE * pStr, ULONG len )
static void hb_devout( BYTE * pStr, ULONG ulLen )
{
if( hb_set_printhan >= 0 && hb_stricmp( hb_set.HB_SET_DEVICE, "PRINTER" ) == 0 )
{
/* Display to printer if SET DEVICE TO PRINTER and valid printer file */
int user_ferror = hb_fsError(); /* Save current user file error code */
USHORT user_ferror = hb_fsError(); /* Save current user file error code */
unsigned write_len;
ULONG count = len;
ULONG ulCount = ulLen;
BYTE * pPtr = pStr;
while( count )
while( ulCount )
{
if( count > UINT_MAX )
if( ulCount > UINT_MAX )
{
write_len = UINT_MAX;
count -= UINT_MAX;
ulCount -= UINT_MAX;
}
else
{
write_len = count;
count = 0;
write_len = ulCount;
ulCount = 0;
}
hb_fsWrite( hb_set_printhan, ( BYTE * ) pPtr, write_len );
pPtr += write_len;
}
if( len + s_uiPCol > USHRT_MAX ) s_uiPCol = USHRT_MAX;
else s_uiPCol += len;
if( ulLen + s_uiPCol > USHRT_MAX ) s_uiPCol = USHRT_MAX;
else s_uiPCol += ulLen;
hb_fsSetError( user_ferror ); /* Restore last user file error code */
}
else
{
#ifdef HARBOUR_USE_GTAPI
/* Otherwise, display to console */
hb_gtWrite( pStr, len );
hb_gtWrite( pStr, ulLen );
hb_gtGetPos( &s_uiDevRow, &s_uiDevCol );
#else
ULONG count = len;
ULONG ulCount = ulLen;
BYTE * pPtr = pStr;
if( strlen( pStr ) != count )
while( count-- ) printf( "%c", *pPtr++ );
if( strlen( pStr ) != ulCount )
while( ulCount-- ) printf( "%c", *pPtr++ );
else
printf( "%s", pStr );
adjust_pos( pStr, len, &s_uiDevRow, &s_uiDevCol, hb_max_row(), hb_max_col() );
adjust_pos( pStr, ulLen, &s_uiDevRow, &s_uiDevCol, hb_max_row(), hb_max_col() );
#endif
}
}
/* Output an item to the screen */
static void hb_dispout( BYTE * pStr, ULONG len )
static void hb_dispout( BYTE * pStr, ULONG ulLen )
{
#ifdef HARBOUR_USE_GTAPI
/* Display to console */
hb_gtWrite( pStr, len );
hb_gtWrite( pStr, ulLen );
hb_gtGetPos( &s_uiDevRow, &s_uiDevCol );
#else
ULONG count = len;
ULONG ulCount = ulLen;
BYTE * pPtr = pStr;
if( strlen( pStr ) != count )
while( count-- ) printf( "%c", *pPtr++ );
if( strlen( pStr ) != ulCount )
while( ulCount-- ) printf( "%c", *pPtr++ );
else
printf( "%s", pStr );
adjust_pos( pStr, len, &s_uiDevRow, &s_uiDevCol, hb_max_row(), hb_max_col() );
adjust_pos( pStr, ulLen, &s_uiDevRow, &s_uiDevCol, hb_max_row(), hb_max_col() );
#endif
}
@@ -474,7 +474,7 @@ void hb_setpos( USHORT row, USHORT col )
#ifdef HARBOUR_USE_GTAPI
hb_gtSetPos( row, col );
#else
USHORT count;
USHORT uiCount;
if( row < s_uiDevRow || col < s_uiDevCol )
{
@@ -483,9 +483,9 @@ void hb_setpos( USHORT row, USHORT col )
s_uiDevRow++;
}
else if( row > s_uiDevRow ) s_uiDevCol = 0;
for( count = s_uiDevRow; count < row; count++ )
for( uiCount = s_uiDevRow; uiCount < row; uiCount++ )
printf( s_szCrLf );
for( count = s_uiDevCol; count < col; count++ )
for( uiCount = s_uiDevCol; uiCount < col; uiCount++ )
printf( " " );
#endif
@@ -495,25 +495,25 @@ void hb_setpos( USHORT row, USHORT col )
void hb_devpos( USHORT row, USHORT col )
{
USHORT count;
USHORT uiCount;
/* Position printer if SET DEVICE TO PRINTER and valid printer file
otherwise position console */
if( hb_set_printhan >= 0 && hb_stricmp( hb_set.HB_SET_DEVICE, "PRINTER" ) == 0 )
{
int user_ferror = hb_fsError(); /* Save current user file error code */
USHORT user_ferror = hb_fsError(); /* Save current user file error code */
if( row < s_uiPRow )
{
hb_fsWrite( hb_set_printhan, ( BYTE * ) "\x0C", 1 );
s_uiPRow = s_uiPCol = 0;
}
for( count = s_uiPRow; count < row; count++ )
for( uiCount = s_uiPRow; uiCount < row; uiCount++ )
hb_fsWrite( hb_set_printhan, ( BYTE * ) s_szCrLf, CRLF_BUFFER_LEN-1 );
if( row > s_uiPRow ) s_uiPCol = 0;
col += hb_set.HB_SET_MARGIN;
for( count = s_uiPCol; count < col; count++ )
for( uiCount = s_uiPCol; uiCount < col; uiCount++ )
hb_fsWrite( hb_set_printhan, ( BYTE * ) " ", 1 );
s_uiPRow = row;
@@ -564,17 +564,17 @@ HARBOUR HB_QQOUT( void ) /* writes a list of values to the current device (scree
HARBOUR HB_QOUT( void )
{
USHORT count;
USHORT uiCount;
hb_altout( s_szCrLf, CRLF_BUFFER_LEN - 1 );
if( hb_set.HB_SET_PRINTER && hb_set_printhan >= 0 )
{
int user_ferror = hb_fsError(); /* Save current user file error code */
USHORT user_ferror = hb_fsError(); /* Save current user file error code */
s_uiPRow++;
s_uiPCol = hb_set.HB_SET_MARGIN;
count = s_uiPCol;
while( count-- > 0 )
uiCount = s_uiPCol;
while( uiCount-- > 0 )
hb_fsWrite( hb_set_printhan, ( BYTE * ) " ", 1 );
hb_fsSetError( user_ferror ); /* Restore last user file error code */
}
@@ -656,7 +656,7 @@ HARBOUR HB_DEVPOS( void ) /* Sets the screen and/or printer position */
HARBOUR HB_DEVOUT( void ) /* writes a single value to the current device (screen or printer), but is not affected by SET ALTERNATE */
{
if( hb_pcount() > 0 )
if( hb_pcount() >= 1 )
{
#ifdef HARBOUR_USE_GTAPI
char pOldColor[ CLR_STRLEN ];
@@ -679,7 +679,7 @@ HARBOUR HB_DEVOUT( void ) /* writes a single value to the current device (screen
HARBOUR HB_DISPOUT( void ) /* writes a single value to the current device (screen or printer), but is not affected by SET ALTERNATE */
{
if( hb_pcount() > 0 )
if( hb_pcount() >= 1 )
{
#ifdef HARBOUR_USE_GTAPI
char pOldColor[ CLR_STRLEN ];
@@ -704,7 +704,7 @@ HARBOUR HB___EJECT( void ) /* Ejects the current page from the printer */
{
if( hb_stricmp( hb_set.HB_SET_DEVICE, "PRINTER" ) == 0 && hb_set_printhan >= 0 )
{
int user_ferror = hb_fsError(); /* Save current user file error code */
USHORT user_ferror = hb_fsError(); /* Save current user file error code */
hb_fsWrite( hb_set_printhan, ( BYTE * ) "\x0C\x0D", 2 );
s_uiPRow = s_uiPCol = 0;
hb_fsSetError( user_ferror ); /* Restore last user file error code */
@@ -781,9 +781,9 @@ HARBOUR HB_SCROLL( void ) /* Scrolls a screen region (requires the GT API) */
&& left == 0 && right == iMC
&& v_scroll == 0 && h_scroll == 0 )
{
USHORT count;
USHORT uiCount;
s_uiDevRow = iMR;
for( count = 0; count < s_uiDevRow ; count++ ) printf( s_szCrLf );
for( uiCount = 0; uiCount < s_uiDevRow ; uiCount++ ) printf( s_szCrLf );
s_uiDevRow = s_uiDevCol = 0;
}
#endif
@@ -1014,7 +1014,7 @@ HARBOUR HB___SHADOW( void )
else if( hb_pcount() == 5 )
uiAttr = hb_parni( 5 );
if( hb_pcount() > 3 )
if( hb_pcount() >= 4 )
hb_gt_DrawShadow( hb_parni( 1 ) + 1,
hb_parni( 2 ) + 1,
hb_parni( 3 ) + 1,
@@ -1119,7 +1119,7 @@ HARBOUR HB___ACCEPT( void ) /* Internal Clipper function used in ACCEPT command
/* receive data. Parameter : cPrompt. Returns : cRet */
{
int input;
ULONG len;
ULONG ulLen;
if( hb_pcount() >= 1 ) /* cPrompt passed */
HB_QOUT();
@@ -1146,10 +1146,10 @@ HARBOUR HB___ACCEPT( void ) /* Internal Clipper function used in ACCEPT command
ta.c_lflag &= ~( ICANON | ECHO );
tcsetattr( STDIN_FILENO, TCSAFLUSH, &ta );
len = strlen( s_szAcceptResult );
ulLen = strlen( s_szAcceptResult );
}
#else
len = 0;
ulLen = 0;
input = 0;
while( input != 13 )
{
@@ -1159,9 +1159,9 @@ HARBOUR HB___ACCEPT( void ) /* Internal Clipper function used in ACCEPT command
{
case 8: /* Backspace */
case 19: /* Left arrow */
if( len > 0 )
if( ulLen > 0 )
{
len--; /* Adjust input count to get rid of last character,
ulLen--; /* Adjust input count to get rid of last character,
then erase it from the screen. */
#ifdef HARBOUR_USE_GTAPI
hb_gtWriteCon( "\x8 \x8", 3L );
@@ -1173,15 +1173,15 @@ HARBOUR HB___ACCEPT( void ) /* Internal Clipper function used in ACCEPT command
case 13: /* Nothing to do. While loop will now exit. */
break;
default:
if( len < ( ACCEPT_BUFFER_LEN - 1 ) && input >= 32 )
if( ulLen < ( ACCEPT_BUFFER_LEN - 1 ) && input >= 32 )
{
s_szAcceptResult[ len ] = input; /* Accept the input */
hb_dispout( &s_szAcceptResult[ len ], sizeof( char ) ); /* Then display it */
len++; /* Then adjust the input count */
s_szAcceptResult[ ulLen ] = input; /* Accept the input */
hb_dispout( &s_szAcceptResult[ ulLen ], sizeof( char ) ); /* Then display it */
ulLen++; /* Then adjust the input count */
}
}
}
s_szAcceptResult[ len ] = '\0';
s_szAcceptResult[ ulLen ] = '\0';
#endif
hb_retc( s_szAcceptResult );
}
@@ -1234,8 +1234,8 @@ HARBOUR HB___COLORINDEX( void )
if( ISCHAR( 1 ) && ISNUM( 2 ) )
{
char * szColor = hb_parc( 1 );
ULONG ulColorPos;
ULONG ulColorLen;
ULONG ulColorPos;
ULONG ulColorLen;
USHORT uiColorIndex = ( USHORT ) hb_parni( 2 );
/* Skip the given number of commas */

View File

@@ -69,6 +69,7 @@
*/
#include "extend.h"
#include "itemapi.h"
#define CHR_HARD1 ( ( char ) 13 )
#define CHR_HARD2 ( ( char ) 10 )
@@ -79,7 +80,7 @@
/* NOTE: pszResult must have an allocated buffer of at least */
/* ulStringLen */
char * hb_strMemotran( char * pszResult, ULONG * ulResultLen, char * pszString, ULONG ulStringLen, char cHardcr, char cSoftcr )
char * hb_strMemotran( char * pszResult, ULONG * ulResultLen, const char * pszString, ULONG ulStringLen, char cHardcr, char cSoftcr )
{
ULONG ulStringPos = 0;
ULONG ulResultPos = 0;
@@ -113,14 +114,16 @@ char * hb_strMemotran( char * pszResult, ULONG * ulResultLen, char * pszString,
HARBOUR HB_MEMOTRAN( void )
{
if( ISCHAR( 1 ) )
PHB_ITEM pString = hb_param( 1, IT_STRING );
if( pString )
{
char * pszResult = ( char * ) hb_xgrab ( hb_parclen( 1 ) + 1 );
char * pszResult = ( char * ) hb_xgrab( hb_itemGetCLen( pString ) + 1 );
char cHardcr = ISCHAR( 2 ) ? *hb_parc( 2 ) : ';';
char cSoftcr = ISCHAR( 3 ) ? *hb_parc( 3 ) : ' ';
ULONG ulResultLen;
hb_strMemotran( pszResult, &ulResultLen, hb_parc( 1 ), hb_parclen( 1 ), cHardcr, cSoftcr );
hb_strMemotran( pszResult, &ulResultLen, hb_itemGetCPtr( pString ), hb_itemGetCLen( pString ), cHardcr, cSoftcr );
hb_retclen( pszResult, ulResultLen );
hb_xfree( pszResult );

View File

@@ -1,4 +1,4 @@
/*
/*
* $Id$
*/
@@ -173,6 +173,7 @@
#include <ctype.h>
#include "extend.h"
#include "itemapi.h"
#include "errorapi.h"
#include "filesys.h"
#include "set.h"
@@ -186,59 +187,58 @@ FHANDLE hb_set_printhan;
static BOOL set_logical( PHB_ITEM pItem )
{
BOOL logical = FALSE;
BOOL bLogical = FALSE;
if( IS_LOGICAL( pItem ) )
logical = pItem->item.asLogical.value;
bLogical = hb_itemGetL( pItem );
else if( IS_STRING( pItem ) )
{
if( pItem->item.asString.length >= 2
&& toupper( pItem->item.asString.value[ 0 ] ) == 'O'
&& toupper( pItem->item.asString.value[ 1 ] ) == 'N' )
logical = TRUE;
else if( pItem->item.asString.length >= 3
&& toupper( pItem->item.asString.value[ 0 ] ) == 'O'
&& toupper( pItem->item.asString.value[ 1 ] ) == 'F'
&& toupper( pItem->item.asString.value[ 2 ] ) == 'F' )
logical = FALSE;
char * szString = hb_itemGetCPtr( pItem );
ULONG ulLen = hb_itemGetCLen( pItem );
if( ulLen >= 2
&& toupper( szString[ 0 ] ) == 'O'
&& toupper( szString[ 1 ] ) == 'N' )
bLogical = TRUE;
else if( ulLen >= 3
&& toupper( szString[ 0 ] ) == 'O'
&& toupper( szString[ 1 ] ) == 'F'
&& toupper( szString[ 2 ] ) == 'F' )
bLogical = FALSE;
}
return logical;
return bLogical;
}
static int set_number( PHB_ITEM pItem, int old_value )
static int set_number( PHB_ITEM pItem, int iOldValue )
{
int number;
if( IS_INTEGER( pItem ) ) number = pItem->item.asInteger.value;
else if( IS_LONG( pItem ) ) number = ( int ) pItem->item.asLong.value;
else if( IS_DOUBLE( pItem ) ) number = ( int ) pItem->item.asDouble.value;
else number = old_value;
return number;
if( IS_NUMERIC( pItem ) )
return hb_itemGetNI( pItem );
else
return iOldValue;
}
static char * set_string( PHB_ITEM pItem, char * old_str )
static char * set_string( PHB_ITEM pItem, char * szOldString )
{
char * string;
char * szString;
if( IS_STRING( pItem ) )
{
/* Limit size of SET strings to 64K, truncating if source is longer */
ULONG size = pItem->item.asString.length;
ULONG ulLen = hb_itemGetCLen( pItem );
if( size > USHRT_MAX ) size = USHRT_MAX;
if( ulLen > USHRT_MAX ) ulLen = USHRT_MAX;
if( old_str ) string = ( char * ) hb_xrealloc( old_str, size + 1 );
else string = ( char * ) hb_xgrab( size + 1 );
if( szOldString ) szString = ( char * ) hb_xrealloc( szOldString, ulLen + 1 );
else szString = ( char * ) hb_xgrab( ulLen + 1 );
memcpy( string, pItem->item.asString.value, size );
string[ size ] = '\0';
memcpy( szString, hb_itemGetCPtr( pItem ), ulLen );
szString[ ulLen ] = '\0';
}
else
string = old_str;
szString = szOldString;
return string;
return szString;
}
static void close_binary( FHANDLE handle )
@@ -247,7 +247,7 @@ static void close_binary( FHANDLE handle )
{
/* Close the file handle without disrupting the current
user file error value */
int user_ferror = hb_fsError();
USHORT user_ferror = hb_fsError();
hb_fsClose( handle );
hb_fsSetError( user_ferror );
}
@@ -259,7 +259,7 @@ static void close_text( FHANDLE handle )
{
/* Close the file handle without disrupting the current
user file error value */
int user_ferror = hb_fsError();
USHORT user_ferror = hb_fsError();
#if ! defined(OS_UNIX_COMPATIBLE)
hb_fsWrite( handle, ( BYTE * ) "\x1A", 1 );
#endif
@@ -270,7 +270,7 @@ static void close_text( FHANDLE handle )
static FHANDLE open_handle( char * file_name, BOOL bAppend, char * def_ext, HB_set_enum set_specifier )
{
int user_ferror = hb_fsError(); /* Save the current user file error code */
USHORT user_ferror = hb_fsError(); /* Save the current user file error code */
FHANDLE handle;
PHB_FNAME pFilename;
char path[ _POSIX_PATH_MAX + 1 ];
@@ -300,9 +300,9 @@ static FHANDLE open_handle( char * file_name, BOOL bAppend, char * def_ext, HB_s
if( bAppend )
{ /* Append mode */
if( hb_fsFile( ( BYTE * ) path ) )
{ /* If the file already exists, open it (in read-write mode, in
case of non-Unix and text modes). */
if( hb_fsFile( ( BYTE * ) path ) )
{ /* If the file already exists, open it (in read-write mode, in
case of non-Unix and text modes). */
handle = hb_fsOpen( ( BYTE * ) path, FO_READWRITE | FO_DENYWRITE );
if( handle != FS_ERROR )
{ /* Position to EOF */
@@ -344,7 +344,7 @@ static FHANDLE open_handle( char * file_name, BOOL bAppend, char * def_ext, HB_s
wResult = hb_errRT_TERM( EG_CREATE, 2015, NULL, path, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY );
else
wResult = E_DEFAULT;
if( wResult == E_DEFAULT || wResult == E_BREAK )
break;
}
@@ -371,7 +371,7 @@ HARBOUR HB_SETCANCEL( void )
*/
HARBOUR HB___SETCENTURY( void )
{
int old_century_setting = hb_set_century;
BOOL old_century_setting = hb_set_century;
/*
* Change the setting if the parameter is a logical value, or is
@@ -723,7 +723,7 @@ HARBOUR HB_SET( void )
if( args > 1 ) hb_set.HB_SET_CANCEL = set_logical( pArg2 );
break;
case HB_SET_COLOR :
hb_retc( hb_setColor( args >= 2 && IS_STRING( pArg2 ) ? pArg2->item.asString.value : ( char * ) NULL ) );
hb_retc( hb_setColor( args >= 2 && IS_STRING( pArg2 ) ? hb_itemGetCPtr( pArg2 ) : ( char * ) NULL ) );
break;
case HB_SET_CONFIRM :
hb_retl( hb_set.HB_SET_CONFIRM );

View File

@@ -47,7 +47,7 @@ char * hb_setColor( char * sColor )
hb_gtGetColorStr( hb_set.HB_SET_COLOR );
#else
strncpy( s_old_string, hb_set.HB_SET_COLOR, sizeof( hb_set.HB_SET_COLOR ) );
s_old_string[ sizeof( hb_set.HB_SET_COLOR ) - 1 ] = 0;
s_old_string[ sizeof( hb_set.HB_SET_COLOR ) - 1 ] = '\0';
#endif
if( sColor != ( char * ) NULL )
@@ -69,7 +69,7 @@ char * hb_setColor( char * sColor )
HARBOUR HB_SETCOLOR( void )
{
hb_retc( hb_setColor( hb_pcount() ? hb_parc( 1 ) : NULL ) );
hb_retc( hb_setColor( ISCHAR( 1 ) ? hb_parc( 1 ) : NULL ) );
}
HARBOUR HB_COLORSELECT( void )

View File

@@ -131,7 +131,7 @@
* $END$
*/
void hb_tone( double frequency, double duration )
void hb_tone( double dFrequency, double dDuration )
{
/* platform specific code */
/*
@@ -152,49 +152,49 @@ void hb_tone( double frequency, double duration )
#else
/* Unsupported platform. */
ULONG temp; /* Avoid unreferenced temp */
duration = -1; /* Exit without delay */
dDuration = -1.0; /* Exit without delay */
#endif
#if defined(HARBOUR_GCC_OS2) || defined(OS2) || defined(WINNT) || defined(_Windows) || defined(__MINGW32__)
frequency = MIN( MAX( 0.0, frequency ), 32767.0 );
duration = duration * 1000.0 / 18.2; /* milliseconds */
dFrequency = MIN( MAX( 0.0, dFrequency ), 32767.0 );
dDuration = dDuration * 1000.0 / 18.2; /* milliseconds */
#elif defined(__DJGPP) || defined(__BORLANDC__)
frequency = MIN( MAX( 0.0, frequency ), 32767.0 );
duration = duration * CLOCKS_PER_SEC / 18.2 ; /* clocks */
dFrequency = MIN( MAX( 0.0, dFrequency ), 32767.0 );
dDuration = dDuration * CLOCKS_PER_SEC / 18.2 ; /* clocks */
#endif
#if defined(__BORLANDC__) && ! defined(_Windows) && ! defined(WINNT)
sound( ( unsigned ) frequency );
sound( ( unsigned ) dFrequency );
#elif defined(__DJGPP__)
sound( ( int ) frequency );
sound( ( int ) dFrequency );
#endif
while( duration > 0.0 )
while( dDuration > 0.0 )
{
#if defined(HARBOUR_GCC_OS2) || defined(_Windows) || defined(__CYGWIN__)
temp = MIN( MAX ( 0, duration ), ULONG_MAX );
temp = MIN( MAX( 0, dDuration ), ULONG_MAX );
#elif defined(OS2) || defined(__BORLANDC__) || defined(__DJGPP__) || defined(__MINGW32__)
temp = MIN( MAX ( 0, duration ), USHRT_MAX );
temp = MIN( MAX( 0, dDuration ), USHRT_MAX );
#endif
duration -= temp;
dDuration -= temp;
if( temp <= 0 )
{
/* Ensure that the loop gets terminated when
only a fraction of the delay time remains. */
duration = -1.0;
dDuration = -1.0;
}
else
{
#if defined(HARBOUR_GCC_OS2)
DosBeep( ( ULONG ) frequency, temp );
DosBeep( ( ULONG ) dFrequency, temp );
#elif defined(OS2)
DosBeep( ( USHORT ) frequency, temp );
DosBeep( ( USHORT ) dFrequency, temp );
#elif defined(__MINGW32__)
beep( frequency, temp );
beep( dFrequency, temp );
#elif defined(WINNT)
Beep( ( ULONG ) frequency, temp );
Beep( ( ULONG ) dFrequency, temp );
#elif defined(_Windows) && ! defined(_Windows)
/* Bad news for non-NT Windows platforms: Beep() ignores
both parameters and either generates the default sound
event or the standard system beep. */
Beep( ( ULONG ) frequency, temp );
Beep( ( ULONG ) dFrequency, temp );
#elif defined(__DJGPP__) || ( defined(__BORLANDC__) && ! defined(_Windows) )
/* Note: delay() in <dos.h> for DJGPP does not work and
delay() in <dos.h> for BORLANDC is not multi-
@@ -214,14 +214,6 @@ void hb_tone( double frequency, double duration )
HARBOUR HB_TONE( void )
{
double frequency, duration;
if( PCOUNT > 0 && ISNUM( 1 ) )
{
frequency = hb_parnd ( 1 );
if( PCOUNT > 1 && ISNUM( 2 ) )
duration = hb_parnd( 2 );
else
duration = 1.0;
hb_tone( frequency, duration );
}
if( ISNUM( 1 ) )
hb_tone( hb_parnd( 1 ), ( ISNUM( 2 ) ? hb_parnd( 2 ) : 1.0 ) );
}

View File

@@ -2509,51 +2509,51 @@ void hb_stackDispLocal( void )
switch( hb_itemType( pBase ) )
{
case IT_NIL:
printf( "NIL " );
break;
printf( "NIL " );
break;
case IT_ARRAY:
if( hb_arrayIsObject( pBase ) )
printf( "OBJECT = %s ", hb_objGetClsName( pBase ) );
else
printf( "ARRAY " );
break;
if( hb_arrayIsObject( pBase ) )
printf( "OBJECT = %s ", hb_objGetClsName( pBase ) );
else
printf( "ARRAY " );
break;
case IT_BLOCK:
printf( "BLOCK " );
break;
printf( "BLOCK " );
break;
case IT_DATE:
printf( "DATE = \"%s\" ", hb_itemGetDS( pBase, stack.szDate ) );
break;
printf( "DATE = \"%s\" ", hb_itemGetDS( pBase, stack.szDate ) );
break;
case IT_DOUBLE:
printf( "DOUBLE = %f ", hb_itemGetND( pBase ) );
break;
printf( "DOUBLE = %f ", hb_itemGetND( pBase ) );
break;
case IT_LOGICAL:
printf( "LOGICAL = %s ", hb_itemGetL( pBase ) ? ".T." : ".F." );
break;
printf( "LOGICAL = %s ", hb_itemGetL( pBase ) ? ".T." : ".F." );
break;
case IT_LONG:
printf( "LONG = %lu ", hb_itemGetNL( pBase ) );
break;
printf( "LONG = %lu ", hb_itemGetNL( pBase ) );
break;
case IT_INTEGER:
printf( "INTEGER = %i ", hb_itemGetNI( pBase ) );
break;
printf( "INTEGER = %i ", hb_itemGetNI( pBase ) );
break;
case IT_STRING:
printf( "STRING = \"%s\" ", hb_itemGetCPtr( pBase ) );
break;
printf( "STRING = \"%s\" ", hb_itemGetCPtr( pBase ) );
break;
case IT_SYMBOL:
printf( "SYMBOL = %s ", pBase->item.asSymbol.value->szName );
break;
printf( "SYMBOL = %s ", pBase->item.asSymbol.value->szName );
break;
default:
printf( "UNKNOWN = TYPE %i ", hb_itemType( pBase ) );
break;
printf( "UNKNOWN = TYPE %i ", hb_itemType( pBase ) );
break;
}
}
}
@@ -3089,7 +3089,7 @@ HARBOUR HB_ERRORLEVEL( void )
/* NOTE: This should be ISNUM( 1 ), but it's sort of a Clipper bug that it
accepts other types also and consider them zero. */
if( hb_pcount() > 0 )
if( hb_pcount() >= 1 )
/* Only replace the error level if a parameter was passed */
s_byErrorLevel = hb_parni( 1 );
}
@@ -3109,7 +3109,7 @@ HARBOUR HB_PCOUNT( void )
HARBOUR HB_PVALUE( void ) /* PValue( <nArg> ) */
{
WORD wParam = hb_parni( 1 ); /* Get parameter */
WORD wParam = hb_parni( 1 ); /* Get parameter */
PHB_ITEM pBase = stack.pItems + stack.pBase->item.asSymbol.stackbase;
/* Skip function + self */