diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 87d028904c..2d76370c46 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,55 @@ +19990719-03:10 EDT David G. Holm + * config/os2/icc.cf + + Added /Gs+ option to enable runtime stack checking + * include/dates.h + + Added prototype for hb_dow() + * include/gtapi.h + + Added prototype for hb_gtExit() + * include/set.h + + Added prototype for hb_setColor() + * Changed hb_set.HB_SET_COLOR from char * to char[64] + * source/compiler/harbour.y + * Replaced _StdFunc table with new table supplied by Jose Lalin, + while keeping the entry for SET that Paul Tucker had CVSed + * source/hbpp/hbpp.c + * Made mpatt and rpatt buffers in ParseCommand() static. + * source/hbpp/hbppint.c + * Allocate sBuffer in Hp_Parse() using _xgrab() (and + release with _xfree() before exiting) + * source/rtl/console.c + + Added call to hb_gtInit() to InitializeConsole() + - Removed all gt...() calls from InitializeConsole() + * source/rtl/gtapi.c + + Added gt...() calls that used to be in InitializeConsole() + to hb_gtInit() and also added a call to gtInit() + * Renamed hb_gtexit() to hb_gtExit() to match Harbour style + * Converted three // style comments to /* style comments */ + * source/rtl/set.c + * Simplified handling of HB_SET_COLOR by just calling hb_setColor() + * Made changes related to hb_set.HB_SET_COLOR now being char[64] + * source/rtl/setcolor.c + + Added #include + * Replaced gt prototypes with #include + * Changed hb_SetColor() to hb_setColor() to match Harbour style + * Changed hb_setColor() to use hb_set.HB_SET_COLOR instead of + allocating a buffer and requiring the caller to free the buffer + + Added conditional logic for not using the GT API + * source/rtl/gt/gtwin.c + - Removed call to hb_gtInit() + * source/tools/dates2.c + + Added #include + ! Added missing semicolon to HB_INIT_SYMBOLS_END() + - Removed prototypes for hb_dow() and hb_dateDecode() + * tests/working/Makefile + - Removed strings4.prg + + Added tstcolor.prg + * tests/working/empty.prg + - Removed call to empty() with no parameters, because + it now results in a compile error + - tests/working/string4.prg + - Removed this test program, because Harbour now checks for + the correct number of arguments when compiling + 19990719-00:55 EDT Paul Tucker * source/rtl/set.c * Trap for NIL param in Set( _SET_SETCOLOR, NIL ) diff --git a/harbour/config/os2/icc.cf b/harbour/config/os2/icc.cf index 4b09c5d6d9..4d7c116cc9 100644 --- a/harbour/config/os2/icc.cf +++ b/harbour/config/os2/icc.cf @@ -13,7 +13,7 @@ CC = icc CC_IN = /C+ /Tp CC_OUT = /Fo CPPFLAGS = /I$(GRANDP) /I$(HB_INC_COMPILE) /DHARBOUR_USE_GTAPI /DHARBOUR_USE_OS2_GTAPI -CFLAGS = /W2 /Se /Sd+ /Ti+ +CFLAGS = /Gs+ /W2 /Se /Sd+ /Ti+ LD = icc LD_OUT = /Fe diff --git a/harbour/include/dates.h b/harbour/include/dates.h index 15d6e58a73..6cf1b2a9d3 100644 --- a/harbour/include/dates.h +++ b/harbour/include/dates.h @@ -5,6 +5,7 @@ #ifndef HB_DATES_H_ #define HB_DATES_H_ +long hb_dow( long d, long m, long y ); char * hb_dtoc( const char * szDate, char * szFormattedDate, const char * szDateFormat ); long hb_dateEncode( long lDay, long lMonth, long lYear ); void hb_dateDecode( long julian, long * plDay, long * plMonth, long * plYear ); diff --git a/harbour/include/gtapi.h b/harbour/include/gtapi.h index 9baddcbdbc..6d1036a4e5 100644 --- a/harbour/include/gtapi.h +++ b/harbour/include/gtapi.h @@ -49,6 +49,7 @@ /* Public interface. These should never change, only be added to. */ void hb_gtInit(void); +void hb_gtExit(void); int hb_gtBox(USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, char * fpBoxString); int hb_gtBoxD(USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight); int hb_gtBoxS(USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight); diff --git a/harbour/include/set.h b/harbour/include/set.h index e6d860b425..14866628df 100644 --- a/harbour/include/set.h +++ b/harbour/include/set.h @@ -29,6 +29,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit their web site at http://www.gnu.org/). + V 1.47 David G. Holm Changed hb_set.HB_SET_COLOR to be a + fixed 64 byte buffer. Added prototype + for hb_setColor() V 1.14 David G. Holm Removed the obsolete hb_set_fixed and HB_SETFIXED(), which I should have done when I took HB_SETFIXED() @@ -62,6 +65,7 @@ HARBOUR HB_SET (void); HARBOUR HB_SETCENTURY (void); +char * hb_setColor (char *); void hb_setInitialize (void); void hb_setRelease (void); @@ -134,7 +138,7 @@ typedef struct char *HB_SET_ALTFILE; /* Character */ BOOL HB_SET_BELL; /* Logical */ BOOL HB_SET_CANCEL; /* Logical */ - char *HB_SET_COLOR; /* Character */ + char HB_SET_COLOR[ 64 ]; /* Character */ BOOL HB_SET_CONFIRM; /* Logical */ BOOL HB_SET_CONSOLE; /* Logical */ HB_cursor_enum HB_SET_CURSOR; /* Numeric */ diff --git a/harbour/source/compiler/harbour.y b/harbour/source/compiler/harbour.y index d76a89d7de..be4e8dae9f 100644 --- a/harbour/source/compiler/harbour.y +++ b/harbour/source/compiler/harbour.y @@ -4951,13 +4951,13 @@ static FUNCINFO _StdFun[] = { { "AADD" , 2, 2 }, { "ABS" , 1, 1 }, { "ASC" , 1, 1 }, -{ "AT" , 1, 1 }, +{ "AT" , 2, 2 }, { "BOF" , 0, 0 }, -{ "BREAK" , 1, 1 }, +{ "BREAK" , 0, 1 }, { "CDOW" , 1, 1 }, { "CHR" , 1, 1 }, { "CMONTH" , 1, 1 }, -{ "COL" , 1, 1 }, +{ "COL" , 0, 0 }, { "CTOD" , 1, 1 }, { "DATE" , 0, 0 }, { "DAY" , 1, 1 }, @@ -4969,16 +4969,15 @@ static FUNCINFO _StdFun[] = { { "EMPTY" , 1, 1 }, { "EOF" , 0, 0 }, { "EXP" , 1, 1 }, -{ "FCOUNT" , 1, 1 }, +{ "FCOUNT" , 0, 0 }, { "FIELDNAME" , 1, 1 }, { "FILE" , 1, 1 }, { "FLOCK" , 0, 0 }, { "FOUND" , 0, 0 }, -{ "INKEY" , 1, 1 }, +{ "INKEY" , 1, 2 }, { "INT" , 1, 1 }, { "LASTREC" , 0, 0 }, { "LEN" , 1, 1 }, -{ "LOCK" , 0, 0 }, { "LOG" , 1, 1 }, { "LOWER" , 1, 1 }, { "LTRIM" , 1, 1 }, @@ -4986,13 +4985,13 @@ static FUNCINFO _StdFun[] = { { "MIN" , 2, 2 }, { "MONTH" , 1, 1 }, { "PCOL" , 0, 0 }, -{ "PCOUNT" , 1, 1 }, +{ "PCOUNT" , 0, 0 }, { "PROW" , 0, 0 }, { "RECCOUNT" , 0, 0 }, { "RECNO" , 0, 0 }, { "REPLICATE" , 2, 2 }, { "RLOCK" , 0, 0 }, -{ "ROUND" , 1, 2 }, +{ "ROUND" , 2, 2 }, { "ROW" , 0, 0 }, { "RTRIM" , 1, 1 }, { "SECONDS" , 0, 0 }, @@ -5001,7 +5000,7 @@ static FUNCINFO _StdFun[] = { { "SETPOS" , 2, 2 }, { "SPACE" , 1, 1 }, { "SQRT" , 1, 1 }, -{ "STR" , 1, 2 }, +{ "STR" , 1, 3 }, { "SUBSTR" , 2, 3 }, { "TIME" , 0, 0 }, { "TRANSFORM" , 2, 2 }, diff --git a/harbour/source/hbpp/hbpp.c b/harbour/source/hbpp/hbpp.c index 2ee577b027..09ba790315 100644 --- a/harbour/source/hbpp/hbpp.c +++ b/harbour/source/hbpp/hbpp.c @@ -383,8 +383,8 @@ int TraSearch(char *cmdname, int ncmd) int ParseCommand( char* sLine, int com_or_xcom, int com_or_tra ) { + static char mpatt[STR_SIZE], rpatt[STR_SIZE]; char cmdname[MAX_NAME]; - char mpatt[STR_SIZE], rpatt[STR_SIZE]; int mlen,rlen; int ipos, rez; diff --git a/harbour/source/hbpp/hbppint.c b/harbour/source/hbpp/hbppint.c index 8de3a49a78..b1163c9619 100644 --- a/harbour/source/hbpp/hbppint.c +++ b/harbour/source/hbpp/hbppint.c @@ -142,7 +142,7 @@ int PreProcess( FILE* handl_i, FILE* handl_o, char *sOut ) int Hp_Parse( FILE* handl_i, FILE* handl_o ) { - char sBuffer[BUFF_SIZE]; /* File read buffer */ + char *sBuffer = (char *)_xgrab( BUFF_SIZE ); /* File read buffer */ char *ptr; int lContinue = 0; int iBuffer = 10, lenBuffer = 10; @@ -177,6 +177,7 @@ int Hp_Parse( FILE* handl_i, FILE* handl_o ) } } } + _xfree( sBuffer ); return 0; } diff --git a/harbour/source/rtl/console.c b/harbour/source/rtl/console.c index 3c62577d6a..8f8972f9a6 100644 --- a/harbour/source/rtl/console.c +++ b/harbour/source/rtl/console.c @@ -138,10 +138,8 @@ HB_CALL_ON_STARTUP_BEGIN( InitializeConsole ) #endif #ifdef HARBOUR_USE_GTAPI - gtInit(); - dev_row = gtWhereY(); - dev_col = gtWhereX(); - hb_gtSetPos( dev_row, dev_col ); + hb_gtInit(); + hb_gtGetPos( &dev_row, & dev_col); #else dev_row = 0; dev_col = 0; diff --git a/harbour/source/rtl/gt/gtwin.c b/harbour/source/rtl/gt/gtwin.c index cfcbc66508..72d4201078 100644 --- a/harbour/source/rtl/gt/gtwin.c +++ b/harbour/source/rtl/gt/gtwin.c @@ -51,7 +51,6 @@ void gtInit(void) LOG("Initializing"); HInput = GetStdHandle(STD_INPUT_HANDLE); HOutput = GetStdHandle(STD_OUTPUT_HANDLE); - hb_gtInit(); /* in ..\gtapi.c */ } HARBOUR GTINIT( void ) diff --git a/harbour/source/rtl/gtapi.c b/harbour/source/rtl/gtapi.c index 793393c724..931d30f6a2 100644 --- a/harbour/source/rtl/gtapi.c +++ b/harbour/source/rtl/gtapi.c @@ -6,12 +6,18 @@ * GTAPI.C: Generic Terminal for Harbour * * Latest mods: + * 1.25 19990718 dholm Moved calls to various gtFunctions out of + * InitializeConsole() in console.c and put + * them in hb_gtInit() in this module. Use + * hb_set.HB_SET_COLOR to initialize the GT + * API color string. Converted // comments. * 1.24 19990718 ptucker corrected returned color strings so ordering * is the same as clipper. * 1.23 19990718 ptucker implimented surface for gtGet/SetColorStr() * changed to allow unlimited color pairs. */ +#include #include /* TODO: functions not implemented yet @@ -25,7 +31,6 @@ static USHORT s_uiCurrentRow = 0; static USHORT s_uiCurrentCol = 0; static USHORT s_uiDispCount = 0; static USHORT s_uiColorIndex = 0; -static char s_szColorStr[CLR_STRLEN] = {"W/N, N/W, N/N, N/N, N/W"}; int *_Color; int _ColorCount; @@ -34,12 +39,14 @@ int _ColorCount; void hb_gtInit(void) { + gtInit(); + hb_gtSetPos( gtWhereY(), gtWhereX() ); _Color = (int *)hb_xgrab(5*sizeof(int)); _ColorCount = 5; - hb_gtSetColorStr( s_szColorStr ); + hb_gtSetColorStr( hb_set.HB_SET_COLOR ); } -void hb_gtexit(void) +void hb_gtExit(void) { hb_xfree( _Color ); } @@ -210,7 +217,7 @@ int hb_gtSetColorStr(char * fpColorString) case '*': nBack |= 128; break; - case 'I': // =N/W + case 'I': /* =N/W */ if( npos == _ColorCount ) { _Color = (int *)hb_xrealloc( _Color, sizeof(int)*(npos +1) ); @@ -220,7 +227,7 @@ int hb_gtSetColorStr(char * fpColorString) nBack = nColor = 0; nSkip = 1; break; - case 'X': // always sets forground to 'N' + case 'X': /* always sets forground to 'N' */ nColor=0; break; case ',': @@ -251,7 +258,7 @@ int hb_gtGetColorStr(char * fpColorString) char *sColors; int i,j=0,k = 0, nColor; - sColors = (char *)hb_xgrab( _ColorCount * 8 + 1 ); // max possible + sColors = (char *)hb_xgrab( _ColorCount * 8 + 1 ); /* max possible */ for( i=0; i<_ColorCount; i++ ) { diff --git a/harbour/source/rtl/set.c b/harbour/source/rtl/set.c index bea2fc069d..40cc17d4df 100644 --- a/harbour/source/rtl/set.c +++ b/harbour/source/rtl/set.c @@ -29,6 +29,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit their web site at http://www.gnu.org/). + V 1.48 David G. Holm Simplified SET_COLOR handling. + Made changes to deal with the + hb_set.HB_SET_COLOR string having + a fixed 64 byte size. V 1.46 Paul Tucker Modifed SetColor handling. V 1.43 David G. Holm Removed the obsolete hb_set_fixed, which I should have done when I took @@ -173,7 +177,6 @@ BOOL hb_set_century; int hb_set_althan; int hb_set_extrahan; int hb_set_printhan; -char *hb_SetColor( char *sColor ); HARBOUR HB_SET( void ); HARBOUR HB___SETCENTURY( void ); @@ -666,13 +669,7 @@ HARBOUR HB_SET (void) if (args > 1) hb_set.HB_SET_CANCEL = set_logical (pArg2); break; case HB_SET_COLOR : -/* - if (hb_set.HB_SET_COLOR) hb_retc (hb_set.HB_SET_COLOR); - else hb_retc (""); - if (args > 1) hb_set.HB_SET_COLOR = set_string (pArg2, hb_set.HB_SET_COLOR); -*/ - if (hb_set.HB_SET_COLOR) hb_xfree(hb_set.HB_SET_COLOR ); - hb_retc( hb_set.HB_SET_COLOR = hb_SetColor( args>1 ? IS_NIL(pArg2) ? "" : pArg2->item.asString.value : (char *)0)); + hb_retc( hb_setColor( args ? pArg2->item.asString.value : (char *)0) ); break; case HB_SET_CONFIRM : hb_retl (hb_set.HB_SET_CONFIRM); @@ -899,8 +896,8 @@ void hb_setInitialize (void) hb_set.HB_SET_ALTFILE = 0; /* NULL pointer */ hb_set.HB_SET_BELL = FALSE; hb_set.HB_SET_CANCEL = TRUE; - hb_set.HB_SET_COLOR = (char*)hb_xgrab (20UL); - memcpy (hb_set.HB_SET_COLOR, "W/N,N/W,N/N,N/N,N/W", 20); + strncpy (hb_set.HB_SET_COLOR, "W/N,N/W,N/N,N/N,N/W", sizeof ( hb_set.HB_SET_COLOR ) ); + hb_set.HB_SET_COLOR[ sizeof ( hb_set.HB_SET_COLOR ) - 1 ] = 0; hb_set.HB_SET_CONFIRM = FALSE; hb_set.HB_SET_CONSOLE = TRUE; hb_set.HB_SET_CURSOR = SC_NORMAL; @@ -951,8 +948,6 @@ void hb_setRelease (void) if (hb_set.HB_SET_ALTFILE) hb_xfree (hb_set.HB_SET_ALTFILE); - if (hb_set.HB_SET_COLOR) - hb_xfree (hb_set.HB_SET_COLOR); if (hb_set.HB_SET_DATEFORMAT) hb_xfree (hb_set.HB_SET_DATEFORMAT); if (hb_set.HB_SET_DEFAULT) diff --git a/harbour/source/rtl/setcolor.c b/harbour/source/rtl/setcolor.c index d4c3acb98b..8f1ed4adbd 100644 --- a/harbour/source/rtl/setcolor.c +++ b/harbour/source/rtl/setcolor.c @@ -24,23 +24,40 @@ #include "pcode.h" #include +#include +#ifdef HARBOUR_USE_GTAPI + #include +#else + static char old_string[ sizeof( hb_set.HB_SET_COLOR ) ]; +#endif -int hb_gtSetColorStr(char * fpColorString); -int hb_gtGetColorStr(char * fpColorString); -void hb_gtexit(void); +/* From strings.c */ +char *hb_strUpper(char *szText, long lLen); -char *hb_SetColor( char *sColor ) +char *hb_setColor( char *sColor ) { - char *color; +#ifdef HARBOUR_USE_GTAPI + hb_gtGetColorStr( hb_set.HB_SET_COLOR ); +#else + strncpy (old_string, hb_set.HB_SET_COLOR, sizeof( hb_set.HB_SET_COLOR ) ); + old_string[ sizeof( hb_set.HB_SET_COLOR ) - 1 ] = 0; +#endif - color = (char *)hb_xgrab( 256 ); - hb_gtGetColorStr( color ); - - if( sColor ) - hb_gtSetColorStr( sColor ); - - /* The caller is responsible for releasing this */ - return (char *)hb_xrealloc( color, strlen( color )+1 ); + if( sColor ) + { + #ifdef HARBOUR_USE_GTAPI + hb_gtSetColorStr( sColor ); + #else + strncpy (hb_set.HB_SET_COLOR, sColor, sizeof( hb_set.HB_SET_COLOR ) ); + hb_set.HB_SET_COLOR[ sizeof( hb_set.HB_SET_COLOR ) - 1 ] = 0; + hb_strUpper( hb_set.HB_SET_COLOR, strlen( hb_set.HB_SET_COLOR ) ); + #endif + } +#ifdef HARBOUR_USE_GTAPI + return hb_set.HB_SET_COLOR; +#else + return old_string; +#endif } HARBOUR HB_SETCOLOR( void ); @@ -56,15 +73,14 @@ HB_INIT_SYMBOLS_END( SETCOLOR__InitSymbols ); HARBOUR HB_SETCOLOR( void ) { - char *color; - - hb_retc( color = hb_SetColor( hb_pcount() == 1 ? hb_parc(1) : NULL ) ); - hb_xfree( color ); + hb_retc( hb_setColor( hb_pcount() ? hb_parc(1) : NULL ) ); } /* TODO: This is a temporary fix - Call it on exit if you use SetColor() */ HARBOUR HB_GTEXIT( void ) { - hb_gtexit(); +#ifdef HARBOUR_USE_GTAPI + hb_gtExit(); +#endif } diff --git a/harbour/source/tools/dates2.c b/harbour/source/tools/dates2.c index cbdf105dc1..413b130f10 100644 --- a/harbour/source/tools/dates2.c +++ b/harbour/source/tools/dates2.c @@ -42,6 +42,7 @@ #include #include #include +#include HARBOUR HB_ADAYS(void); HARBOUR HB_AMONTHS(void); @@ -67,16 +68,11 @@ HB_INIT_SYMBOLS_BEGIN( Dates2__InitSymbols ) { "ISLEAPYEAR", FS_PUBLIC, HB_ISLEAPYEAR , 0 }, { "WOM", FS_PUBLIC, HB_WOM , 0 }, { "WOY", FS_PUBLIC, HB_WOY , 0 } -HB_INIT_SYMBOLS_END( Dates2__InitSymbols ) +HB_INIT_SYMBOLS_END( Dates2__InitSymbols ); #if ! defined(__GNUC__) #pragma startup Dates2__InitSymbols #endif - -/* In dates.c module */ -void hb_dateDecode( long julian, long * plDay, long * plMonth, long * plYear ); -long hb_dow( long d, long m, long y ); - /* In msgxxx.c modules */ extern char *hb_monthsname[]; extern char *hb_daysname[]; diff --git a/harbour/tests/working/Makefile b/harbour/tests/working/Makefile index ffd47dcefb..dc5339b32a 100644 --- a/harbour/tests/working/Makefile +++ b/harbour/tests/working/Makefile @@ -89,7 +89,6 @@ PRG_SOURCES=\ strings.prg \ strings2.prg \ strings3.prg \ - strings4.prg \ strip.prg \ syserror.prg \ t1.prg \ @@ -108,6 +107,7 @@ PRG_SOURCES=\ testtok.prg \ testvars.prg \ testwarn.prg \ + tstcolor.prg \ transfrm.prg \ val.prg \ version.prg \ diff --git a/harbour/tests/working/empty.prg b/harbour/tests/working/empty.prg index eeb7b1debf..0a961123c1 100644 --- a/harbour/tests/working/empty.prg +++ b/harbour/tests/working/empty.prg @@ -52,7 +52,6 @@ function Main() QOut( "L .T. ", empty( .T. ) ) QOut( "L .F. ", empty( .F. ) ) QOut( "U NIL ", empty( NIL ) ) - QOut( "U ", empty( ) ) QOut( "A {1} ", empty( {1} ) ) QOut( "A {} ", empty( {} ) ) QOut( "A {0} ", empty( {0} ) ) diff --git a/harbour/tests/working/harbour.ini b/harbour/tests/working/harbour.ini index de04bcaf9a..23123e54cd 100644 --- a/harbour/tests/working/harbour.ini +++ b/harbour/tests/working/harbour.ini @@ -8,7 +8,7 @@ so there!!!= another=section [Date Test] -Today=19990617 +Today=19990718 [Bool Test] True=.t. diff --git a/harbour/tests/working/strings4.prg b/harbour/tests/working/strings4.prg deleted file mode 100644 index 6bec832972..0000000000 --- a/harbour/tests/working/strings4.prg +++ /dev/null @@ -1,11 +0,0 @@ -// -// $Id$ -// - -function Main() - - QOut( "Inside strings4" ) - - At() // generating an error - -return nil