From 85ffaae73a2e555dbc84c9ede856386982c3ec0e Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Mon, 30 Jul 2007 16:00:32 +0000 Subject: [PATCH] 2007-07-30 18:00 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbcompat.ch + added #xtranslate ISPOINTER( ) * simplified bit operator translations * harbour/include/hbapi.h + added #define hb_itemPutCStatic(...) hb_itemPutCConst(...) * harbour/include/hbapiitm.h - removed #define hb_retclenAdoptRaw(...) hb_retclen_buffer(...) it's not _exactly_ the same and in some cases it cannot be replaced so users should know what exactly they are doing * harbour/source/rtl/gttrm/gttrm.c + added some #ifdef OS_UNIX_COMPATIBLE for future non *nix ports * harbour/source/rdd/dbf1.c ! added RT error when someone tires to create DBF with more then 2046 fields - without it corrupted files were created or GPF appeared * harbour/contrib/ole2/w32ole.c * changed hb_retclenAdoptRaw() to hb_retclen_buffer() --- harbour/ChangeLog | 24 ++++++++++++++ harbour/contrib/ole2/w32ole.c | 4 +-- harbour/include/hbapi.h | 1 - harbour/include/hbapiitm.h | 1 + harbour/include/hbcompat.ch | 25 +++++++------- harbour/source/rdd/dbf1.c | 13 ++++++++ harbour/source/rtl/gttrm/gttrm.c | 56 ++++++++++++++++++++++++-------- 7 files changed, 96 insertions(+), 28 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 1cd34cd1e2..3debe44e6a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,30 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-07-30 18:00 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbcompat.ch + + added #xtranslate ISPOINTER( ) + * simplified bit operator translations + + * harbour/include/hbapi.h + + added #define hb_itemPutCStatic(...) hb_itemPutCConst(...) + + * harbour/include/hbapiitm.h + - removed #define hb_retclenAdoptRaw(...) hb_retclen_buffer(...) + it's not _exactly_ the same and in some cases it cannot be + replaced so users should know what exactly they are doing + + * harbour/source/rtl/gttrm/gttrm.c + + added some #ifdef OS_UNIX_COMPATIBLE for future non *nix ports + + * harbour/source/rdd/dbf1.c + ! added RT error when someone tires to create DBF with more then + 2046 fields - without it corrupted files were created or GPF + appeared + + * harbour/contrib/ole2/w32ole.c + * changed hb_retclenAdoptRaw() to hb_retclen_buffer() + 2007-07-27 01:52 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/make_gcc.sh * harbour/makefile.gc diff --git a/harbour/contrib/ole2/w32ole.c b/harbour/contrib/ole2/w32ole.c index ec5a441c60..52b5043635 100644 --- a/harbour/contrib/ole2/w32ole.c +++ b/harbour/contrib/ole2/w32ole.c @@ -221,7 +221,7 @@ static void TraceLog( const char * sFile, const char * sTraceMsg, ... ) if( nConvertedLen ) { - LPWSTR wString = (LPWSTR) hb_xgrab( nConvertedLen * 2 ); + LPWSTR wString = (LPWSTR) hb_xgrab( nConvertedLen * 2 + 1 ); if( MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, cString, -1, wString, nConvertedLen ) ) { @@ -296,7 +296,7 @@ static void TraceLog( const char * sFile, const char * sTraceMsg, ... ) if( wString ) { - hb_retclenAdoptRaw( (char *) wString, SysStringLen( wString ) ); + hb_retclen_buffer( (char *) wString, SysStringLen( wString ) ); return; } } diff --git a/harbour/include/hbapi.h b/harbour/include/hbapi.h index 00d2447d6d..a154f13f0a 100644 --- a/harbour/include/hbapi.h +++ b/harbour/include/hbapi.h @@ -597,7 +597,6 @@ extern HB_EXPORT void hb_retnlllen( LONGLONG lNumber, int iWidth ); /* returns /* xHarbour compatible function */ #define hb_retcAdopt( szText ) hb_retc_buffer( (szText) ) #define hb_retclenAdopt( szText, ulLen ) hb_retclen_buffer( (szText), (ulLen) ) -#define hb_retclenAdoptRaw( szText, ulLen ) hb_retclen_buffer( (szText), (ulLen) ) #define hb_retcStatic( szText ) hb_retc_const( (szText) ) #ifdef HB_API_MACROS diff --git a/harbour/include/hbapiitm.h b/harbour/include/hbapiitm.h index f80ad2712f..3a88f5dfbc 100644 --- a/harbour/include/hbapiitm.h +++ b/harbour/include/hbapiitm.h @@ -195,6 +195,7 @@ extern HB_EXPORT void hb_itemSwap ( PHB_ITEM pItem1, PHB_ITEM pItem2 ) /* xHarbour compatible function */ #define hb_itemForwardValue( dst, src ) hb_itemMove( (dst), (src) ) +#define hb_itemPutCStatic( itm, str ) hb_itemPutCConst( (itm), (str) ) HB_EXTERN_END diff --git a/harbour/include/hbcompat.ch b/harbour/include/hbcompat.ch index c93bad6927..5426db86ef 100644 --- a/harbour/include/hbcompat.ch +++ b/harbour/include/hbcompat.ch @@ -130,8 +130,13 @@ #xtranslate HEXTONUM([]) => HB_HEXTONUM() #xtranslate NUMTOHEX([]) => HB_NUMTOHEX() + + #xtranslate ISPOINTER( ) => HB_ISPOINTER( ) + + #xcommand TEXT INTO => #pragma __text|+=%s+HB_OSNEWLINE();:="" + /* SWITCH ... ; case ... ; DEFAULT ; ... ; END */ #xcommand DEFAULT => OTHERWISE @@ -145,18 +150,14 @@ #xcommand > [<*x*>] => } /* xHarbour operators: IN, HAS, LIKE, >>, <<, |, &, ^^ */ - #translate ( IN ) => ( $ ) - #translate ( HAS ) => ( HB_REGEXHAS( , ) ) - #translate ( LIKE ) => ( HB_REGEXLIKE( , ) ) - #translate ( \<\< ) => ( HB_BITSHIFT( , ) ) - #translate ( >> ) => ( HB_BITSHIFT( , - ) ) - #translate ( | ) => ( HB_BITOR( , ) ) - #translate ( & ) => ( HB_BITAND( , ) ) - #translate ( ^^ ) => ( HB_BITXOR( , ) ) - - #xtranslate HB_BITOR( [,] | ) => HB_BITOR( [,] , ) - #xtranslate HB_BITAND( [,] & ) => HB_BITAND( [,] , ) - #xtranslate HB_BITXOR( [,] ^^ ) => HB_BITXOR( [,] , ) + #translate ( IN ) => ( () $ () ) + #translate ( HAS ) => ( HB_REGEXHAS( (), () ) ) + #translate ( LIKE ) => ( HB_REGEXLIKE( (), () ) ) + #translate ( \<\< ) => ( HB_BITSHIFT( (), () ) ) + #translate ( >> ) => ( HB_BITSHIFT( (), -() ) ) + #translate ( | ) => ( HB_BITOR( (), () ) ) + #translate ( & ) => ( HB_BITAND( (), () ) ) + #translate ( ^^ ) => ( HB_BITXOR( (), () ) ) #endif diff --git a/harbour/source/rdd/dbf1.c b/harbour/source/rdd/dbf1.c index 25aeed6b47..f07fce526c 100644 --- a/harbour/source/rdd/dbf1.c +++ b/harbour/source/rdd/dbf1.c @@ -2290,6 +2290,19 @@ static ERRCODE hb_dbfCreate( DBFAREAP pArea, LPDBOPENINFO pCreateInfo ) hb_itemRelease( pItem ); } + if( pArea->uiFieldCount * sizeof( DBFFIELD ) + sizeof( DBFHEADER ) + + ( pArea->bTableType == DB_DBF_VFP ? 1 : 2 ) > UINT16_MAX ) + { + pError = hb_errNew(); + hb_errPutGenCode( pError, EG_CREATE ); + hb_errPutSubCode( pError, EDBF_DATAWIDTH ); + hb_errPutDescription( pError, hb_langDGetErrorDesc( EG_CREATE ) ); + hb_errPutFileName( pError, ( char * ) pCreateInfo->abName ); + SELF_ERROR( ( AREAP ) pArea, pError ); + hb_itemRelease( pError ); + return FAILURE; + } + if( !fRawBlob ) { pError = NULL; diff --git a/harbour/source/rtl/gttrm/gttrm.c b/harbour/source/rtl/gttrm/gttrm.c index 89cddd52d2..4b0be0b985 100644 --- a/harbour/source/rtl/gttrm/gttrm.c +++ b/harbour/source/rtl/gttrm/gttrm.c @@ -147,16 +147,26 @@ static HB_GT_FUNCS SuperTable; #define MOUSE_GPM 1 #define MOUSE_XTERM 2 -#define TIMEVAL_GET(tv) gettimeofday(&(tv), NULL); +#if defined( OS_UNIX_COMPATIBLE ) + +#define TIMEVAL_GET(tv) gettimeofday(&(tv), NULL) #define TIMEVAL_LESS(tv1, tv2) (((tv1).tv_sec == (tv2).tv_sec ) ? \ ((tv1).tv_usec < (tv2).tv_usec) : \ ((tv1).tv_sec < (tv2).tv_sec )) -#define TIMEVAL_ADD(dst, src, n) { \ - (dst).tv_sec = (src).tv_sec + n / 1000; \ +#define TIMEVAL_ADD(dst, src, n) do { \ + (dst).tv_sec = (src).tv_sec + (n) / 1000; \ if(((dst).tv_usec = (src).tv_usec+(n%1000)*1000)>=1000000) {\ (dst).tv_usec -= 1000000; (dst).tv_sec++; \ } \ - } + } while( 0 ) + +#else + +#define TIMEVAL_GET(tv) do { (tv) = hb_dateSeconds(); } while( 0 ) +#define TIMEVAL_LESS(tv1, tv2) ((tv1) < (tv2)) +#define TIMEVAL_ADD(dst, src, n) do { (dst) = (src) + n / 1000; } while( 0 ) + +#endif #define KEY_ALTMASK 0x10000000 #define KEY_CTRLMASK 0x20000000 @@ -250,9 +260,15 @@ typedef struct { int mbup_row, mbup_col; int mbdn_row, mbdn_col; /* to analize DBLCLK on xterm */ +#if defined( OS_UNIX_COMPATIBLE ) struct timeval BL_time; struct timeval BR_time; struct timeval BM_time; +#else + double BL_time; + double BR_time; + double BM_time; +#endif } mouseEvent; typedef struct _keyTab { @@ -509,7 +525,7 @@ static const ClipKeyCode extdKeyTab[NO_EXTDKEYS] = { static int getClipKey( int nKey ) { - int nRet = 0, nFlag = 0, n; + int nRet = 0, nFlag, n; if( IS_CLIPKEY( nKey ) ) nRet = GET_CLIPKEY( nKey ); @@ -731,18 +747,23 @@ static int add_efds( int fd, int mode, int ( *eventFunc ) ( int, int, void * ), void *data ) { evtFD *pefd = NULL; - int i, fl; + int i; if( eventFunc == NULL && mode != O_RDONLY ) return -1; - if( ( fl = fcntl( fd, F_GETFL, 0 ) ) == -1 ) - return -1; +#if defined( OS_UNIX_COMPATIBLE ) + { + int fl; + if( ( fl = fcntl( fd, F_GETFL, 0 ) ) == -1 ) + return -1; - fl &= O_ACCMODE; - if( ( fl == O_RDONLY && mode == O_WRONLY ) || - ( fl == O_WRONLY && mode == O_RDONLY ) ) - return -1; + fl &= O_ACCMODE; + if( ( fl == O_RDONLY && mode == O_WRONLY ) || + ( fl == O_WRONLY && mode == O_RDONLY ) ) + return -1; + } +#endif for( i = 0; i < s_termState.efds_no && !pefd; i++ ) if( s_termState.event_fds[i]->fd == fd ) @@ -908,7 +929,11 @@ static void chk_mevtdblck( mouseEvent * mEvt ) if( newbuttons != 0 ) { +#if defined( OS_UNIX_COMPATIBLE ) struct timeval tv; +#else + double tv; +#endif TIMEVAL_GET( tv ); if( newbuttons & M_BUTTON_LEFT ) @@ -1175,8 +1200,13 @@ static int get_inch( int milisec ) { unsigned char buf[STDIN_BUFLEN]; +#if defined( OS_UNIX_COMPATIBLE ) n = read( s_termState.event_fds[i]->fd, buf, STDIN_BUFLEN - s_termState.stdin_inbuf ); +#else + n = hb_fsRead( s_termState.event_fds[i]->fd, buf, + STDIN_BUFLEN - s_termState.stdin_inbuf ); +#endif if( n == 0 ) s_termState.event_fds[i]->status = EVTFDSTAT_STOP; else @@ -2064,7 +2094,7 @@ static void hb_gt_trm_SetDispTrans( char * src, char * dst, int box ) if( src && dst ) { - for( i = 0; i < 256 && ( c = ( unsigned char ) src[i] ); i++ ) + for( i = 0; i < 256 && ( c = ( unsigned char ) src[i] ) != 0; i++ ) { d = ( unsigned char ) dst[i]; s_termState.chrattr[c] = d | HB_GTTRM_ATTR_STD;