From 07671ae2f3637d762ed0c863ce9864d39cd3e92c Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Mon, 26 Oct 2009 14:29:12 +0000 Subject: [PATCH] 2009-10-26 15:29 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/hbqt/qtcore/QLocale.cpp * harbour/contrib/hbqt/qtcore/QByteArray.cpp ! fixed casting for 64bit builds - in all 64bit builds except Win64 LONG is 64bit integer and HB_LONG is declared as LONG not LONGLONG * harbour/contrib/hbwin/win_dll.c % minor optimization * removed unnecessary casting --- harbour/ChangeLog | 10 +++++++ harbour/contrib/hbqt/qtcore/QByteArray.cpp | 4 +-- harbour/contrib/hbqt/qtcore/QLocale.cpp | 4 +-- harbour/contrib/hbwin/win_dll.c | 31 ++++++++++++---------- 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 79a933c5e2..6f716740ba 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,16 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-10-26 15:29 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/contrib/hbqt/qtcore/QLocale.cpp + * harbour/contrib/hbqt/qtcore/QByteArray.cpp + ! fixed casting for 64bit builds - in all 64bit builds except Win64 + LONG is 64bit integer and HB_LONG is declared as LONG not LONGLONG + + * harbour/contrib/hbwin/win_dll.c + % minor optimization + * removed unnecessary casting + 2009-10-26 14:18 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * src/vm/maindllp.c ! Using hb_getProcAddress() instead of GetProcAddress(). diff --git a/harbour/contrib/hbqt/qtcore/QByteArray.cpp b/harbour/contrib/hbqt/qtcore/QByteArray.cpp index b4a3fc28c9..8f41d6e43d 100644 --- a/harbour/contrib/hbqt/qtcore/QByteArray.cpp +++ b/harbour/contrib/hbqt/qtcore/QByteArray.cpp @@ -684,7 +684,7 @@ HB_FUNC( QT_QBYTEARRAY_SETNUM_3 ) */ HB_FUNC( QT_QBYTEARRAY_SETNUM_4 ) { - hb_retptrGC( hbqt_ptrTOgcpointer( new QByteArray( hbqt_par_QByteArray( 1 )->setNum( hb_parnint( 2 ), ( HB_ISNUM( 3 ) ? hb_parni( 3 ) : 10 ) ) ), release_QByteArray ) ); + hb_retptrGC( hbqt_ptrTOgcpointer( new QByteArray( hbqt_par_QByteArray( 1 )->setNum( ( qulonglong ) hb_parnint( 2 ), ( HB_ISNUM( 3 ) ? hb_parni( 3 ) : 10 ) ) ), release_QByteArray ) ); } /* @@ -692,7 +692,7 @@ HB_FUNC( QT_QBYTEARRAY_SETNUM_4 ) */ HB_FUNC( QT_QBYTEARRAY_SETNUM_5 ) { - hb_retptrGC( hbqt_ptrTOgcpointer( new QByteArray( hbqt_par_QByteArray( 1 )->setNum( hb_parnint( 2 ), ( HB_ISNUM( 3 ) ? hb_parni( 3 ) : 10 ) ) ), release_QByteArray ) ); + hb_retptrGC( hbqt_ptrTOgcpointer( new QByteArray( hbqt_par_QByteArray( 1 )->setNum( ( qulonglong ) hb_parnint( 2 ), ( HB_ISNUM( 3 ) ? hb_parni( 3 ) : 10 ) ) ), release_QByteArray ) ); } /* diff --git a/harbour/contrib/hbqt/qtcore/QLocale.cpp b/harbour/contrib/hbqt/qtcore/QLocale.cpp index a3bcc12be8..bfa32113a7 100644 --- a/harbour/contrib/hbqt/qtcore/QLocale.cpp +++ b/harbour/contrib/hbqt/qtcore/QLocale.cpp @@ -347,7 +347,7 @@ HB_FUNC( QT_QLOCALE_TOSHORT ) */ HB_FUNC( QT_QLOCALE_TOSTRING ) { - hb_retc( hbqt_par_QLocale( 1 )->toString( hb_parnint( 2 ) ).toAscii().data() ); + hb_retc( hbqt_par_QLocale( 1 )->toString( ( qulonglong ) hb_parnint( 2 ) ).toAscii().data() ); } /* @@ -403,7 +403,7 @@ HB_FUNC( QT_QLOCALE_TOSTRING_6 ) */ HB_FUNC( QT_QLOCALE_TOSTRING_7 ) { - hb_retc( hbqt_par_QLocale( 1 )->toString( hb_parnint( 2 ) ).toAscii().data() ); + hb_retc( hbqt_par_QLocale( 1 )->toString( ( qulonglong ) hb_parnint( 2 ) ).toAscii().data() ); } /* diff --git a/harbour/contrib/hbwin/win_dll.c b/harbour/contrib/hbwin/win_dll.c index e8cc398e36..7f239036d2 100644 --- a/harbour/contrib/hbwin/win_dll.c +++ b/harbour/contrib/hbwin/win_dll.c @@ -743,13 +743,13 @@ static LPVOID hb_getprocaddress( HMODULE hDLL, int iProc ) HB_SYMBOL_UNUSED( iProc ); return NULL; #else - LPVOID lpFunction = ( LPVOID ) GetProcAddress( hDLL, HB_ISCHAR( iProc ) ? ( LPCSTR ) hb_parc( iProc ) : ( LPCSTR ) ( HB_PTRDIFF ) hb_parnint( iProc ) ); + const char * szProc = hb_parc( iProc ); + LPVOID lpFunction = ( LPVOID ) GetProcAddress( hDLL, szProc ? szProc : ( LPCSTR ) ( HB_PTRDIFF ) hb_parnint( iProc ) ); - if( ! lpFunction && HB_ISCHAR( iProc ) ) /* try with ANSI suffix? */ + if( ! lpFunction && szProc ) /* try with ANSI suffix? */ { - char * pszFuncName = ( char * ) hb_xgrab( hb_parclen( iProc ) + 2 ); - hb_strncpy( pszFuncName, hb_parc( iProc ), hb_parclen( iProc ) ); - lpFunction = ( LPVOID ) GetProcAddress( hDLL, hb_strncat( pszFuncName, "A", hb_parclen( iProc ) + 1 ) ); + char * pszFuncName = hb_xstrcpy( NULL, szProc, "A", NULL ); + lpFunction = ( LPVOID ) GetProcAddress( hDLL, pszFuncName ); hb_xfree( pszFuncName ); } @@ -761,7 +761,7 @@ HB_FUNC( LOADLIBRARY ) { LPTSTR lpName = HB_TCHAR_CONVTO( hb_parcx( 1 ) ); - hb_retnint( ( HB_PTRDIFF ) LoadLibrary( ( LPCTSTR ) lpName ) ); + hb_retnint( ( HB_PTRDIFF ) LoadLibrary( lpName ) ); HB_TCHAR_FREE( lpName ); } @@ -812,7 +812,7 @@ HB_FUNC( DLLCALL ) { LPTSTR lpName = HB_TCHAR_CONVTO( hb_parcx( 1 ) ); - hDLL = LoadLibrary( ( LPCTSTR ) lpName ); + hDLL = LoadLibrary( lpName ); HB_TCHAR_FREE( lpName ); } @@ -836,11 +836,11 @@ HB_FUNC( DLLPREPARECALL ) if( HB_ISCHAR( 1 ) ) { - LPTSTR lpName = HB_TCHAR_CONVTO( hb_parc( 1 ) ); + LPTSTR lpName; xec->cDLL = hb_strdup( hb_parc( 1 ) ); - xec->hDLL = LoadLibrary( ( LPCTSTR ) lpName ); - + lpName = HB_TCHAR_CONVTO( xec->cDLL ); + xec->hDLL = LoadLibrary( lpName ); HB_TCHAR_FREE( lpName ); } else if( HB_ISPOINTER( 1 ) ) @@ -850,18 +850,21 @@ HB_FUNC( DLLPREPARECALL ) if( xec->hDLL ) { + ULONG ulLen = 0; + if( HB_ISCHAR( 3 ) ) { - xec->cProc = ( char * ) hb_xgrab( hb_parclen( 3 ) + 2 ); /* Reserving space for possible ANSI "A" suffix. */ - hb_strncpy( xec->cProc, hb_parc( 3 ), hb_parclen( 3 ) ); + ulLen = hb_parclen( 3 ) + 1; + xec->cProc = ( char * ) hb_xgrab( ulLen + 1 ); /* Reserving space for possible ANSI "A" suffix. */ + hb_strncpy( xec->cProc, hb_parc( 3 ), ulLen ); } else if( HB_ISNUM( 3 ) ) xec->wOrdinal = ( WORD ) hb_parni( 3 ); - xec->lpFunc = ( LPVOID ) GetProcAddress( xec->hDLL, xec->cProc ? ( LPCSTR ) xec->cProc : ( LPCSTR ) ( HB_PTRDIFF ) xec->wOrdinal ); + xec->lpFunc = ( LPVOID ) GetProcAddress( xec->hDLL, xec->cProc ? xec->cProc : ( LPCSTR ) ( HB_PTRDIFF ) xec->wOrdinal ); if( ! xec->lpFunc && xec->cProc ) /* try with ANSI suffix? */ - xec->lpFunc = ( LPVOID ) GetProcAddress( xec->hDLL, ( LPCSTR ) hb_strncat( xec->cProc, "A", hb_parclen( 3 ) + 1 ) ); + xec->lpFunc = ( LPVOID ) GetProcAddress( xec->hDLL, hb_strncat( xec->cProc, "A", ulLen ) ); if( xec->lpFunc ) {