From 182f0910afc1afcb506f1993878a4e61b864246d Mon Sep 17 00:00:00 2001 From: "David G. Holm" Date: Thu, 16 Sep 1999 23:52:05 +0000 Subject: [PATCH] See ChangeLog entry 19990916-19:35 EDT David G. Holm --- harbour/ChangeLog | 43 +++++++++++++++++++ harbour/doc/gmake.txt | 13 ++++-- harbour/source/rtl/console.c | 2 +- harbour/source/rtl/dir.c | 12 +++--- harbour/source/rtl/environ.c | 69 +++++++++++++++++++++++++++--- harbour/source/rtl/filesys.c | 1 + harbour/source/rtl/inkey.c | 47 ++++++++++++-------- harbour/tests/working/inkeytst.prg | 8 ++-- harbour/tests/working/version.prg | 3 +- 9 files changed, 159 insertions(+), 39 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index e1796ef2a6..0ce34514ed 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,46 @@ +19990916-19:35 EDT David G. Holm + + * doc/gmake.txt + + Added gcc/mingw32. + + Updated the BUILD.BAT paragraph. + + * source/rtl/console.c + ! Added missing type override to hb_xgrab() call in SAVESCREEN(). + + * source/rtl/dir.c + ! Changed FA_READONLY to FA_RDONLY + ! Changed FILE_RDONLY to FILE_READONLY + + * source/rtl/environ.c + ! Added conditional definition of a Windows define + that is missing from some versions of Borland C. + Thanks to Jose Lalin. + + Added compiler identification to VERSION(), but + only if called with a parameter (any parameter) + based on an idea by Victor Szel. + + * source/rtl/filesys.c + ! Added '#include ' for Borland C in order + to eliminate a warning regarding '_getdrive()'. + + * source/rtl/inkey.c + ! Restored Unix-style keyboard input, because it is + non-blocking under Linux/GCC. + + Added separate __CYGWIN__ Unix-style keyboard input, + because it is blocking under Win32/GCC. + + Actually added the Borland C Windows #elif code block + supplied by Jose Lalin this time. + + * tests/working/inkeytst.prg + * Modified warning text to refer only to Cygwin. + + * tests/working/version.prg + * Changed 'QOUT( VERSION() )' to '? VERSION()'. + + Added '? VERSION( .T. )' to display the compiler that + was used to build Harbour.exe (which does not have to + be the same compiler used to build the Harbour program). + + 19990917-00:50 GMT+1 Victor Szel * source/rtl/hardcr.c diff --git a/harbour/doc/gmake.txt b/harbour/doc/gmake.txt index c6016c1275..3a114593a7 100644 --- a/harbour/doc/gmake.txt +++ b/harbour/doc/gmake.txt @@ -134,10 +134,14 @@ system. To check this, type "make -v"; you should see Then, you must set a couple of environment variables that indicate your architecture and compiler. -For gcc on Win95/WinNT: +For gcc on Win95/WinNT with the Cygwin library: HB_ARCHITECTURE win32 HB_COMPILER gcc +For gcc on Win95/WinNT with the Mingw32 library: + HB_ARCHITECTURE win32 + HB_COMPILER mingw32 + For MSVC on Win95/WinNT: HB_ARCHITECTURE win32 HB_COMPILER msvc @@ -218,5 +222,8 @@ test programs, change to the 'test' directory. If you are using a DOS-based operating system, then you can build any program in tests/working by using the build batch file. For example, -'build scroll' will rebuild the scroll.prg module. This can also be used -for modules that aren't in the Makefile. +'build scroll' will rebuild the scroll.prg program and then run it. This +can also be used for modules that aren't in the Makefile. You can also +pass parameters to the program. For example, 'build readfile harbour.ini' +will rebuild the readfile.prg program and run it with 'harbour.ini' as a +command line parameter. \ No newline at end of file diff --git a/harbour/source/rtl/console.c b/harbour/source/rtl/console.c index e78ee47cf7..28009d611b 100644 --- a/harbour/source/rtl/console.c +++ b/harbour/source/rtl/console.c @@ -1044,7 +1044,7 @@ HARBOUR HB_SAVESCREEN( void ) uiCoords[ uiX - 1 ] = hb_parni( uiX ); hb_gtRectSize( uiCoords[ 0 ], uiCoords[ 1 ], uiCoords[ 2 ], uiCoords[ 3 ], &uiX ); - pBuffer = hb_xgrab( uiX ); + pBuffer = (char *) hb_xgrab( uiX ); hb_gtSave( uiCoords[ 0 ], uiCoords[ 1 ], uiCoords[ 2 ], uiCoords[ 3 ], pBuffer ); hb_retclen( pBuffer, uiX ); hb_xfree( pBuffer ); diff --git a/harbour/source/rtl/dir.c b/harbour/source/rtl/dir.c index 1a0d81f000..776be92462 100644 --- a/harbour/source/rtl/dir.c +++ b/harbour/source/rtl/dir.c @@ -206,9 +206,9 @@ #endif /* these work under NT but are otherwise used as placeholders for non MS o/s support */ -#if !defined(FA_ENCRYPTED) +#if !defined(FA_DEVICE) #define FA_DEVICE 64 /* I */ - #define FA_NORMAL 128 /* N */ // ignored +/* #define FA_NORMAL 128 */ /* N */ /* ignored */ /* Exists in BORLANDC */ #define FA_TEMPORARY 256 /* T */ #define FA_SPARSE 512 /* P */ #define FA_REPARSE 1024 /* L */ @@ -253,8 +253,8 @@ static USHORT osToHarbourMask( USHORT usMask ) usRetMask |= FA_DIREC; if( usMask & FILE_HIDDEN ) usRetMask |= FA_HIDDEN; - if( usMask & FILE_RDONLY ) - usRetMask |= FA_READONLY; + if( usMask & FILE_READONLY ) + usRetMask |= FA_RDONLY; if( usMask & FILE_SYSTEM ) usRetMask |= FA_SYSTEM; #endif @@ -301,8 +301,8 @@ static USHORT HarbourToOsMask( USHORT usMask ) usRetMask |= FILE_DIRECTORY; if( usMask & FA_HIDDEN ) usRetMask |= FILE_HIDDEN; - if( usMask & FA_READONLY ) - usRetMask |= FILE_RDONLY; + if( usMask & FA_RDONLY ) + usRetMask |= FILE_READONLY; if( usMask & FA_SYSTEM ) usRetMask |= FILE_SYSTEM; #endif diff --git a/harbour/source/rtl/environ.c b/harbour/source/rtl/environ.c index c183faad3b..f27c28f677 100644 --- a/harbour/source/rtl/environ.c +++ b/harbour/source/rtl/environ.c @@ -65,11 +65,15 @@ #endif #endif +#if defined(__BORLANDC__) && defined(_Windows) && ! defined(VER_PLATFORM_WIN32_WINDOWS) + #define VER_PLATFORM_WIN32_WINDOWS 1 +#endif + #include "extend.h" #include "errorapi.h" #include "hbver.h" -#if defined(__TURBOC__) || defined(__BORLANDC__) || defined(__MSC__) || defined(_MSC_VER) || defined(__DJGPP__) || defined(__MINGW32__) +#if defined(__TURBOC__) || defined(__BORLANDC__) || defined(_MSC_VER) || defined(__DJGPP__) || defined(__MINGW32__) #include #include #endif @@ -136,7 +140,7 @@ HARBOUR HB_OS( void ) #else /* TODO: add MSVC support but MSVC cannot detect any OS except Windows! */ -#if defined(__TURBOC__) || defined(__BORLANDC__) || defined(__MSC__) || defined(_MSC_VER) || defined(__MINGW32__) +#if defined(__TURBOC__) || defined(__BORLANDC__) || defined(_MSC_VER) || defined(__MINGW32__) #if defined(_Windows) || defined(_WIN32) || defined(__MINGW32__) @@ -176,7 +180,7 @@ HARBOUR HB_OS( void ) cformat = "%s %d.%02d.%04d"; } #else -#if defined(__MSC__) || defined(_MSC_VER) +#if defined(_MSC_VER) if( _osmode == _WIN_MODE ) { hb_os = "Windows"; @@ -195,7 +199,7 @@ HARBOUR HB_OS( void ) hb_osletter = 0; hb_os = "Windows"; } -#endif /* __MSC__ */ +#endif /* _MSC_VER */ else { hb_os = "DOS"; @@ -251,7 +255,7 @@ HARBOUR HB_OS( void ) hb_osletter = 0; } } -#endif /* __TURBOC__ or __BORLANDC__ or __MSC__ 0r __DJGPP__ */ +#endif /* __TURBOC__ or __BORLANDC__ or _MSC_VER 0r __DJGPP__ */ #ifdef __DJGPP__ hb_os = hb_xgrab( strlen( _os_flavor ) + 1 ); strcpy( hb_os, _os_flavor ); @@ -284,6 +288,59 @@ HARBOUR HB_VERSION( void ) sprintf( hb_ver, "Harbour %d.%d Intl. (Build %d%s) (%04d.%02d.%02d)", hb_major, hb_minor, hb_build, hb_revision, hb_year, hb_month, hb_day ); + if( hb_pcount() == 1 ) + { + /* Optionally include the Compiler name and version, if available. */ + char * compiler = (char *) 0; + int version = 0; + + #if defined(__IBMCPP__) + compiler = "IBM C++"; + version = __IBMCPP__; + #elif defined(__BORLANDC__) + compiler = "Borland C"; + version = __BORLANDC__; + #elif defined(__TURBOC__) + compiler = "Turbo C"; + version = __TURBOC__; + #elif defined(_MSC_VER) + compiler = "Microsoft C"; + version = _MSC_VER; + #elif defined(__MPW__) + compiler = "MPW C"; + version = __MPW__; + #elif defined(__WATCOMC_) + compiler = "Watcom C"; + version = __WATCOMC__; + #elif defined(__DJGPP__) + compiler = "Delorie GCC"; + version = __DJGPP__; + #elif defined(__CYGWIN__) + compiler = "Cygnus GCC (cygwin)"; + version = __CYGWIN__; + #elif defined(__MINGW32__) + compiler = "Cygnus GCC (mingw32)"; + version = __MINGW32__; + #elif defined(__GNUC__) + compiler = "GNU C"; + version = __GNUC__; + #endif + if( compiler ) + { + strncat( hb_ver, " (", sizeof( hb_ver ) ); + strncat( hb_ver, compiler, sizeof( hb_ver ) ); + if( version ) + { + char buf[ 40 ]; + sprintf( buf, "(%d)", version ); + strncat( hb_ver, " ", sizeof( hb_ver ) ); + strncat( hb_ver, buf, sizeof( hb_ver ) ); + } + strncat( hb_ver, ")", sizeof( hb_ver ) ); + hb_ver[ sizeof( hb_ver ) - 1 ] = '\0'; + } + } + hb_retc( hb_ver ); } @@ -336,7 +393,7 @@ HARBOUR HB_GETENV( void ) HARBOUR HB___RUN( void ) { -#if defined(__TURBOC__) || defined(__BORLANDC__) || defined(__DJGPP__) || defined(__MSC__) || defined(_MSC_VER) || defined(__IBMCPP__) || defined(HARBOUR_GCC_OS2) || defined(__CYGWIN__) || defined(__MINGW32__) +#if defined(__TURBOC__) || defined(__BORLANDC__) || defined(__DJGPP__) || defined(_MSC_VER) || defined(__IBMCPP__) || defined(HARBOUR_GCC_OS2) || defined(__CYGWIN__) || defined(__MINGW32__) if( ISCHAR( 1 ) ) system( hb_parc( 1 ) ); #else diff --git a/harbour/source/rtl/filesys.c b/harbour/source/rtl/filesys.c index b0e8a28c5c..99c80c500b 100644 --- a/harbour/source/rtl/filesys.c +++ b/harbour/source/rtl/filesys.c @@ -121,6 +121,7 @@ #include #if defined(__BORLANDC__) #include + #include #endif #if defined(_MSC_VER) || defined(__MINGW32__) diff --git a/harbour/source/rtl/inkey.c b/harbour/source/rtl/inkey.c index efddb74994..f411fe98f8 100644 --- a/harbour/source/rtl/inkey.c +++ b/harbour/source/rtl/inkey.c @@ -36,6 +36,13 @@ /* * ChangeLog: * + * V 1.39 David G. Holm Added Borland Windows support. + * Restored Unix support to what + * it was in version 1.34. + * Added separate Cygwin support and + * set it up to cooperate between the + * hb_inkeyGet() and hb_inkeyNext() + * functions (but it still blocks). * V 1.36 David G. Holm Added __MINGW32__ support * V 1.35 David G. Holm Changed the __CYGWIN__ build to use * the Unix keyboard input method and @@ -78,7 +85,7 @@ #include "inkey.h" #include "init.h" -#if defined(__TURBOC__) || defined(__BORLANDC__) || defined(__MSC__) || defined(_MSC_VER) || defined(__MINGW32__) +#if defined(__TURBOC__) || defined(__BORLANDC__) || defined(_MSC_VER) || defined(__MINGW32__) #include #include #elif defined(__DJGPP__) @@ -199,9 +206,6 @@ int hb_inkey( double seconds, HB_inkey_enum event_mask, BOOL wait, BOOL forever if( wait ) end_clock = clock() + seconds * CLOCKS_PER_SEC; s_inkeyPoll = TRUE; /* Force polling */ -/* As soon as a non-blocking way to do Unix input is implemented, - the #if test can be eliminated, (leaving the code intact) */ -#if ! defined(OS_UINX_COMPATIBLE) && ! defined(__CYGWIN__) while( wait && hb_inkeyNext() == 0 ) { /* Release the CPU between checks */ @@ -211,7 +215,6 @@ int hb_inkey( double seconds, HB_inkey_enum event_mask, BOOL wait, BOOL forever if( !forever && clock() >= end_clock ) wait = FALSE; } /* Get the current input event or 0 */ -#endif key = hb_inkeyGet(); s_inkeyPoll = FALSE; /* Stop forced polling */ s_eventmask = hb_set.HB_SET_EVENTMASK; /* Restore original input event mask */ @@ -221,14 +224,6 @@ int hb_inkey( double seconds, HB_inkey_enum event_mask, BOOL wait, BOOL forever int hb_inkeyGet( void ) /* Extract the next key from the keyboard buffer */ { int key; -#if defined(OS_UNIX_COMPATIBLE) || defined(__CYGWIN__) - /* This part of the #if block is temporary and needs to be removed when - non-blocking Unix-style keyboard input is implemented */ - char ch; - read( STDIN_FILENO, &ch, 1 ); - if( ch == '\n' ) key = '\r'; - else key = ch; -#else hb_inkeyPoll(); if( hb_set.HB_SET_TYPEAHEAD ) { @@ -246,7 +241,6 @@ int hb_inkeyGet( void ) /* Extract the next key from the keyboard buffer * } else key = s_inkeyLast = s_inkeyForce; /* Typeahead support is disabled */ s_inkeyForce = 0; -#endif return key; } @@ -263,8 +257,8 @@ int hb_inkeyNext( void ) /* Return the next key without extracting it */ if( hb_set.HB_SET_TYPEAHEAD ) { /* Proper typeahead support is enabled */ - if( s_inkeyHead == s_inkeyTail ) key = 0; - else key = s_inkeyBuffer[ s_inkeyTail ]; + if( s_inkeyHead == s_inkeyTail ) key = 0; /* No key */ + else key = s_inkeyBuffer[ s_inkeyTail ]; /* Next key */ } else key = s_inkeyForce; /* Typeahead support is disabled */ return key; @@ -297,6 +291,10 @@ void hb_inkeyPoll( void ) /* Poll the console keyboard to stuff the Harbour #if defined(__DJGPP__) if( s_eventmask & INKEY_EXTENDED ) ch = getxkey(); else ch = getkey(); + #elif defined(__BORLANDC__) && ( defined(_Windows) || defined(_WIN32) ) + ch = getch(); + if( !ch ) /* Is a extended key */ + ch = getch() + 256; #else /* A key code is available in the BIOS keyboard buffer */ ch = getch(); /* Get the key code */ @@ -427,9 +425,22 @@ void hb_inkeyPoll( void ) /* Poll the console keyboard to stuff the Harbour case 396: /* Alt + F12 */ ch = 349 - ch; } -#elif defined(OS_UNIX_COMPATIBLE) || defined(__CYGWIN__) +#elif defined(OS_UNIX_COMPATIBLE) /* TODO: */ - /* NOTE: The blocking Unix support has been moved to hb_inkeyGet() */ + if( ! read( STDIN_FILENO, &ch, 1 ) ) + return; +#elif defined(__CYGWIN__) + /* TODO: */ + /* NOTE: Cygwin needs the Unix support, but for some reason it + is blocking when used in Cygwin, so it has to be handled + separately from the Unix support. */ + if( s_inkeyPoll && s_inkeyHead == s_inkeyTail ) + { + /* 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 */ + } #else /* TODO: Support for other platforms, such as Mac */ #endif diff --git a/harbour/tests/working/inkeytst.prg b/harbour/tests/working/inkeytst.prg index 97e52c20bf..2392636d75 100644 --- a/harbour/tests/working/inkeytst.prg +++ b/harbour/tests/working/inkeytst.prg @@ -17,10 +17,10 @@ LOCAL nKey, nMask, cText /* NOTE: When non-blocking Unix-style keyboard input is implemented, remove the next few lines... */ ? - ? "Note: All but the last test will fail for Harbour builds with Unix-style" - ? " keyboard input. The TYPEAHEAD tests will enter an infinite loop." - ? " To run only the last test, break out of this program and run it" - ? " again with any parameter (for example, INKEYTST X)." + ? "Note: If you are using a Cygnus CYGWIN build of Harbour, some of the" + ? " keyboard tests will not give the correct results, you will have" + ? " to press a key even when the prompt indicates a timeout, and you" + ? " may have to press an extra key in order to get the test results." ? ? "Testing the KEYBOARD and CLEAR TYPEAHEAD commands and the" diff --git a/harbour/tests/working/version.prg b/harbour/tests/working/version.prg index 7dabad8fa5..2a4a358189 100644 --- a/harbour/tests/working/version.prg +++ b/harbour/tests/working/version.prg @@ -10,6 +10,7 @@ function Main() - QOUT( VERSION() ) + ? VERSION() + ? VERSION(.T.) return nil