diff --git a/harbour/ChangeLog b/harbour/ChangeLog index f0b575b5f1..4fbf855f2f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,34 @@ +19990921-20:30 GMT+1 Victor Szel + + * source/hbpp/hbpp.c + ! One warning about unused variable fixed in strincmp() + * source/rtl/console.c + + HB_OSNEWLINE() function added. + * source/rtl/inkey.c + ! // style comment changed to ANSI /**/ + + Added #include "inkey.ch" + * Some keyboard code constants changed to manifest constant. + * source/runner/runlib.c + ! Two casts added for MSVC 4 + * adirtest.prg + cdow.prg + dates.prg + dates2.prg + dates3.prg + dates4.prg + dirtest.prg + longstr2.prg + output.prg + readfile.prg + round.prg + rtl_test.prg + seconds.prg + set_num.prg + set_test.prg + testcgi.prg + testhtml.prg + * OS_NewLine() -> HB_OSNewLine() + 19990921-14:25 EDT David G. Holm * source/rtl/set.c @@ -55,20 +86,20 @@ source/vm/hvm.c ! printf() calls changed to hb_outerr() calls, since Clipper is sending - these to STDERR, too. The other issues fixed are file buffering and + these to STDERR, too. The other issues fixed are file buffering and console inconsistency. - In general one should not use printf(), fprintf(), or any f*() file - functions to handle STDOUT/STDERR(), since this can cause anomalies due - to both direct and buffered access to the same device, and also the - internal cursor positions cannot be tracked that way. When using + In general one should not use printf(), fprintf(), or any f*() file + functions to handle STDOUT/STDERR(), since this can cause anomalies due + to both direct and buffered access to the same device, and also the + internal cursor positions cannot be tracked that way. When using f*() functions from console.c an fflush() call must be issued after them. * source/rtl/console.c include/extend.h + hb_outerr(), hb_outstd() are now public functions. - + hb_outerr(), hb_outstd() now automatically determines the length + + hb_outerr(), hb_outstd() now automatically determines the length if the length parameter is zero. + hb_outerr(), hb_outstd() now don't call GT after hb_consoleRelease() has been called. This is needed since these functions are used in such @@ -125,14 +156,14 @@ * tests/working/rtl_test.prg + Added Empty(ErrorNew()) test. * source/rtl/fm.c - * Changed the ending message, since this is not the maximum memory + * Changed the ending message, since this is not the maximum memory consumed, but the total. Made it more compact, and meaningful. 19990919-15:45 GMT+2 Ryszard Glab *source/vm/hvm.c - * added checking if starting symbol name points to a function - + * added checking if starting symbol name points to a function + 19990919-14:25 GMT+2 Ryszard Glab *source/rtl/console.c @@ -973,7 +1004,7 @@ * source/rtl/adir.prg ! Default flags reset to "HSD" * tests/working/adirtest.prg - ! Fixed a bug which caused an error when zero files was found. + ! Fixed a bug which caused an error when zero file was found. + Added: SET DATE ANSI, SET CENTURY ON ! Newline handling made platform compatible. ! Some other fixes. diff --git a/harbour/source/hbpp/hbpp.c b/harbour/source/hbpp/hbpp.c index c1ac405b7b..514f03d508 100644 --- a/harbour/source/hbpp/hbpp.c +++ b/harbour/source/hbpp/hbpp.c @@ -856,7 +856,7 @@ int CommandStuff ( char *ptrmp, char *inputLine, char * ptro, int *lenres, int c } else ptrmp = lastopti[Repeate]; - } + } else ptrmp++; numBrackets--; } @@ -1803,7 +1803,7 @@ int truncmp (char* ptro, char** ptri, int lTrunc ) int strincmp (char* ptro, char** ptri ) { - char *ptrb = ptro, co, ci; + char co, ci; for ( ; **ptri != ',' && **ptri != '[' && **ptri != ']' && **ptri != '\1' && **ptri != '\0' && toupper(**ptri)==toupper(*ptro); diff --git a/harbour/source/rtl/console.c b/harbour/source/rtl/console.c index c20505cbde..d03bab6c2c 100644 --- a/harbour/source/rtl/console.c +++ b/harbour/source/rtl/console.c @@ -48,6 +48,7 @@ * HB_SETPOS(), HB_SETPRC(), HB_SCROLL(), and hb_consoleInitialize() * * Copyright 1999 Victor Szel + * hb_consoleGetNewLine() * HB_SETPOSBS() * HB_DISPBOX() (GT version) * HB_DISPBEGIN() @@ -171,6 +172,50 @@ char * hb_consoleGetNewLine( void ) return s_szCrLf; } +/* $DOC$ + * $FUNCNAME$ + * HB_OSNewLine + * $CATEGORY$ + * Operating System Specific + * $ONELINER$ + * Returns the newline character(s) to use with the current OS + * $SYNTAX$ + * HB_OSNewLine() --> cString + * $ARGUMENTS$ + * $RETURNS$ + * A character string containing the character or characters required + * to move the screen cursor or print head to the start of a new line. + * The string will hold either CHR( 10 ) or CHR( 13 ) + CHR( 10 ). + * $DESCRIPTION$ + * Returns a character string containing the character or characters + * required to move the screen cursor or print head to the start of a + * new line for the operating system that the program is running on + * (or thinks it is running on, if an OS emulator is being used). + * $EXAMPLES$ + * // Get the newline character(s) for the current OS using defaults. + * STATIC s_cNewLine + * ... + * s_cNewLine := HB_OSNewLine() + * ... + * OutStd( "Hello World!" + s_cNewLine ) + * ... + * $TESTS$ + * valtype( HB_OSNewLine() ) == "C" + * LEN( HB_OSNewLine( { "ANOTHERDOS" }, { "" } ) ) == 1 + * $STATUS$ + * C + * $COMPLIANCE$ + * This is an add-on Operating System Tool function. + * $SEEALSO$ + * OS(), OUTSTD(), OUTERR() + * $END$ + */ + +HARBOUR HB_HB_OSNEWLINE( void ) +{ + hb_retc( s_szCrLf ); +} + USHORT hb_max_row( void ) { #ifdef HARBOUR_USE_GTAPI diff --git a/harbour/source/rtl/inkey.c b/harbour/source/rtl/inkey.c index 0e27cc0bb2..4643cc7307 100644 --- a/harbour/source/rtl/inkey.c +++ b/harbour/source/rtl/inkey.c @@ -1,4 +1,4 @@ -/* +/* * $Id$ */ @@ -83,6 +83,7 @@ #include "errorapi.h" #include "itemapi.h" #include "inkey.h" +#include "inkey.ch" #include "init.h" #if defined(__TURBOC__) || defined(__BORLANDC__) || defined(_MSC_VER) || defined(__MINGW32__) @@ -206,7 +207,7 @@ int hb_inkey( double seconds, HB_inkey_enum event_mask, BOOL wait, BOOL forever /* Check or wait for input events */ if( wait ) end_clock = clock() + seconds * CLOCKS_PER_SEC; s_inkeyPoll = TRUE; /* Force polling */ - + while( wait && hb_inkeyNext() == 0 ) { /* Release the CPU between checks */ @@ -283,7 +284,7 @@ void hb_inkeyPoll( void ) /* Poll the console keyboard to stuff the Harbour ch = _read_kbd( 0, 0, 0 ); if( ch != -1 ) ch += 256; /* If it's really a scan code, offset it */ } - /* _read_kbd() returns -1 for no key, the switch statement will handle + /* _read_kbd() returns -1 for no key, the switch statement will handle this. */ #else if( kbhit() ) @@ -323,55 +324,55 @@ void hb_inkeyPoll( void ) /* Poll the console keyboard to stuff the Harbour case -1: /* No key available */ return; case 328: /* Up arrow */ - ch = 5; + ch = K_UP; break; case 336: /* Down arrow */ - ch = 24; + ch = K_DOWN; break; case 331: /* Left arrow */ - ch = 19; + ch = K_LEFT; break; case 333: /* Right arrow */ - ch = 4; + ch = K_RIGHT; break; case 327: /* Home */ - ch = 1; + ch = K_HOME; break; case 335: /* End */ - ch = 6; + ch = K_END; break; case 329: /* Page Up */ - ch = 18; + ch = K_PGUP; break; case 337: /* Page Down */ - ch = 3; + ch = K_PGDN; break; case 371: /* Ctrl + Left arrow */ - ch = 26; + ch = K_CTRL_LEFT; break; case 372: /* Ctrl + Right arrow */ - ch = 2; + ch = K_CTRL_RIGHT; break; case 375: /* Ctrl + Home */ - ch = 29; + ch = K_CTRL_HOME; break; case 373: /* Ctrl + End */ - ch = 23; + ch = K_CTRL_END; break; case 388: /* Ctrl + Page Up */ - ch = 31; + ch = K_CTRL_PGUP; break; case 374: /* Ctrl + Page Down */ - ch = 30; + ch = K_CTRL_PGDN; break; case 338: /* Insert */ - ch = 22; + ch = K_INS; break; case 339: /* Delete */ - ch = 7; + ch = K_DEL; break; case 315: /* F1 */ - ch = 28; + ch = K_F1; break; case 316: /* F2 */ case 317: /* F3 */ @@ -440,12 +441,13 @@ void hb_inkeyPoll( void ) /* Poll the console keyboard to stuff the Harbour /* Only read keyboard input here if not called from the HVM and the typeahead buffer is empty. */ read( STDIN_FILENO, &ch, 1 ); /* Read a key */ -/// if( ch == '\n' ) ch = '\r'; /* Convert LF to CR */ +/* if( ch == '\n' ) + ch = '\r'; */ /* Convert LF to CR */ } #else /* TODO: Support for other platforms, such as Mac */ #endif - if( ch == 302 ) /* K_ALT_C */ + if( ch == K_ALT_C ) hb_vmRequestCancel( ); /* Alt-C was pressed */ hb_inkeyPut( ch ); diff --git a/harbour/source/runner/runlib.c b/harbour/source/runner/runlib.c index ae03cef6b8..4c715cf0c1 100644 --- a/harbour/source/runner/runlib.c +++ b/harbour/source/runner/runlib.c @@ -187,7 +187,7 @@ HARBOUR HB___HRBRUN( void ) ulSize = hb_hrbFileReadLong( file, szFileName ); /* Read size of function */ pDynFunc[ ul ].pCode = ( BYTE * ) hb_xgrab( ulSize ); - hb_hrbFileRead( file, szFileName, pDynFunc[ ul ].pCode, 1, ulSize ); + hb_hrbFileRead( file, szFileName, ( char * ) pDynFunc[ ul ].pCode, 1, ulSize ); /* Read the block */ pDynFunc[ ul ].pAsmCall = hb_hrbAsmCreateFun( pSymRead, @@ -370,7 +370,7 @@ static BYTE hb_hrbFileReadByte( FILE * file, char * szFileName ) { BYTE bRet; - hb_hrbFileRead( file, szFileName, &bRet, 1, 1 ); + hb_hrbFileRead( file, szFileName, ( char * ) &bRet, 1, 1 ); return bRet; } diff --git a/harbour/tests/working/adirtest.prg b/harbour/tests/working/adirtest.prg index 0d92bac7cd..54543a7299 100644 --- a/harbour/tests/working/adirtest.prg +++ b/harbour/tests/working/adirtest.prg @@ -20,7 +20,7 @@ STATIC FUNCTION TestIt( cSpec ) LOCAL a4 LOCAL a5 - LOCAL cNewLine := OS_NewLine() + LOCAL cNewLine := HB_OSNewLine() SET DATE ANSI SET CENTURY ON diff --git a/harbour/tests/working/cdow.prg b/harbour/tests/working/cdow.prg index 911915dfc8..c82ffc1b47 100644 --- a/harbour/tests/working/cdow.prg +++ b/harbour/tests/working/cdow.prg @@ -3,7 +3,7 @@ // function main() -local cNewLine := OS_NewLine() +local cNewLine := HB_OSNewLine() OutStd( cMonth( date() ) + cNewLine ) OutStd( cMonth( date() + 31 ) + cNewLine ) diff --git a/harbour/tests/working/dates.prg b/harbour/tests/working/dates.prg index 4fcea616ce..e743e43299 100644 --- a/harbour/tests/working/dates.prg +++ b/harbour/tests/working/dates.prg @@ -7,13 +7,13 @@ #include "set.ch" function Main() -local cNewLine := OS_NewLine() +local cNewLine := HB_OSNewLine() local dDate, dDate2, cMask, cDate OUTSTD (cNewLine, "Testing Harbour dates management on", DATE()) - TestCentury(cNewLine) + TestCentury(cNewLine) OUTSTD (cNewLine, "") OUTSTD (cNewLine, "dDate = CToD( '02/04/1999' ) =>", dDate := CToD( "02/04/1999" )) diff --git a/harbour/tests/working/dates2.prg b/harbour/tests/working/dates2.prg index 7cc21fa280..fa32dafc24 100644 --- a/harbour/tests/working/dates2.prg +++ b/harbour/tests/working/dates2.prg @@ -4,7 +4,7 @@ #include "set.ch" function main() - local newline := OS_NewLine() + local newline := HB_OSNewLine() local dDate := CTOD ("04/30/99") outstd (SET (_SET_DATEFORMAT), dDate, newline) diff --git a/harbour/tests/working/dates3.prg b/harbour/tests/working/dates3.prg index 62ee563336..6d75ce3fec 100644 --- a/harbour/tests/working/dates3.prg +++ b/harbour/tests/working/dates3.prg @@ -8,7 +8,7 @@ function main() - LOCAL dDate, i, cNewLine := OS_NewLine() + LOCAL dDate, i, cNewLine := HB_OSNewLine() set( _SET_DATEFORMAT, "dd/mm/yyyy" ) dDate := cToD( "25/05/1999" ) @@ -35,7 +35,7 @@ function main() dDate += 4 OutStd( dDate, dow( dDate ), cNewLine ) - + OutStd( cNewLine ) dDate := DATE () FOR i := 1 TO 7 diff --git a/harbour/tests/working/dates4.prg b/harbour/tests/working/dates4.prg index 9e0f5ef4a3..c29502627c 100644 --- a/harbour/tests/working/dates4.prg +++ b/harbour/tests/working/dates4.prg @@ -11,7 +11,7 @@ function main() LOCAL i LOCAL dDate := date() - s_cNewLine := OS_NewLine() + s_cNewLine := HB_OSNewLine() set( _SET_DATEFORMAT, "dd/mm/yyyy" ) diff --git a/harbour/tests/working/dirtest.prg b/harbour/tests/working/dirtest.prg index 7796633d89..60286c1f5b 100644 --- a/harbour/tests/working/dirtest.prg +++ b/harbour/tests/working/dirtest.prg @@ -6,7 +6,7 @@ function main(filespec,attribs,cshort) local adir := {} -local x := 0, lShort := .f., cNewLine := OS_NewLine() +local x := 0, lShort := .f., cNewLine := HB_OSNewLine() IF !cshort == NIL .and. (Upper( cShort ) == "TRUE" .or. Upper( cShort ) == ".T.") lShort := .t. diff --git a/harbour/tests/working/longstr2.prg b/harbour/tests/working/longstr2.prg index 35075ebe2e..c997cf34df 100644 --- a/harbour/tests/working/longstr2.prg +++ b/harbour/tests/working/longstr2.prg @@ -9,7 +9,7 @@ function Main() local short := "1234567890" local i, long, very_long, cNewLine - cNewLine := OS_NewLine() + cNewLine := HB_OSNewLine() long := short for i := 1 TO 12 diff --git a/harbour/tests/working/output.prg b/harbour/tests/working/output.prg index abea0d91d1..93d48a89db 100644 --- a/harbour/tests/working/output.prg +++ b/harbour/tests/working/output.prg @@ -12,7 +12,7 @@ #include "set.ch" function Main() -local cNewLine := OS_NewLine() +local cNewLine := HB_OSNewLine() OUTSTD (cNewLine, "Testing Harbour device management on", DATE()) SET ALTERNATE TO OUTPUT_A ADDITIVE diff --git a/harbour/tests/working/readfile.prg b/harbour/tests/working/readfile.prg index 1110f643cf..d55b1855d3 100644 --- a/harbour/tests/working/readfile.prg +++ b/harbour/tests/working/readfile.prg @@ -13,7 +13,7 @@ PROCEDURE Main( cFile ) LOCAL oFile := TFileRead():New( cFile ) -LOCAL cNewLine := OS_NewLine() +LOCAL cNewLine := HB_OSNewLine() oFile:Open() IF oFile:Error() diff --git a/harbour/tests/working/round.prg b/harbour/tests/working/round.prg index 3f81693ed0..648d032701 100644 --- a/harbour/tests/working/round.prg +++ b/harbour/tests/working/round.prg @@ -11,7 +11,7 @@ function main() local n, value := -5 -local cNewLine := OS_NewLine() +local cNewLine := HB_OSNewLine() for n := 1 to 100 OUTSTD(cNewLine) diff --git a/harbour/tests/working/rtl_test.prg b/harbour/tests/working/rtl_test.prg index 14485ce36f..a4acb81fbd 100644 --- a/harbour/tests/working/rtl_test.prg +++ b/harbour/tests/working/rtl_test.prg @@ -375,8 +375,8 @@ STATIC FUNCTION Main_HVM() //NOTE: These expressions have to be written with no separators! TEST_LINE( mnIntP==10.or.mnIntP=0 , .T. ) - TEST_LINE( mnIntP==10.and.mnLongP=0 , .F. ) - + TEST_LINE( mnIntP==10.and.mnLongP=0 , .F. ) + TEST_LINE( NIL + 1 , "E BASE 1081 Argument error + F:S" ) TEST_LINE( NIL - 1 , "E BASE 1082 Argument error - F:S" ) @@ -2068,7 +2068,7 @@ STATIC FUNCTION TEST_BEGIN( cParam ) s_nStartTime := Seconds() #ifdef __HARBOUR__ - s_cNewLine := OS_NewLine() + s_cNewLine := HB_OSNewLine() #else s_cNewLine := Chr( 13 ) + Chr( 10 ) #endif diff --git a/harbour/tests/working/seconds.prg b/harbour/tests/working/seconds.prg index 863aba9ec1..bbbf7bdfc5 100644 --- a/harbour/tests/working/seconds.prg +++ b/harbour/tests/working/seconds.prg @@ -11,7 +11,7 @@ function Main( cParam ) local n, limit := 10 -local cNewLine := OS_NewLine() +local cNewLine := HB_OSNewLine() IF( ! EMPTY( cParam ) ) limit := VAL( cParam ) diff --git a/harbour/tests/working/set_num.prg b/harbour/tests/working/set_num.prg index 269794923b..334d4d080c 100644 --- a/harbour/tests/working/set_num.prg +++ b/harbour/tests/working/set_num.prg @@ -5,7 +5,7 @@ // Testing SET function Main() -local n, cNewLine := OS_NewLine() +local n, cNewLine := HB_OSNewLine() for n := 1 to 39 outstd (cNewLine) diff --git a/harbour/tests/working/set_test.prg b/harbour/tests/working/set_test.prg index 0129582c10..4baf690b55 100644 --- a/harbour/tests/working/set_test.prg +++ b/harbour/tests/working/set_test.prg @@ -12,7 +12,7 @@ function Main() // for Clipper, this drags in the terminal driver @ Row(), col() say "" - s_cNewLine := OS_NewLine() + s_cNewLine := HB_OSNewLine() TestLine( "_SET_EXACT", 1) TestLine( "_SET_FIXED", 2) diff --git a/harbour/tests/working/testcgi.prg b/harbour/tests/working/testcgi.prg index 8953c0c4fc..5bb9e41bc0 100644 --- a/harbour/tests/working/testcgi.prg +++ b/harbour/tests/working/testcgi.prg @@ -35,7 +35,7 @@ FUNCTION Main() LOCAL oHTML := THTML():New() LOCAL hFile, nPos, cString, cBuf, i, cTable, cLine - s_cNewLine := OS_NewLine() + s_cNewLine := HB_OSNewLine() oHTML:SetHTMLFile( "function.cfm" ) diff --git a/harbour/tests/working/testhtml.prg b/harbour/tests/working/testhtml.prg index 7f0cf66717..8aafc60d2b 100644 --- a/harbour/tests/working/testhtml.prg +++ b/harbour/tests/working/testhtml.prg @@ -21,7 +21,7 @@ FUNCTION Main() LOCAL oHTML := THTML():New() - s_cNewLine := OS_NewLine() + s_cNewLine := HB_OSNewLine() oHTML:SetTitle( "Harbour Power Demonstration" ) oHTML:AddHead( "Harbour Project" )