diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 8782337d48..9984d9eb89 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,13 @@ +20000401-06:09 GMT+1 Victor Szakats + + - source/rtl/environ.c + + source/rtl/version.c + * source/rtl/Makefile + * makefile.bc + * makefile.vc + * hb_os() - Fixed, simplified, optimized. + * Filename changed to match CA-Cl*pper + 20000401-04:57 GMT+1 Victor Szakats * source/rtl/environ.c diff --git a/harbour/makefile.bc b/harbour/makefile.bc index 1490f1c48a..aa9dba7057 100644 --- a/harbour/makefile.bc +++ b/harbour/makefile.bc @@ -169,7 +169,6 @@ RTL_LIB_OBJS = \ $(OBJ_DIR)\diskspac.obj \ $(OBJ_DIR)\do.obj \ $(OBJ_DIR)\empty.obj \ - $(OBJ_DIR)\environ.obj \ $(OBJ_DIR)\errorapi.obj \ $(OBJ_DIR)\eval.obj \ $(OBJ_DIR)\filesys.obj \ @@ -241,6 +240,7 @@ RTL_LIB_OBJS = \ $(OBJ_DIR)\val.obj \ $(OBJ_DIR)\valtostr.obj \ $(OBJ_DIR)\valtype.obj \ + $(OBJ_DIR)\version.obj \ $(OBJ_DIR)\word.obj \ $(OBJ_DIR)\xhelp.obj \ \ @@ -1043,10 +1043,6 @@ $(OBJ_DIR)\empty.obj : $(RTL_DIR)\empty.c $(CC) $(CLIBFLAGS) -o$@ $** tlib $(RTL_LIB) -+$@,, -$(OBJ_DIR)\environ.obj : $(RTL_DIR)\environ.c - $(CC) $(CLIBFLAGS) -o$@ $** - tlib $(RTL_LIB) -+$@,, - $(OBJ_DIR)\errorapi.obj : $(RTL_DIR)\errorapi.c $(CC) $(CLIBFLAGS) -o$@ $** tlib $(RTL_LIB) -+$@,, @@ -1475,6 +1471,10 @@ $(OBJ_DIR)\valtype.obj : $(RTL_DIR)\valtype.c $(CC) $(CLIBFLAGS) -o$@ $** tlib $(RTL_LIB) -+$@,, +$(OBJ_DIR)\version.obj : $(RTL_DIR)\version.c + $(CC) $(CLIBFLAGS) -o$@ $** + tlib $(RTL_LIB) -+$@,, + $(OBJ_DIR)\wait.c : $(RTL_DIR)\wait.prg $(HARBOUR_EXE) $(HARBOURFLAGS) $** -o$@ diff --git a/harbour/makefile.vc b/harbour/makefile.vc index 2ec1750761..65560f3395 100644 --- a/harbour/makefile.vc +++ b/harbour/makefile.vc @@ -208,7 +208,6 @@ RTL_LIB_OBJS = \ $(OBJ_DIR)\diskspac.obj \ $(OBJ_DIR)\do.obj \ $(OBJ_DIR)\empty.obj \ - $(OBJ_DIR)\environ.obj \ $(OBJ_DIR)\errorapi.obj \ $(OBJ_DIR)\eval.obj \ $(OBJ_DIR)\filesys.obj \ @@ -280,6 +279,7 @@ RTL_LIB_OBJS = \ $(OBJ_DIR)\val.obj \ $(OBJ_DIR)\valtostr.obj \ $(OBJ_DIR)\valtype.obj \ + $(OBJ_DIR)\version.obj \ $(OBJ_DIR)\word.obj \ $(OBJ_DIR)\xhelp.obj \ \ diff --git a/harbour/source/rtl/Makefile b/harbour/source/rtl/Makefile index 346bd8ee5a..7668999536 100644 --- a/harbour/source/rtl/Makefile +++ b/harbour/source/rtl/Makefile @@ -27,7 +27,6 @@ C_SOURCES=\ diskspac.c \ do.c \ empty.c \ - environ.c \ errorapi.c \ eval.c \ filesys.c \ @@ -99,6 +98,7 @@ C_SOURCES=\ val.c \ valtostr.c \ valtype.c \ + version.c \ word.c \ xhelp.c \ \ diff --git a/harbour/source/rtl/environ.c b/harbour/source/rtl/version.c similarity index 79% rename from harbour/source/rtl/environ.c rename to harbour/source/rtl/version.c index a0e6b20e12..d880b06289 100644 --- a/harbour/source/rtl/environ.c +++ b/harbour/source/rtl/version.c @@ -57,6 +57,8 @@ #define HB_OS_WIN_32_USED +#include + #include "hbapi.h" #include "hbapierr.h" #include "hbver.h" @@ -99,7 +101,7 @@ The latter is mainly an issue in DOS, where the host OS can be OS/2 WinNT/2K, Win3x, Win9x, DOSEMU, Desqview, etc. [vszakats] */ -#define HB_OS_BUFFER_LEN 128 +#define HB_OS_BUFFER_LEN 256 char * hb_os( void ) { @@ -131,7 +133,7 @@ char * hb_os( void ) if( regs.h.al != 0x00 && regs.h.al != 0x80 ) { - char szHost[ 128 ] = ""; + char szHost[ 128 ]; if( regs.h.al == 0x01 || regs.h.al == 0xFF ) sprintf( szHost, " (Windows 2.x)" ); @@ -168,7 +170,7 @@ char * hb_os( void ) if( regs.h.al >= 10 ) { - char szHost[ 128 ] = ""; + char szHost[ 128 ]; if( regs.h.al == 20 && regs.h.ah > 20 ) sprintf( szHost, " (OS/2 %d.%02d)", regs.h.ah / 10, regs.h.ah % 10 ); @@ -200,77 +202,30 @@ char * hb_os( void ) { OSVERSIONINFO osVer; - char * pszName; - char szBuild[ 128 ] = ""; - int iVerMajor; - int iVerMinor; - int iVerLetter; - osVer.dwOSVersionInfoSize = sizeof( osVer ); if( GetVersionEx( &osVer ) ) { - iVerMajor = osVer.dwMajorVersion; - iVerMinor = osVer.dwMinorVersion; - iVerLetter = LOWORD( osVer.dwBuildNumber ); + char * pszName = "Windows"; switch( osVer.dwPlatformId ) { case VER_PLATFORM_WIN32_WINDOWS: - if( iVerMajor == 4 && iVerMinor == 0 && iVerLetter == 950 ) + if( osVer.dwMajorVersion == 4 && osVer.dwMinorVersion < 10 ) pszName = "Windows 95"; - else if( iVerMajor == 4 && iVerMinor > 0 && - iVerLetter > 950 && iVerLetter <= 1080 ) - pszName = "Windows 95 SP1"; - else if( iVerMajor == 4 && iVerMinor < 10 && - iVerLetter > 1080 ) - pszName = "Windows 95 OSR2"; /* Formerly: "Windows 95 SP2" */ - else if( iVerMajor == 4 && iVerMinor == 10 && - iVerLetter == 1998 ) + else if( osVer.dwMajorVersion == 4 && osVer.dwMinorVersion == 10 ) pszName = "Windows 98"; - else if( iVerMajor == 4 && iVerMinor == 10 && - iVerLetter > 1998 && iVerLetter < 2183 ) - pszName = "Windows 98 SP1"; - else if( iVerMajor > 4 && iVerLetter >= 2183 ) - pszName = "Windows 98 SE"; - else - pszName = "Windows"; - - strncpy( szBuild, osVer.szCSDVersion, sizeof( szBuild ) ); - szBuild[ sizeof( szBuild ) - 1 ] = '\0'; break; case VER_PLATFORM_WIN32_NT: - if( iVerMajor == 3 && iVerMinor == 10 ) - pszName = "Windows NT 3.1"; - else if( iVerMajor == 3 && iVerMinor == 50 ) - pszName = "Windows NT 3.5"; - else if( iVerMajor == 3 && iVerMinor == 51 ) - pszName = "Windows NT 3.51"; - else if( iVerMajor == 4 ) - pszName = "Windows NT 4"; - else if( iVerMajor == 5 ) + if( osVer.dwMajorVersion == 5 ) pszName = "Windows 2000"; else pszName = "Windows NT"; - if( osVer.szCSDVersion ) - { - int i = 0; - int iServicePack; - - while( osVer.szCSDVersion[ i ] != '\0' && ( osVer.szCSDVersion[ i ] < '0' || osVer.szCSDVersion[ i ] > '9' ) ) - i++; - - iServicePack = atoi( &osVer.szCSDVersion[ i ] ); - - if( iServicePack ) - sprintf( szBuild, " SP%i", iServicePack ); - } - break; case VER_PLATFORM_WIN32s: @@ -280,21 +235,32 @@ char * hb_os( void ) case VER_PLATFORM_WIN32_CE: pszName = "Windows CE"; break; + } - default: - pszName = "Windows"; - break; + sprintf( pszOS, "%s %d.%02d.%04d", + pszName, + osVer.dwMajorVersion, + osVer.dwMinorVersion, + LOWORD( osVer.dwBuildNumber ) ); + + /* Add service pack/other info */ + + if( osVer.szCSDVersion ) + { + int i; + + /* Skip the leading spaces (Win95B, Win98) */ + for( i = 0; osVer.szCSDVersion[ i ] != '\0' && isspace( osVer.szCSDVersion[ i ] ); i++ ); + + if( osVer.szCSDVersion[ i ] != '\0' ) + { + strcat( pszOS, " " ); + strcat( pszOS, osVer.szCSDVersion + i ); + } } } else - { - iVerMajor = osVer.dwMajorVersion; - iVerMinor = osVer.dwMinorVersion; - iVerLetter = LOWORD( osVer.dwBuildNumber ); - pszName = "Windows"; - } - - sprintf( pszOS, "%s%s %d.%02d.%04d", pszName, szBuild, iVerMajor, iVerMinor, iVerLetter ); + sprintf( pszOS, "Windows" ); } #elif defined(HB_OS_UNIX)