diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 52d1096578..8683aa6c9a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,34 @@ +19990604-20:20 EDT David G. Holm + Thanks go to Jose Lalin for CDOW() and CMONTH() (and + their support functions), msggal.c, msgspa.c, and msguk.c and cdow.prg, + to Felipe G. Coury for msgpor.c, and to Eddie + Runia for msgdut.c + * makefile.dos + - Added source/rtl/natmsg + * source/rtl/console.c + - Separated screen and printer coordinates + - Moved HARBOUR ROW() and HARBOUR COL() from gtapi.c + - Added rudimentary screen positioning when not using the GT API + * source/rtl/dates.c + - Added HARBOUR CDOW(), HARBOUR CMONTH(), and support functions + * source/rtl/gtapi.c + - Moved HARBOUR ROW() and HARBOUR COL() to console.c + + source/rtl/natmsg/makefile.dos + - New DJGPP makefile for national language message files + Note: Only msguk goes into the library + + source/rtl/natmsg/msgdut.c + - National language message file for Dutch + + source/rtl/natmsg/msggal.c + - National language message file for ? + + source/rtl/natmsg/msgpor.c + - National language message file for Portugese + + source/rtl/natmsg/msgsp.c + - National language message file for Spanish + + source/rtl/natmsg/msguk.c + - National language message file for English + + tests/working/cdow.prg + - Test program for CDOW() and CMONTH() + 19990605-00:22 CET Eddie Runia * tests/broken/exittest.prg; tests/broken/codebloc.prg removed, since they work ! diff --git a/harbour/makefile.dos b/harbour/makefile.dos index 4e86a2797d..cfdc50ac2f 100644 --- a/harbour/makefile.dos +++ b/harbour/makefile.dos @@ -3,7 +3,7 @@ .phony: compiler vm rtl tests -all: compiler vm rtl tools +all: compiler nat vm rtl tools compiler: make -r -w --directory=source/compiler -f makefile.dos @@ -14,6 +14,9 @@ vm: rtl: make -w --directory=source/rtl -f makefile.dos +nat: + make -w --directory=source/rtl/natmsg -f makefile.dos + tools: make -w --directory=source/tools -f makefile.dos @@ -25,5 +28,6 @@ clean: make -r -w --directory=source/compiler -f makefile.dos clean make -w --directory=source/vm -f makefile.dos clean make -w --directory=source/rtl -f makefile.dos clean + make -w --directory=source/rtl/natmsg -f makefile.dos clean make -w --directory=source/tools -f makefile.dos clean # make -w --directory=tests -f makefile.dos clean diff --git a/harbour/source/rtl/console.c b/harbour/source/rtl/console.c index d411b37ad4..0b52e22db6 100644 --- a/harbour/source/rtl/console.c +++ b/harbour/source/rtl/console.c @@ -11,12 +11,14 @@ #include #include #include +#ifdef __DJGPP__ + #include +#endif #ifdef USE_GTAPI #include #endif -static unsigned short dev_row; -static unsigned short dev_col; +static unsigned short dev_row, dev_col, p_row, p_col; static char CrLf [3]; void InitializeConsole( void ) @@ -31,6 +33,25 @@ void InitializeConsole( void ) #else dev_row = 0; dev_col = 0; +#endif + p_row = p_col = 0; +} + +USHORT hb_maxrow( void ) +{ +#ifdef USE_GTAPI + return _gtMaxRow (); +#else + return 23; +#endif +} + +USHORT hb_maxcol( void ) +{ +#ifdef USE_GTAPI + return _gtMaxCol (); +#else + return 79; #endif } @@ -62,7 +83,6 @@ static void hb_out( WORD wParam, void_func_int * hb_out_func ) { char * szText; PHB_ITEM pItem = _param( wParam, IT_ANY ); - ULONG ulLenText; char szBuffer [11]; switch( _parinfo( wParam ) ) @@ -153,6 +173,12 @@ static void hb_altout( char * fpStr, WORD uiLen ) WORD uiCount; for( uiCount = 0; uiCount < uiLen; uiCount++ ) printf( "%c", fpStr[ uiCount ] ); + dev_col += uiLen; + if( dev_col > hb_maxcol() ) + { + dev_row += (uiLen / (hb_maxcol() + 1)); + dev_col -= (uiLen % (hb_maxcol() + 1)); + } #endif } if( hb_set.HB_SET_ALTERNATE && hb_set_althan >= 0 ) @@ -170,7 +196,7 @@ static void hb_devout( char * fpStr, WORD uiLen ) { /* Display to printer if SET DEVICE TO PRINTER and valid printer file */ write( hb_set_printhan, fpStr, uiLen ); - dev_col += uiLen; + p_col += uiLen; } else { @@ -182,32 +208,46 @@ static void hb_devout( char * fpStr, WORD uiLen ) WORD uiCount; for( uiCount = 0; uiCount < uiLen; uiCount++ ) printf( "%c", fpStr[ uiCount ] ); + dev_col += uiLen; + if( dev_col > hb_maxcol() ) + { + dev_row += (uiLen / (hb_maxcol() + 1)); + dev_col -= (uiLen % (hb_maxcol() + 1)); + } #endif } } -void hb_devpos( int row, int col ) +void hb_devpos( USHORT row, USHORT col ) { int count; /* Position printer if SET DEVICE TO PRINTER and valid printer file otherwise position console */ if( stricmp( hb_set.HB_SET_DEVICE, "PRINTER" ) == 0 && hb_set_printhan >= 0 ) { - if( row < dev_row ) + if( row < p_row ) { write( hb_set_printhan, "\x0C", 1 ); - dev_row = dev_col = 0; + p_row = p_col = 0; } - for( count = dev_row; count < row; count++ ) write( hb_set_printhan, CrLf, strlen (CrLf) ); + for( count = p_row; count < row; count++ ) write( hb_set_printhan, CrLf, strlen (CrLf) ); + if( row > p_row ) p_col = 0; + for( count = p_col; count < col; count++ ) write( hb_set_printhan, " ", 1 ); + p_row = row; + p_col = col; + } + else + { + #ifdef USE_GTAPI + _gtSetPos( row, col ); + #else + for( count = dev_row; count < row; count++ ) printf("\n"); if( row > dev_row ) dev_col = 0; - for( count = dev_col; count < col; count++ ) write( hb_set_printhan, " ", 1 ); + for( count = dev_col; count < col; count++ ) printf(" "); + #endif dev_row = row; dev_col = col; } - #ifdef USE_GTAPI - else - _gtSetPos( row, col ); - #endif } HARBOUR OUTSTD( void ) /* writes a list of values to the standard output device */ @@ -234,7 +274,6 @@ HARBOUR OUTERR( void ) /* writes a list of values to the standard error device * HARBOUR QQOUT( void ) /* writes a list of values to the current device (screen or printer) and is affected by SET ALTERNATE */ { - BOOL bScreen; WORD w; for( w = 0; w < _pcount(); w++ ) @@ -268,7 +307,6 @@ HARBOUR DEVPOS( void ) /* Sets the screen and/or printer position */ HARBOUR DEVOUT( void ) /* writes a single values to the current device (screen or printer), but is not affected by SET ALTERNATE */ { - BOOL bScreen; if( _pcount() > 0 ) { char fpOldColor[ 64 ]; @@ -296,18 +334,18 @@ HARBOUR EJECT( void ) /* Ejects the current page from the printer */ if( stricmp( hb_set.HB_SET_DEVICE, "PRINTER" ) == 0 && hb_set_printhan >= 0 ) { write( hb_set_printhan, "\x0C", 1 ); - dev_row = dev_col = 0; + p_row = p_col = 0; } } HARBOUR PROW( void ) /* Returns the current printer row position */ { - _retni( dev_row ); + _retni( p_row ); } HARBOUR PCOL( void ) /* Returns the current printer row position */ { - _retni( dev_col ); + _retni( p_col ); } HARBOUR SETPRC( void ) /* Sets the current printer row and column positions */ @@ -318,48 +356,61 @@ HARBOUR SETPRC( void ) /* Sets the current printer row and column positions */ PHB_ITEM pCol = _param( 1, IT_NUMERIC ); if( pRow && pCol ) { - dev_row = _parni( 1 ); - dev_col = _parni( 2 ); + p_row = _parni( 1 ); + p_col = _parni( 2 ); } } } HARBOUR SCROLL( void ) /* Scrolls a screen region (requires the GT API) */ { -#ifdef USE_GTAPI - int top = 0, left = 0, bottom = _gtMaxRow(), right = _gtMaxCol(), - v_scroll = 0, h_scroll = 0; + int top = 0, left = 0, bottom = hb_maxrow(), right = hb_maxcol(), + v_scroll = 0, h_scroll = 0; - if( _pcount() > 0 && _param( 1, IT_NUMERIC ) ) - top = _parni( 1 ); - if( _pcount() > 1 && _param( 2, IT_NUMERIC ) ) - left = _parni( 2 ); - if( _pcount() > 2 && _param( 3, IT_NUMERIC ) ) - bottom = _parni( 3 ); - if( _pcount() > 3 && _param( 4, IT_NUMERIC ) ) - right = _parni( 4 ); - if( _pcount() > 4 && _param( 5, IT_NUMERIC ) ) - v_scroll = _parni( 5 ); - if( _pcount() > 5 && _param( 6, IT_NUMERIC ) ) - h_scroll = _parni( 6 ); - _gtScroll( top, left, bottom, right, v_scroll, h_scroll ); + if( _pcount() > 0 && _param( 1, IT_NUMERIC ) ) + top = _parni( 1 ); + if( _pcount() > 1 && _param( 2, IT_NUMERIC ) ) + left = _parni( 2 ); + if( _pcount() > 2 && _param( 3, IT_NUMERIC ) ) + bottom = _parni( 3 ); + if( _pcount() > 3 && _param( 4, IT_NUMERIC ) ) + right = _parni( 4 ); + if( _pcount() > 4 && _param( 5, IT_NUMERIC ) ) + v_scroll = _parni( 5 ); + if( _pcount() > 5 && _param( 6, IT_NUMERIC ) ) + h_scroll = _parni( 6 ); + +#ifdef USE_GTAPI + _gtScroll( top, left, bottom, right, v_scroll, h_scroll ); +#else + if( top == 0 && bottom == hb_maxrow() + && left == 0 && right == hb_maxcol() + && v_scroll == 0 && h_scroll == 0 ) + { + int count; + dev_row = hb_maxrow(); + for( count = 0; count < dev_row ; count++ ) printf( "\n" ); + dev_row = dev_col = 0; + } #endif } HARBOUR MAXROW( void ) /* Return the maximum screen row number (zero origin) */ { -#ifdef USE_GTAPI - _retni( _gtMaxRow () ); -#else - _retni( 23 ); -#endif + _retni( hb_maxrow () ); } HARBOUR MAXCOL( void ) /* Return the maximum screen column number (zero origin) */ { -#ifdef USE_GTAPI - _retni( _gtMaxCol () ); -#else - _retni( 79 ); -#endif + _retni( hb_maxcol () ); +} + +HARBOUR ROW( void ) /* Return the current screen row position (zero origin) */ +{ + _retni( dev_row ); +} + +HARBOUR COL( void ) /* Return the current screen column position (zero origin) */ +{ + _retni( dev_col ); } diff --git a/harbour/source/rtl/dates.c b/harbour/source/rtl/dates.c index 1db5285a2c..6f51c687ce 100644 --- a/harbour/source/rtl/dates.c +++ b/harbour/source/rtl/dates.c @@ -18,6 +18,26 @@ ADJ is 7 for ISO, 6 for no ISO extern STACK stack; +/* In msgxxx.c modules */ +extern char *hb_monthsname[]; +extern char *hb_daysname[]; + +char *hb_cmonth( month ) +{ + if( month >= 1 && month <= 12 ) + return hb_monthsname[ month - 1 ]; + + return ""; +} + +char *hb_cdow( day ) +{ + if( day >= 1 && day <= 7 ) + return hb_daysname[ day - 1 ]; + + return ""; +} + long hb_dateEncode( long lDay, long lMonth, long lYear ) { BOOL bValid = FALSE; @@ -486,3 +506,63 @@ HARBOUR DOW( void ) _errRelease(pError); } } + +HARBOUR CMONTH( void ) +{ + PHB_ITEM pDate = _param( 1, IT_DATE ); + long lDay, lMonth, lYear; + + if( _pcount() ) + { + if( pDate ) + { + hb_dateDecode( pDate->value.lDate, &lDay, &lMonth, &lYear ); + _retc( hb_cmonth( lMonth ) ); + } + else + { + PHB_ITEM pError = _errNew(); + _errPutDescription(pError, "Error BASE/1116 Argument error: CMONTH"); + _errLaunch(pError); + _errRelease(pError); + } + } + else + { + /* QUESTION: Clipper catches this at compile time! */ + PHB_ITEM pError = _errNew(); + _errPutDescription(pError, "Incorrect number of arguments: CMONTH"); + _errLaunch(pError); + _errRelease(pError); + } +} + +HARBOUR CDOW( void ) +{ + PHB_ITEM pDate = _param( 1, IT_DATE ); + long lDay, lMonth, lYear; + + if( _pcount() ) + { + if( pDate ) + { + hb_dateDecode( pDate->value.lDate, &lDay, &lMonth, &lYear ); + _retc( hb_cdow( hb_dow( lDay, lMonth, lYear ) ) ); + } + else + { + PHB_ITEM pError = _errNew(); + _errPutDescription(pError, "Error BASE/1117 Argument error: CDOW"); + _errLaunch(pError); + _errRelease(pError); + } + } + else + { + /* QUESTION: Clipper catches this at compile time! */ + PHB_ITEM pError = _errNew(); + _errPutDescription(pError, "Incorrect number of arguments: CDOW"); + _errLaunch(pError); + _errRelease(pError); + } +} diff --git a/harbour/source/rtl/gtapi.c b/harbour/source/rtl/gtapi.c index 0cccb6de8d..2373e2b730 100644 --- a/harbour/source/rtl/gtapi.c +++ b/harbour/source/rtl/gtapi.c @@ -23,18 +23,6 @@ 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"}; -/* Harbour functions */ - -HARBOUR ROW() -{ - _retni(s_uiCurrentRow); -} - -HARBOUR COL() -{ - _retni(s_uiCurrentCol); -} - /* gt API functions */ void _gtInit(void) diff --git a/harbour/source/rtl/natmsg/makefile.dos b/harbour/source/rtl/natmsg/makefile.dos new file mode 100644 index 0000000000..3b43e8e40c --- /dev/null +++ b/harbour/source/rtl/natmsg/makefile.dos @@ -0,0 +1,19 @@ +# $Id$ +# Make file for DOS DJGPP +# +include ../../../makedos.env + +SRCPRG:= $(wildcard *.prg) +CPRG=$(SRCPRG:.prg=.c) +OBJPRG=$(CPRG:.c=.o) + +SRCC:= $(wildcard *.c) +OBJC=$(SRCC:.c=.o) + +all: $(HARBOURLIB) + +$(HARBOURLIB): ${OBJPRG} $(OBJC) + ar r $(HARBOURLIB) msguk.o + +clean: + -del *.o diff --git a/harbour/source/rtl/natmsg/msgdut.c b/harbour/source/rtl/natmsg/msgdut.c new file mode 100644 index 0000000000..867fe2139c --- /dev/null +++ b/harbour/source/rtl/natmsg/msgdut.c @@ -0,0 +1,12 @@ +#include +#include + +char *hb_monthsname[ 12 ] = { + "januari", "februari", "maart", + "april", "mei", "juni", "juli", + "augustus", "september", "oktober", + "november", "december" }; + +char *hb_daysname[ 7 ] = { + "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag", + "zondag" }; diff --git a/harbour/source/rtl/natmsg/msggal.c b/harbour/source/rtl/natmsg/msggal.c new file mode 100644 index 0000000000..1de0a1277b --- /dev/null +++ b/harbour/source/rtl/natmsg/msggal.c @@ -0,0 +1,13 @@ +#include +#include + +char *hb_monthsname[ 12 ] = { + "Xaneiro", "Febreiro", "Marzal", + "Abril", "Maio", "Xunio", "Xullo", + "Agosto", "Setembro", "Outubro", + "Novembro", "Decembro" }; + +char *hb_daysname[ 7 ] = { + "Domingo", "Luns", "Martes", + "M‚rcores", "Xoves", "Venres", + "S bado" }; diff --git a/harbour/source/rtl/natmsg/msgpor.c b/harbour/source/rtl/natmsg/msgpor.c new file mode 100644 index 0000000000..b8d0e1af8f --- /dev/null +++ b/harbour/source/rtl/natmsg/msgpor.c @@ -0,0 +1,14 @@ +#include +#include + +char *hb_monthsname[ 12 ] = { + "Janeiro", "Fevereiro", "Março", + "Abril", "Maio", "Junho", "Julho", + "Agosto", "Setembro", "Outubro", + "Novembro", "Dezembro" }; + +char *hb_daysname[ 7 ] = { + "Domingo", "Segunda-feira", "Terça-feira", + "Quarta-feira", "Quinta-feira", "Sexta-feira", + "Sábado" }; + diff --git a/harbour/source/rtl/natmsg/msgspa.c b/harbour/source/rtl/natmsg/msgspa.c new file mode 100644 index 0000000000..6d28d10371 --- /dev/null +++ b/harbour/source/rtl/natmsg/msgspa.c @@ -0,0 +1,14 @@ +#include +#include + +char *hb_monthsname[ 12 ] = { + "Enero", "Febrero", "Marzo", + "Abril", "Mayo", "Junio", "Julio", + "Agosto", "Septiembre", "Octubre", + "Noviembre", "Diciembre" }; + +char *hb_daysname[ 7 ] = { + "Domingo", "Lunes", "Martes", + "Mi‚rcoles", "Jueves", "Vi‚rnes", + "S bado" }; + diff --git a/harbour/source/rtl/natmsg/msguk.c b/harbour/source/rtl/natmsg/msguk.c new file mode 100644 index 0000000000..8fad50f6a1 --- /dev/null +++ b/harbour/source/rtl/natmsg/msguk.c @@ -0,0 +1,13 @@ +#include +#include + +char *hb_monthsname[ 12 ] = { + "January", "February", "March", + "April", "May", "June", "July", + "August", "September", "October", + "November", "December" }; + +char *hb_daysname[ 7 ] = { + "Sunday", "Monday", "Tuesday", + "Wednesday", "Thursday", "Friday", + "Saturday" }; diff --git a/harbour/tests/working/cdow.prg b/harbour/tests/working/cdow.prg new file mode 100644 index 0000000000..bc6085e704 --- /dev/null +++ b/harbour/tests/working/cdow.prg @@ -0,0 +1,11 @@ +function main() + + OutStd( cMonth( date() ) + chr(10) ) + OutStd( cMonth( date() + 31 ) + chr(10) ) + OutStd( cMonth( date() + 60 ) + chr(10) ) + + OutStd( cDow( date() ) + chr(10) ) + OutStd( cDow( date() + 6 ) + chr(10) ) + OutStd( cDow( date() + 7 ) + chr(10) ) + +return nil