diff --git a/harbour/ChangeLog b/harbour/ChangeLog index ebb691d9e3..a62e59a78b 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,29 @@ +20000330-12:15 EST Paul Tucker + * source/rtl/dates.c + * account for possible overflow in calculation + * source/rtl/defpath.c + * initialise size to 0 + * source/rtl/environ.c + * added missing ; for msc branch + * source/rtl/isprint.c + * added msc8 support (== _BORLANDC_) + * source/rtl/dir.c + * source/rtl/gtdos/gtdos.c + * source/rtl/gtdos/mousedos.c + * modified to work with msc8 (upcoming addition!) + * include/hbvmpub.h + * change alignment of HB_SYMB for msc8 + * source/rdd/dbcmd.c + * changed if(!(...)) to if((...)==0) in rddInherit for /W4 compiler warning. + * initialise uiArraylen in AFIELDS() + * initialise ulNext in defEval() + * source/rdd/dbf1.c + * dbfUpdateRecord() Initialise local ulRecCount! + NOTE: Something doesn't look right with the logic here. + * dbfReadDBHeader() Init pFieldInfo.uiLen to 0 + * source/vm/memvars.c + * hb_memvarCreateFromItem() Initialize pDynVar to NULL + 20000329-16:33 GMT+1 Victor Szakats * include/hbapi.h diff --git a/harbour/include/hbvmpub.h b/harbour/include/hbvmpub.h index dbb310c178..09cba1849b 100644 --- a/harbour/include/hbvmpub.h +++ b/harbour/include/hbvmpub.h @@ -45,6 +45,8 @@ extern "C" { struct _HB_DYNS; /* symbol support structure */ +#pragma pack(8) + typedef struct { char * szName; /* the name of the symbol */ diff --git a/harbour/source/rdd/dbcmd.c b/harbour/source/rdd/dbcmd.c index 98de4f9543..09329ee05e 100644 --- a/harbour/source/rdd/dbcmd.c +++ b/harbour/source/rdd/dbcmd.c @@ -284,7 +284,7 @@ static ERRCODE defError( AREAP pArea, PHB_ITEM pError ) static ERRCODE defEval( AREAP pArea, LPDBEVALINFO pEvalInfo ) { BOOL bEof, bFor, bWhile; - ULONG ulNext; + ULONG ulNext = 0; HB_TRACE(HB_TR_DEBUG, ("defEval(%p, %p)", pArea, pEvalInfo)); @@ -1026,7 +1026,7 @@ ERRCODE hb_rddInherit( PRDDFUNCS pTable, PRDDFUNCS pSubTable, PRDDFUNCS pSuperTa return FAILURE; /* Copy the pSuperTable into pTable */ - if( !szDrvName || !( uiCount = strlen( ( const char * ) szDrvName ) ) ) + if( !szDrvName || ( uiCount = strlen( ( const char * ) szDrvName ) )==0 ) { memcpy( pTable, &defTable, sizeof( RDDFUNCS ) ); memcpy( pSuperTable, &defTable, sizeof( RDDFUNCS ) ); @@ -1338,7 +1338,7 @@ void hb_rddShutDown( void ) HB_FUNC( AFIELDS ) { PHB_ITEM pName, pType, pLen, pDec, pItem; - USHORT uiFields, uiArrayLen, uiCount; + USHORT uiFields, uiArrayLen = 0, uiCount; if( !s_pCurrArea ) { diff --git a/harbour/source/rdd/dbf1.c b/harbour/source/rdd/dbf1.c index fe8edffe84..2f82eb39f2 100644 --- a/harbour/source/rdd/dbf1.c +++ b/harbour/source/rdd/dbf1.c @@ -293,7 +293,7 @@ static BOOL hb_dbfWriteMemo( AREAP pArea, LPDBFMEMO pMemo, ULONG * lNewRecNo ) static BOOL hb_dbfUpdateRecord( AREAP pArea, ULONG ulRecNo ) { - ULONG ulRecCount; + ULONG ulRecCount = 0; USHORT uiCount; LPFIELD pField; BYTE pBuffer[ 1 ]; @@ -1719,6 +1719,7 @@ static ERRCODE dbfReadDBHeader( AREAP pArea ) pArea->lpExtendInfo->uiRecordLen = 1; SELF_SETFIELDEXTENT( pArea, uiFields ); pFieldInfo.typeExtended = 0; + pFieldInfo.uiLen = 0; pDBField = ( LPDBFFIELD ) szBuffer; for( uiCount = 0; uiCount < uiFields; uiCount++ ) { diff --git a/harbour/source/rtl/dates.c b/harbour/source/rtl/dates.c index f9615d5f6a..941f8e48a1 100644 --- a/harbour/source/rtl/dates.c +++ b/harbour/source/rtl/dates.c @@ -146,8 +146,10 @@ void hb_dateStrGet( const char * szDate, long * plDay, long * plMonth, long * pl /* Date string has correct length, so attempt to convert */ *plDay = ( ( szDate[ 6 ] - '0' ) * 10 ) + ( szDate[ 7 ] - '0' ); *plMonth = ( ( szDate[ 4 ] - '0' ) * 10 ) + ( szDate[ 5 ] - '0' ); - *plYear = ( ( szDate[ 0 ] - '0' ) * 1000 ) + ( ( szDate[ 1 ] - '0' ) * 100 ) + - ( ( szDate[ 2 ] - '0' ) * 10 ) + ( szDate[ 3 ] - '0' ); + *plYear = ( ( USHORT ) ( szDate[ 0 ] - '0' ) * 1000 ) + + ( ( USHORT ) ( szDate[ 1 ] - '0' ) * 100 ) + + ( ( USHORT ) ( szDate[ 2 ] - '0' ) * 10 ) + + ( USHORT ) ( szDate[ 3 ] - '0' ); } else { diff --git a/harbour/source/rtl/defpath.c b/harbour/source/rtl/defpath.c index 6f02444133..4e4b95f0c3 100644 --- a/harbour/source/rtl/defpath.c +++ b/harbour/source/rtl/defpath.c @@ -40,7 +40,7 @@ HB_FUNC( DEFPATH ) { char buffer[ _POSIX_PATH_MAX ]; char delimiter[ 2 ] = ":"; - int size; + int size = 0; if( hb_set.HB_SET_DEFAULT ) { diff --git a/harbour/source/rtl/dir.c b/harbour/source/rtl/dir.c index cdc6dc6720..629597db58 100644 --- a/harbour/source/rtl/dir.c +++ b/harbour/source/rtl/dir.c @@ -131,7 +131,7 @@ #endif #endif -#if defined(__WATCOMC__) || defined(_MSC_VER) || defined(__MINGW32__) +#if defined(__WATCOMC__) || defined(__MINGW32__) || ( defined(_MSC_VER) && _MSC_VER >= 1000 ) #include #include #include @@ -140,6 +140,19 @@ #include #include + #if !defined(HAVE_POSIX_IO) + #define HAVE_POSIX_IO + #endif +#elif defined(_MSC_VER) + #include + #include + #include + #include + #include + #include + #include + #include + #if !defined(HAVE_POSIX_IO) #define HAVE_POSIX_IO #endif @@ -351,7 +364,7 @@ HB_FUNC( DIRECTORY ) PHB_ITEM pDirSpec = hb_param( 1, IT_STRING ); PHB_ITEM pAttributes = hb_param( 2, IT_STRING ); -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(__MINGW32__) || ( defined(_MSC_VER) && _MSC_VER >= 1000 ) PHB_ITEM pEightDotThree = hb_param( 3, IT_LOGICAL ); BOOL bEightDotThree; #elif defined(__WATCOMC__) @@ -371,7 +384,7 @@ HB_FUNC( DIRECTORY ) char ttime[ 9 ]; char aatrib[ 17 ]; int attrib; - long fsize; + long fsize = 0; time_t ftime; char * pos; USHORT ushbMask = FA_ARCH; @@ -380,9 +393,12 @@ HB_FUNC( DIRECTORY ) struct stat statbuf; struct tm * ft; -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(__MINGW32__) || ( defined(_MSC_VER) && _MSC_VER >= 1000 ) struct _finddata_t entry; long hFile; +#elif defined(_MSC_VER) + struct _find_t entry; + long hFile; #elif defined(__IBMCPP__) FILEFINDBUF3 entry; HDIR hFind = HDIR_CREATE; @@ -401,7 +417,7 @@ HB_FUNC( DIRECTORY ) if( pAttributes && hb_itemGetCLen( pAttributes ) >= 1 ) ushbMask |= HarbourAttributesToMask( ( BYTE * ) hb_itemGetCPtr( pAttributes ) ); -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(__MINGW32__) || ( defined(_MSC_VER) && _MSC_VER >= 1000 ) /* Do we want 8.3 support? */ bEightDotThree = ( pEightDotThree ? hb_itemGetL( pEightDotThree ) : FALSE ); #endif @@ -488,7 +504,7 @@ HB_FUNC( DIRECTORY ) tzset(); pDir = hb_itemArrayNew( 0 ); -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(__MINGW32__) || ( defined(_MSC_VER) && _MSC_VER >=1000 ) strcpy( string, dirname ); strcat( string, pattern ); @@ -504,6 +520,16 @@ HB_FUNC( DIRECTORY ) if( bEightDotThree ) GetShortPathName( string, string, _POSIX_PATH_MAX ); +#elif defined(_MSC_VER) + + strcpy( string, dirname ); + strcat( string, pattern ); + + if( _dos_findfirst( string, ushbMask, &entry ) == 0 ) + { + do + { + strcpy( string, entry.name ); #elif defined(__IBMCPP__) strcpy( string, dirname ); @@ -567,7 +593,7 @@ HB_FUNC( DIRECTORY ) { attrib = 0; -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(__MINGW32__) || ( defined(_MSC_VER) && _MSC_VER >= 1000 ) /* due to short-name support: reconstruct the filename */ if( bEightDotThree ) @@ -593,6 +619,9 @@ HB_FUNC( DIRECTORY ) strcpy( fullfile, dirname ); strcpy( filename, entry.name ); } +#elif defined(_MSC_VER) + strcpy( filename, entry.name ); + strcpy( fullfile, dirname ); #elif defined(__IBMCPP__) strcpy( filename, entry.achName ); strcpy( fullfile, dirname ); @@ -613,8 +642,9 @@ HB_FUNC( DIRECTORY ) attrib = statbuf.st_mode; #elif defined(__IBMCPP__) attrib = entry.attrFile; - #elif defined(_MSC_VER) || defined(__MINGW32__) + #elif defined(__MINGW32__) || defined(_MSC_VER) attrib = entry.attrib; + #if defined(_MSC_VER ) && _MSC_VER >= 1000 if( bEightDotThree ) { /* need to strip off the path */ @@ -622,7 +652,7 @@ HB_FUNC( DIRECTORY ) if( pos ) strcpy( filename, ++pos ); } - + #endif #elif defined(__BORLANDC__) && (__BORLANDC__ >= 1280) /* NOTE: _chmod( f, 0 ) => Get attribs _chmod( f, 1, n ) => Set attribs @@ -690,9 +720,11 @@ HB_FUNC( DIRECTORY ) } } -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER >= 1000 ) while( _findnext( hFile, &entry ) == 0 ); _findclose( hFile ); +#elif defined(_MSC_VER ) + while( _dos_findnext( &entry ) == 0 ); #elif defined(__IBMCPP__) while( DosFindNext( hFind, &entry, findSize, &findCount ) == NO_ERROR && findCount > 0 ); DosFindClose( hFind ); diff --git a/harbour/source/rtl/environ.c b/harbour/source/rtl/environ.c index 3897410f49..2186cc9a8d 100644 --- a/harbour/source/rtl/environ.c +++ b/harbour/source/rtl/environ.c @@ -245,7 +245,7 @@ HB_FUNC( OS ) { hb_os = "Windows"; hb_osmajor = _osmajor; - hb_osminor = _osminor + hb_osminor = _osminor; hb_osletter = 0; } #else diff --git a/harbour/source/rtl/gtdos/gtdos.c b/harbour/source/rtl/gtdos/gtdos.c index 03ded19269..9ee2702e8b 100644 --- a/harbour/source/rtl/gtdos/gtdos.c +++ b/harbour/source/rtl/gtdos/gtdos.c @@ -71,6 +71,8 @@ #include #elif defined(__WATCOMC__) #include +#elif defined(_MSC_VER) + #include #endif #if defined(__WATCOMC__) @@ -129,11 +131,11 @@ static BOOL s_bBreak; /* Used to signal Ctrl+Break to hb_inkeyPoll() */ static USHORT s_uiDispCount; #ifndef __DJGPP__ -#if defined(__WATCOMC__) -static void hb_gt_Watcom_CtrlBreak_Handler( int iSignal ) +#if defined(__WATCOMC__) || defined(_MSC_VER) +static void hb_gt_CtrlBreak_Handler( int iSignal ) { /* Ctrl-Break was pressed */ - /* NOTE: the layout of this function is forced by the Watcom compiler + /* NOTE: the layout of this function is forced by the compiler */ HB_SYMBOL_UNUSED( iSignal ); s_bBreak = TRUE; @@ -154,6 +156,8 @@ static void hb_gt_CtrlBrkRestore( void ) HB_TRACE(HB_TR_DEBUG, ("hb_gt_CtrlBrkRestore()")); #if defined(__WATCOMC__) signal( SIGBREAK, SIG_DFL); + #elif defined(_MSC_VER) + signal( SIGINT, SIG_DFL); #else setcbrk( s_iOldCtrlBreak ); #endif @@ -181,7 +185,9 @@ void hb_gt_Init( int iFilenoStdin, int iFilenoStdout, int iFilenoStderr ) /* Set the Ctrl+Break handler [vszakats] */ #if defined(__WATCOMC__) - signal( SIGBREAK, hb_gt_Watcom_CtrlBreak_Handler ); + signal( SIGBREAK, hb_gt_CtrlBreak_Handler ); + #elif defined(_MSC_VER) + signal( SIGINT, hb_gt_CtrlBreak_Handler ); #else ctrlbrk( hb_gt_CtrlBrkHandler ); s_iOldCtrlBreak = getcbrk(); diff --git a/harbour/source/rtl/gtdos/mousedos.c b/harbour/source/rtl/gtdos/mousedos.c index c0f2e47d40..b851d71d17 100644 --- a/harbour/source/rtl/gtdos/mousedos.c +++ b/harbour/source/rtl/gtdos/mousedos.c @@ -42,6 +42,11 @@ #include #endif +#if defined(_MSC_VER) + #define MOUSE_INTERRUPT 0x33 + #include +#endif + #include "hbapigt.h" /* C callable low-level interface */ diff --git a/harbour/source/rtl/isprint.c b/harbour/source/rtl/isprint.c index c2ba2221a2..801d6d78e5 100644 --- a/harbour/source/rtl/isprint.c +++ b/harbour/source/rtl/isprint.c @@ -81,7 +81,7 @@ HB_FUNC( ISPRINTER ) union REGS regs; regs.h.ah = 2; - #if defined(__BORLANDC__) + #if defined(__BORLANDC__) || defined(_MSC_VER) regs.x.dx = uiPort - 1; #else regs.w.dx = uiPort - 1; diff --git a/harbour/source/vm/memvars.c b/harbour/source/vm/memvars.c index 272471e8b6..2b6bbcb3c0 100644 --- a/harbour/source/vm/memvars.c +++ b/harbour/source/vm/memvars.c @@ -574,7 +574,7 @@ char * hb_memvarGetStrValuePtr( char * szVarName, ULONG *pulLen ) */ static void hb_memvarCreateFromItem( PHB_ITEM pMemvar, BYTE bScope, PHB_ITEM pValue ) { - PHB_DYNS pDynVar; + PHB_DYNS pDynVar = NULL; HB_TRACE(HB_TR_DEBUG, ("hb_memvarCreateFromItem(%p, %d, %p)", pMemvar, bScope, pValue));