diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 4162aabdf3..eb9473beed 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,35 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-10-15 17:39 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbpp.h + * harbour/include/hbmath.h + * harbour/source/pp/ppcore.c + * harbour/source/pp/ppgen.c + * harbour/source/pp/Makefile + * harbour/source/rtl/diskspac.c + * harbour/source/rtl/fserror.c + * harbour/source/rtl/gtchrmap.c + * harbour/source/rtl/disksphb.c + * harbour/source/rtl/gttone.c + * harbour/source/rtl/gtwvt/gtwvt.c + * harbour/source/rtl/fssize.c + * harbour/source/rtl/hbinet.c + * harbour/source/rtl/hbffind.c + * harbour/source/rtl/filesys.c + * harbour/source/vm/mainwin.c + * harbour/source/common/hbver.c + * harbour/source/common/hbtrace.c + * harbour/source/compiler/cmdcheck.c + * harbour/source/compiler/ppcomp.c + * harbour/utils/hbver/hbverfix.c + * harbour/utils/hbpp/hbppcore.c + * harbour/config/w32/pocc.cf + * code cleanup: + - eliminated unnecessary errno access + - use WinAPI functions instead of some standard C library functions + in Windows builds + 2007-10-13 12:48 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/compiler/hbdead.c % minor improvement diff --git a/harbour/config/w32/pocc.cf b/harbour/config/w32/pocc.cf index 38ab3eedc8..86d8dd29f1 100644 --- a/harbour/config/w32/pocc.cf +++ b/harbour/config/w32/pocc.cf @@ -62,10 +62,13 @@ endif LINKLIBS += $(foreach gt, $(HB_GT_LIBS), $(gt)$(LIB_EXT)) endif +#LDFLAGS = $(LINKPATHS) LDFLAGS = $(LINKPATHS) kernel32.lib user32.lib \ winspool.lib ole32.lib oleaut32.lib uuid.lib \ comctl32.lib mapi32.lib advapi32.lib \ - gdi32.lib mpr.lib wsock32.lib + gdi32.lib mpr.lib wsock32.lib ws2.lib ws2_32.lib + +# ws2 ws2_32 ifeq ($(HB_GT_DEFAULT),gtgui) LDFLAGS += /SUBSYSTEM:WINDOWS @@ -75,8 +78,6 @@ LDFLAGS += /SUBSYSTEM:WINDOWS endif endif -# mpr wsock32 ws2_32 mapi32 - AR = polib.exe ARFLAGS = $(A_USR) AR_RULE = $(AR) $(ARFLAGS) /out:$@ $(^F) diff --git a/harbour/include/hbmath.h b/harbour/include/hbmath.h index 58ffe8730f..e6ccfb979e 100644 --- a/harbour/include/hbmath.h +++ b/harbour/include/hbmath.h @@ -82,7 +82,10 @@ HB_EXTERN_BEGIN #define exception _exception #endif #endif - +#elif defined(__MINGW32CE__) + #define HB_MATH_HANDLER + #define matherr _matherr + #define exception _exception /* it seems that MinGW has some problem with MATH HANDLER use HB_MATH_ERRNO instead */ #elif defined(__MINGW32__) && 0 diff --git a/harbour/include/hbpp.h b/harbour/include/hbpp.h index f2f1597f22..7a008c1a89 100644 --- a/harbour/include/hbpp.h +++ b/harbour/include/hbpp.h @@ -83,7 +83,7 @@ HB_EXTERN_BEGIN #define HB_PP_INLINE_QUOTE2 6 /* function to open included files */ -#define HB_PP_OPEN_FUNC_( func ) FILE * func( void *, const char *, BOOL, char * ) +#define HB_PP_OPEN_FUNC_( func ) FILE * func( void *, const char *, BOOL, BOOL *, char * ) typedef HB_PP_OPEN_FUNC_( HB_PP_OPEN_FUNC ); typedef HB_PP_OPEN_FUNC * PHB_PP_OPEN_FUNC; diff --git a/harbour/source/common/hbtrace.c b/harbour/source/common/hbtrace.c index e622982973..a71a55e073 100644 --- a/harbour/source/common/hbtrace.c +++ b/harbour/source/common/hbtrace.c @@ -225,7 +225,6 @@ void hb_tr_trace( char * fmt, ... ) if ( s_flush ) { fflush( s_fp ) ; - close( dup( fileno( s_fp ))) ; } } } diff --git a/harbour/source/common/hbver.c b/harbour/source/common/hbver.c index 5df14d8a4f..074c4ade16 100644 --- a/harbour/source/common/hbver.c +++ b/harbour/source/common/hbver.c @@ -88,7 +88,7 @@ #define VER_PLATFORM_WIN32_CE 3 #endif -#elif defined(HB_OS_UNIX) +#elif defined(HB_OS_UNIX) && !defined(__CEGCC__) #include @@ -269,6 +269,10 @@ char * hb_verPlatform( void ) snprintf( pszPlatform, 256, "Windows" ); } +#elif defined(__CEGCC__) + { + snprintf( pszPlatform, 256, "Windows" ); + } #elif defined(HB_OS_UNIX) { diff --git a/harbour/source/compiler/cmdcheck.c b/harbour/source/compiler/cmdcheck.c index 04dc7410d0..7f5cef7ec1 100644 --- a/harbour/source/compiler/cmdcheck.c +++ b/harbour/source/compiler/cmdcheck.c @@ -45,10 +45,14 @@ * */ -#include - #include "hbcomp.h" +#if defined(HB_OS_WIN_32) +#include +#else +#include +#endif + /* TODO: Add support for this compiler switches -r -t || hb_getenv( "TMP" ) */ @@ -76,11 +80,40 @@ static ULONG PackDateTime( void ) BYTE szString[4]; BYTE nValue; +#if defined(HB_OS_WIN_32) + SYSTEMTIME st; + + GetLocalTime( &st ); + + nValue = ( BYTE ) ( ( st.wYear - 1980 ) & ( 2 ^ 6 ) ); /* 6 bits */ + szString[0] = nValue << 2; + nValue = ( BYTE ) ( st.wMonth ); /* 4 bits */ + szString[0] |= nValue >> 2; + szString[1] = nValue << 6; + nValue = ( BYTE ) ( st.wDay ); /* 5 bits */ + szString[1] |= nValue << 1; + + nValue = ( BYTE ) st.wHour; /* 5 bits */ + szString[1] = nValue >> 4; + szString[2] = nValue << 4; + nValue = ( BYTE ) st.wMinute; /* 6 bits */ + szString[2] |= nValue >> 2; + szString[3] = nValue << 6; + nValue = ( BYTE ) st.wSecond; /* 6 bits */ + szString[3] |= nValue; +#else time_t t; struct tm *oTime; +#if defined( HB_OS_LINUX ) && !defined( __WATCOMC__ ) + struct tm tm; + time( &t ); + oTime = &tm; + localtime_r( &t, oTime ); +#else time( &t ); oTime = localtime( &t ); +#endif nValue = ( BYTE ) ( ( ( oTime->tm_year + 1900 ) - 1980 ) & ( 2 ^ 6 ) ); /* 6 bits */ szString[0] = nValue << 2; @@ -98,6 +131,7 @@ static ULONG PackDateTime( void ) szString[3] = nValue << 6; nValue = ( BYTE ) oTime->tm_sec; /* 6 bits */ szString[3] |= nValue; +#endif return HB_MKLONG( szString[3], szString[2], szString[1], szString[0] ); } diff --git a/harbour/source/compiler/ppcomp.c b/harbour/source/compiler/ppcomp.c index d07169b844..8d9f9d27cd 100644 --- a/harbour/source/compiler/ppcomp.c +++ b/harbour/source/compiler/ppcomp.c @@ -52,7 +52,6 @@ #include "hbcomp.h" -#include static void hb_pp_ErrorGen( void * cargo, const char * szMsgTable[], char cPrefix, int iErrorCode, diff --git a/harbour/source/pp/Makefile b/harbour/source/pp/Makefile index 796879c8fe..d3a39b1a21 100644 --- a/harbour/source/pp/Makefile +++ b/harbour/source/pp/Makefile @@ -22,5 +22,10 @@ endif include $(TOP)$(ROOT)config/lib.cf +ifneq ($(HB_PP_RULES),) +pptable.c : $(HB_PP_RULES) + $(CP) $(subst /,$(DIRSEP),$<) $@ +else pptable.c : ppgen$(EXE_EXT) $(HB_PPGEN_PATH)/ppgen$(EXE_EXT) $(TOP)$(ROOT)include/hbstdgen.ch -opptable.c -q +endif diff --git a/harbour/source/pp/ppcore.c b/harbour/source/pp/ppcore.c index ab57bd398e..7d23c5b96d 100644 --- a/harbour/source/pp/ppcore.c +++ b/harbour/source/pp/ppcore.c @@ -58,7 +58,9 @@ #include "hbpp.h" #include "hbdate.h" -#include +#if !defined(__MINGW32CE__) && !defined(HB_WINCE) +# include +#endif #define HB_PP_WARN_DEFINE_REDEF 1 /* C1005 */ @@ -1757,7 +1759,7 @@ static void hb_pp_defineDel( PHB_PP_STATE pState, PHB_PP_TOKEN pToken ) } static PHB_PP_FILE hb_pp_FileNew( PHB_PP_STATE pState, char * szFileName, - BOOL fSysFile, FILE * file_in, + BOOL fSysFile, BOOL * pfNested, FILE * file_in, BOOL fSearchPath, PHB_PP_OPEN_FUNC pOpenFunc ) { char szFileNameBuf[ _POSIX_PATH_MAX + 1 ]; @@ -1767,16 +1769,17 @@ static PHB_PP_FILE hb_pp_FileNew( PHB_PP_STATE pState, char * szFileName, { if( pOpenFunc ) { - file_in = ( pOpenFunc )( pState->cargo, szFileName, fSysFile, szFileNameBuf ); + file_in = ( pOpenFunc )( pState->cargo, szFileName, fSysFile, + pfNested, szFileNameBuf ); szFileName = szFileNameBuf; } else { PHB_FNAME pFileName = hb_fsFNameSplit( szFileName ); + BOOL fNested = FALSE; pFileName->szName = szFileName; pFileName->szExtension = NULL; - errno = 0; if( !fSysFile ) { if( !pFileName->szPath || !pFileName->szPath[ 0 ] ) @@ -1800,18 +1803,29 @@ static PHB_PP_FILE hb_pp_FileNew( PHB_PP_STATE pState, char * szFileName, } file_in = fopen( szFileName, "r" ); +#if !defined(__MINGW32CE__) && !defined(HB_WINCE) + fNested = errno == EMFILE; +#endif } - if( !file_in && errno != EMFILE && pState->pIncludePath && fSearchPath ) + if( !file_in ) { - HB_PATHNAMES * pPath = pState->pIncludePath; - - while( pPath && !file_in ) + if( fNested ) { - pFileName->szPath = pPath->szPath; - hb_fsFNameMerge( szFileNameBuf, pFileName ); - file_in = fopen( szFileNameBuf, "r" ); - pPath = pPath->pNext; + if( pfNested ) + * pfNested = TRUE; + } + else if( pState->pIncludePath && fSearchPath ) + { + HB_PATHNAMES * pPath = pState->pIncludePath; + + while( pPath && !file_in ) + { + pFileName->szPath = pPath->szPath; + hb_fsFNameMerge( szFileNameBuf, pFileName ); + file_in = fopen( szFileNameBuf, "r" ); + pPath = pPath->pNext; + } } } hb_xfree( pFileName ); @@ -1962,8 +1976,9 @@ static void hb_pp_includeFile( PHB_PP_STATE pState, char * szFileName, BOOL fSys } else { - PHB_PP_FILE pFile = hb_pp_FileNew( pState, szFileName, fSysFile, NULL, - TRUE, pState->pOpenFunc ); + BOOL fNested = FALSE; + PHB_PP_FILE pFile = hb_pp_FileNew( pState, szFileName, fSysFile, &fNested, + NULL, TRUE, pState->pOpenFunc ); if( pFile ) { pFile->pPrev = pState->pFile; @@ -1971,7 +1986,7 @@ static void hb_pp_includeFile( PHB_PP_STATE pState, char * szFileName, BOOL fSys pState->iFiles++; pFile->fGenLineInfo = TRUE; } - else if( errno == EMFILE ) + else if( fNested ) hb_pp_error( pState, 'F', HB_PP_ERR_NESTED_INCLUDES, NULL ); else hb_pp_error( pState, 'F', HB_PP_ERR_CANNOT_OPEN_FILE, szFileName ); @@ -5128,7 +5143,7 @@ void hb_pp_readRules( PHB_PP_STATE pState, const char * szRulesFile ) hb_fsFNameMerge( szFileName, pFileName ); hb_xfree( pFileName ); - pState->pFile = hb_pp_FileNew( pState, szFileName, FALSE, NULL, + pState->pFile = hb_pp_FileNew( pState, szFileName, FALSE, NULL, NULL, TRUE, pState->pOpenFunc ); if( !pState->pFile ) { @@ -5179,7 +5194,7 @@ BOOL hb_pp_inFile( PHB_PP_STATE pState, const char * szFileName, pState->fError = FALSE; - pState->pFile = hb_pp_FileNew( pState, ( char * ) szFileName, FALSE, + pState->pFile = hb_pp_FileNew( pState, ( char * ) szFileName, FALSE, NULL, file_in, fSearchPath, NULL ); if( pState->pFile ) { diff --git a/harbour/source/pp/ppgen.c b/harbour/source/pp/ppgen.c index 2bbbce70bb..0ac9f1e51c 100644 --- a/harbour/source/pp/ppgen.c +++ b/harbour/source/pp/ppgen.c @@ -54,6 +54,9 @@ #include "ppcore.c" +#if defined(__MINGW32CE__) || defined(HB_WINCE) +#include +#endif /* * library functions used by PP core code @@ -275,7 +278,9 @@ static int hb_pp_preprocesfile( PHB_PP_STATE pState, char * szRuleFile ) foutr = fopen( szRuleFile, "w" ); if( !foutr ) { +#if !defined(__MINGW32CE__) && !defined(HB_WINCE) perror( szRuleFile ); +#endif iResult = 1; } else @@ -302,12 +307,27 @@ static void hb_pp_usage( char * szName ) " -q \tdisable information messages\n" ); } +#if defined(__MINGW32CE__) || defined(HB_WINCE) +int WINAPI WinMain( HINSTANCE hInstance, /* handle to current instance */ + HINSTANCE hPrevInstance, /* handle to previous instance */ + LPWSTR lpCmdLine, /* pointer to command line */ + int iCmdShow ) /* show state of window */ +{ + char * szFile = NULL, * szRuleFile = NULL; + BOOL fQuiet = FALSE, fWrite = FALSE; + PHB_PP_STATE pState; + int iResult, i; + /* hack - we do not want to create real binaries */ + int argc = 1; + char * argv[] = {"ppgen"}; +#else int main( int argc, char * argv[] ) { char * szFile = NULL, * szRuleFile = NULL; BOOL fQuiet = FALSE, fWrite = FALSE; PHB_PP_STATE pState; int iResult, i; +#endif pState = hb_pp_new(); diff --git a/harbour/source/rtl/diskspac.c b/harbour/source/rtl/diskspac.c index 1962fbc74e..e754d5e235 100644 --- a/harbour/source/rtl/diskspac.c +++ b/harbour/source/rtl/diskspac.c @@ -67,7 +67,7 @@ #if defined(HB_OS_UNIX) # include # include -# if defined(__WATCOMC__) +# if defined(__WATCOMC__) || defined(__CEGCC__) # include # else # include @@ -117,6 +117,7 @@ HB_FUNC( DISKSPACE ) SetLastError( 0 ); +#if !defined(__MINGW32CE__) && !defined(HB_WINCE) pGetDiskFreeSpaceEx = ( P_GDFSE ) GetProcAddress( GetModuleHandle( "kernel32.dll" ), "GetDiskFreeSpaceExA"); @@ -156,6 +157,7 @@ HB_FUNC( DISKSPACE ) } } else +#endif { DWORD dwSectorsPerCluster; DWORD dwBytesPerSector; @@ -203,7 +205,7 @@ HB_FUNC( DISKSPACE ) szName = ( char * ) hb_fsNameConv( ( BYTE * ) szName, &fFree ); { -#if defined(__WATCOMC__) +#if defined(__WATCOMC__) || defined(__CEGCC__) struct stat st; if( stat( szName, &st) == 0 ) dSpace = ( double ) st.st_blocks * ( double ) st.st_blksize; diff --git a/harbour/source/rtl/disksphb.c b/harbour/source/rtl/disksphb.c index af08999686..bb345e6db0 100644 --- a/harbour/source/rtl/disksphb.c +++ b/harbour/source/rtl/disksphb.c @@ -62,7 +62,7 @@ #include "hbapierr.h" #include "hbapifs.h" -#if defined( HB_OS_UNIX ) && !defined( __WATCOMC__ ) +#if defined( HB_OS_UNIX ) && !( defined( __WATCOMC__ ) || defined( __CEGCC__ ) ) #include #endif @@ -163,6 +163,7 @@ HB_FUNC( HB_DISKSPACE ) SetLastError( 0 ); +#if !defined(__MINGW32CE__) && !defined(HB_WINCE) pGetDiskFreeSpaceEx = ( P_GDFSE ) GetProcAddress( GetModuleHandle( "kernel32.dll" ), "GetDiskFreeSpaceExA"); @@ -231,6 +232,7 @@ HB_FUNC( HB_DISKSPACE ) } } else +#endif { DWORD dwSectorsPerCluster; DWORD dwBytesPerSector; @@ -327,7 +329,7 @@ HB_FUNC( HB_DISKSPACE ) else hb_fsSetIOError( FALSE, 0 ); } -#elif defined(HB_OS_UNIX) && !defined(__WATCOMC__) +#elif defined(HB_OS_UNIX) && !( defined(__WATCOMC__) || defined(__CEGCC__) ) { struct statvfs sf; BOOL fFree = FALSE; diff --git a/harbour/source/rtl/filesys.c b/harbour/source/rtl/filesys.c index 5bc58c8e26..6614f6bffe 100644 --- a/harbour/source/rtl/filesys.c +++ b/harbour/source/rtl/filesys.c @@ -123,13 +123,14 @@ #if ( defined(__DMC__) || defined(__BORLANDC__) || defined(__IBMCPP__) || defined(_MSC_VER) || \ defined(__MINGW32__) || defined(__WATCOMC__) ) && !defined( HB_OS_UNIX ) #include + #include + #include #if !defined( __POCC__ ) && !defined( __XCC__ ) #include #endif - #include - #include - #include - #include + #if !defined(__MINGW32CE__) + #include + #endif #if defined(__BORLANDC__) #include #include @@ -153,7 +154,6 @@ #include #include #include - #include #if defined(__CYGWIN__) #include #elif defined(__DJGPP__) @@ -1182,10 +1182,7 @@ HB_EXPORT void hb_fsCommit( FHANDLE hFileHandle ) #elif defined(HB_OS_OS2) { - errno = 0; - /* TODO: what about error code from DosResetBuffer() call? */ - DosResetBuffer( hFileHandle ); - hb_fsSetIOError( errno == 0, 0 ); + hb_fsSetIOError( DosResetBuffer( hFileHandle ) == 0, 0 ); } #elif defined(HB_OS_UNIX) diff --git a/harbour/source/rtl/fserror.c b/harbour/source/rtl/fserror.c index 077ffb3730..40660a419f 100644 --- a/harbour/source/rtl/fserror.c +++ b/harbour/source/rtl/fserror.c @@ -57,7 +57,9 @@ #include "hbapi.h" #include "hbapifs.h" #include "hb_io.h" -#include +#if !defined(__MINGW32CE__) +# include +#endif static USHORT s_uiFError = 0; static USHORT s_uiErrorLast = 0; diff --git a/harbour/source/rtl/fssize.c b/harbour/source/rtl/fssize.c index 42e439adf6..bbf4797e53 100644 --- a/harbour/source/rtl/fssize.c +++ b/harbour/source/rtl/fssize.c @@ -58,12 +58,12 @@ #include "hbapi.h" #include "hbapifs.h" -#include #include #include HB_FOFFSET hb_fsFSize( BYTE * pszFileName, BOOL bUseDirEntry ) { +#if !defined(__MINGW32CE__) && !defined(HB_WINCE) if( bUseDirEntry ) { BOOL fResult; @@ -84,6 +84,7 @@ HB_FOFFSET hb_fsFSize( BYTE * pszFileName, BOOL bUseDirEntry ) return ( HB_FOFFSET ) statbuf.st_size; } else +#endif { FHANDLE hFileHandle = hb_fsOpen( pszFileName, 0 ); diff --git a/harbour/source/rtl/gtchrmap.c b/harbour/source/rtl/gtchrmap.c index 2c1e5f22b8..7e0f894694 100644 --- a/harbour/source/rtl/gtchrmap.c +++ b/harbour/source/rtl/gtchrmap.c @@ -403,24 +403,30 @@ static int hb_gt_chrmapread( const char *pszFile, const char *pszTerm, int *nTra int hb_gt_chrmapinit( int *piTransTbl, const char *pszTerm, BOOL fSetACSC ) { - char *pszFile, szFile[ _POSIX_PATH_MAX + 1 ]; + char *pszFree = NULL, *pszFile, szFile[ _POSIX_PATH_MAX + 1 ]; int nRet = -1; chrmap_init( piTransTbl ); if( pszTerm == NULL || *pszTerm == '\0' ) - pszTerm = getenv("HB_TERM"); + pszTerm = pszFree = hb_getenv("HB_TERM"); if( pszTerm == NULL || *pszTerm == '\0' ) - pszTerm = getenv("TERM"); + { + if( pszFree ) + hb_xfree( pszFree ); + pszTerm = pszFree = hb_getenv("TERM"); + } if( pszTerm != NULL && *pszTerm != '\0' ) { - pszFile = getenv( "HB_CHARMAP" ); + pszFile = hb_getenv( "HB_CHARMAP" ); if( pszFile != NULL && *pszFile != '\0' ) nRet = hb_gt_chrmapread( pszFile, pszTerm, piTransTbl ); if( nRet == -1 ) { - pszFile = getenv( "HB_ROOT" ); + if( pszFile ) + hb_xfree( pszFile ); + pszFile = hb_getenv( "HB_ROOT" ); if( pszFile != NULL && sizeof( szFile ) > strlen( pszFile ) + strlen( s_szDefaultCharMapFile ) ) { @@ -429,10 +435,15 @@ int hb_gt_chrmapinit( int *piTransTbl, const char *pszTerm, BOOL fSetACSC ) nRet = hb_gt_chrmapread( szFile, pszTerm, piTransTbl ); } } + if( pszFile ) + hb_xfree( pszFile ); if( nRet == -1 ) nRet = hb_gt_chrmapread( s_szDefaultCharMapFile, pszTerm, piTransTbl ); } + if( pszFree ) + hb_xfree( pszFree ); + if( nRet == -1 ) { chrmap_dotctrl( piTransTbl ); diff --git a/harbour/source/rtl/gttone.c b/harbour/source/rtl/gttone.c index 90515d5762..72cd38b4c3 100644 --- a/harbour/source/rtl/gttone.c +++ b/harbour/source/rtl/gttone.c @@ -66,13 +66,14 @@ #if defined( HB_OS_WIN_32 ) -#if defined(_MSC_VER) || defined(__WATCOMC__) - #include -#endif - -#if defined( HB_ARCH_32BIT ) && \ +#if defined( HB_ARCH_32BIT ) && !defined( _M_ARM ) && \ ( defined(__BORLANDC__) || defined(_MSC_VER) || \ defined(__WATCOMC__) || defined(__MINGW32__) ) + +#if defined(_MSC_VER) || defined(__WATCOMC__) + #include +#endif + static int hb_Inp9x( USHORT usPort ) { USHORT usVal; @@ -258,7 +259,7 @@ void hb_gt_w32_Tone( double dFrequency, double dDuration ) /* If Windows 95 or 98, use w9xTone for BCC32, MSVC */ if( s_osv.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) { - #if defined( HB_ARCH_32BIT ) && \ + #if defined( HB_ARCH_32BIT ) && !defined( _M_ARM ) && \ ( defined( __BORLANDC__ ) || defined( _MSC_VER ) || \ defined( __WATCOMC__ ) || defined(__MINGW32__) ) hb_gt_w9xTone( dFrequency, dDuration ); diff --git a/harbour/source/rtl/gtwvt/gtwvt.c b/harbour/source/rtl/gtwvt/gtwvt.c index 30f79f649c..735370e574 100644 --- a/harbour/source/rtl/gtwvt/gtwvt.c +++ b/harbour/source/rtl/gtwvt/gtwvt.c @@ -86,10 +86,6 @@ #include "gtwvt.h" -#if defined(_MSC_VER) - #include -#endif - static HB_GT_FUNCS SuperTable; #define HB_GTSUPER (&SuperTable) diff --git a/harbour/source/rtl/hbffind.c b/harbour/source/rtl/hbffind.c index f32826cc18..97e838102e 100644 --- a/harbour/source/rtl/hbffind.c +++ b/harbour/source/rtl/hbffind.c @@ -76,7 +76,6 @@ HB_FILE_VER( "$Id$" ) #if defined(__DJGPP__) || defined(__RSX32__) #include - #include #endif #if defined(__DJGPP__) || defined(__RSX32__) || defined(__BORLANDC__) #include @@ -127,8 +126,6 @@ HB_FILE_VER( "$Id$" ) #elif defined(HB_OS_WIN_32) - #include - typedef struct { HANDLE hFindFile; @@ -147,7 +144,6 @@ HB_FILE_VER( "$Id$" ) #include #include #include - #include #include #include diff --git a/harbour/source/rtl/hbinet.c b/harbour/source/rtl/hbinet.c index 9123947c96..5dbb24090d 100644 --- a/harbour/source/rtl/hbinet.c +++ b/harbour/source/rtl/hbinet.c @@ -61,7 +61,6 @@ #include "hbapiitm.h" #include "hbapierr.h" - /* HB_INET_H_ */ #if defined( HB_OS_DOS ) @@ -71,6 +70,8 @@ #else + #include + #if defined( HB_OS_WIN_32 ) #define _WINSOCKAPI_ /* Prevents inclusion of Winsock.h in Windows.h */ #define HB_SOCKET_T SOCKET @@ -170,7 +171,9 @@ #if !defined( HB_NO_DEFAULT_INET ) #include -#include +#if !defined(__MINGW32CE__) + #include +#endif #if defined( HB_OS_UNIX ) || defined( OS_UNIX_COMPATIBLE ) || defined( HB_OS_BSD ) || defined(HB_OS_OS2) #include @@ -1513,6 +1516,9 @@ HB_FUNC( HB_INETSERVER ) HB_FUNC( HB_INETACCEPT ) { +#if !defined(EAGAIN) +#define EAGAIN -1 +#endif HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 1 ); HB_SOCKET_STRUCT *NewSocket; HB_SOCKET_T incoming = 0; diff --git a/harbour/source/vm/mainwin.c b/harbour/source/vm/mainwin.c index 4c3ab9dcaa..3fddf6f8c5 100644 --- a/harbour/source/vm/mainwin.c +++ b/harbour/source/vm/mainwin.c @@ -73,9 +73,15 @@ static int s_argc = 0; static char * s_argv[ MAX_ARGS ]; static char s_szAppName[ 256 ]; +#if defined(__MINGW32CE__) || defined(HB_WINCE) +# define HB_SYSSTR LPWSTR +#else +# define HB_SYSSTR LPSTR +#endif + int WINAPI WinMain( HINSTANCE hInstance, /* handle to current instance */ HINSTANCE hPrevInstance, /* handle to previous instance */ - LPSTR lpCmdLine, /* pointer to command line */ + HB_SYSSTR lpCmdLine, /* pointer to command line */ int iCmdShow ) /* show state of window */ { LPSTR pArgs, pArg, pDst, pSrc; @@ -97,9 +103,14 @@ int WINAPI WinMain( HINSTANCE hInstance, /* handle to current instance */ GetModuleFileName( hInstance, s_szAppName, sizeof( s_szAppName ) - 1 ); s_argv[ s_argc++ ] = s_szAppName; - pDst = pArgs = ( LPSTR ) LocalAlloc( LMEM_FIXED, strlen( lpCmdLine ) + 1 ); pArg = NULL; +#if defined(__MINGW32CE__) || defined(HB_WINCE) + pDst = pArgs = ( LPSTR ) LocalAlloc( LMEM_FIXED, strlen( ( LPSTR ) lpCmdLine ) + 1 ); + pSrc = ( LPSTR ) lpCmdLine; +#else + pDst = pArgs = ( LPSTR ) LocalAlloc( LMEM_FIXED, strlen( lpCmdLine ) + 1 ); pSrc = lpCmdLine; +#endif fQuoted = FALSE; while( *pSrc != 0 && s_argc < MAX_ARGS ) diff --git a/harbour/utils/hbpp/hbppcore.c b/harbour/utils/hbpp/hbppcore.c index 62694c387d..66bcd086d2 100644 --- a/harbour/utils/hbpp/hbppcore.c +++ b/harbour/utils/hbpp/hbppcore.c @@ -76,7 +76,9 @@ #endif #include -#include +#if !defined(__MINGW32CE__) +# include +#endif #include "hbppdef.h" #include "hbcomp.h" @@ -557,11 +559,13 @@ int hb_pp_ParseDirective_( char *sLine ) if( !OpenInclude( sLine, hb_comp_pIncludePath, hb_comp_pFileName, ( cDelimChar == '>' ), szInclude ) ) { +#if !defined(__MINGW32CE__) if( errno == 0 || errno == EMFILE ) hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_TOO_MANY_INCLUDES, sLine, NULL ); else +#endif { -#if defined(__CYGWIN__) || defined(__IBMCPP__) || defined(__LCC__) +#if defined(__CYGWIN__) || defined(__MINGW32CE__) || defined(__IBMCPP__) || defined(__LCC__) hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_CANNOT_OPEN, sLine, "" ); #else hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_CANNOT_OPEN, sLine, strerror( errno ) ); @@ -4734,7 +4738,9 @@ static BOOL OpenInclude( char *szFileName, HB_PATHNAMES * pSearch, PHB_FNAME pMa HB_TRACE( HB_TR_DEBUG, ( "OpenInclude(%s, %p, %p, %d, %s)", szFileName, pSearch, pMainFileName, ( int ) bStandardOnly, szInclude ) ); +#if !defined(__MINGW32CE__) errno = 0; +#endif if( bStandardOnly ) { fptr = 0; @@ -4753,7 +4759,11 @@ static BOOL OpenInclude( char *szFileName, HB_PATHNAMES * pSearch, PHB_FNAME pMa hb_xfree( pFileName ); } +#if defined(__MINGW32CE__) + if( !fptr && pSearch ) +#else if( !fptr && pSearch && errno != EMFILE ) +#endif { pFileName = hb_fsFNameSplit( szFileName ); pFileName->szName = szFileName; diff --git a/harbour/utils/hbver/hbverfix.c b/harbour/utils/hbver/hbverfix.c index 53bb5b8b81..6e517c26be 100644 --- a/harbour/utils/hbver/hbverfix.c +++ b/harbour/utils/hbver/hbverfix.c @@ -60,9 +60,11 @@ #endif #include -#include #include #include +#if ! defined(__MINGW32CE__) +# include +#endif #include "hbcomp.h" @@ -208,6 +210,10 @@ int main( int argc, char * argv[] ) fhChangeLog = fopen( cszChangeLogName, "rt" ); if( fhChangeLog == NULL ) { +#if defined(__MINGW32CE__) + fprintf( stderr, "error: %s\n", szErrBuf ); + return 4; +#else switch( errno ) { case ENOENT: @@ -217,6 +223,7 @@ int main( int argc, char * argv[] ) perror( szErrBuf ); return 4; } +#endif } while( ! ( bFoundID && bFoundLog ) && ! feof( fhChangeLog ) ) {