diff --git a/harbour/ChangeLog b/harbour/ChangeLog index f29277b43b..ab31bd5e03 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,27 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-11-27 00:12 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/bin/pack_src.sh + * updated for recent file name modifications + + * harbour/include/hbgtcore.h + * harbour/source/rtl/gtclip.c + * changed hb_gt_w32_SetClipboard() type from void to BOOL + + * harbour/source/rtl/gtstd/gtstd.c + * harbour/source/rtl/gtpca/gtpca.c + * added basic input support for DJGPP + + * harbour/contrib/gtwvg/gtwvt.c + ! fixed memory leak and GPF trap + + * harbour/contrib/gtwvg/wvtutils.c + ! rewritten and fixed CLIPBOARD functions - Pritpal this functions + should be removed, they are redundant and works only in MS-Windows + * make WVT__GETOPENFILENAME() and WVT__GETSAVEFILENAME() Unicode + ready and fixed possible GPF trap + 2007-11-26 22:09 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/mtpl_b32.bat * contrib/mtpl_vc.bat diff --git a/harbour/bin/pack_src.sh b/harbour/bin/pack_src.sh index 987e1f2ea3..af0fef9d1b 100755 --- a/harbour/bin/pack_src.sh +++ b/harbour/bin/pack_src.sh @@ -414,7 +414,8 @@ $hb_collect contrib/mysql/*.bat # CONTRIB\GD $hb_collect contrib/gd/[mM]akefile* $hb_collect contrib/gd/Change[Ll]og* -$hb_collect contrib/gd/README +$hb_collect contrib/gd/README* +$hb_collect contrib/gd/readme* $hb_collect contrib/gd/*.[ch] $hb_collect contrib/gd/include/*.[ch] $hb_collect contrib/gd/*.ch diff --git a/harbour/contrib/gtwvg/gtwvt.c b/harbour/contrib/gtwvg/gtwvt.c index fdccb30724..4bec367e34 100644 --- a/harbour/contrib/gtwvg/gtwvt.c +++ b/harbour/contrib/gtwvg/gtwvt.c @@ -684,7 +684,7 @@ static void hb_gt_wvt_MouseEvent( HWND hWnd, UINT message, WPARAM wParam, LPARAM if( keyCode != 0 ) { - if( _s.pSymWVT_MOUSE && keyCode != 0 ) + if( _s.pSymWVT_MOUSE ) { if( hb_vmRequestReenter() ) { @@ -1619,7 +1619,7 @@ static void hb_wvt_gtCreateToolTipWindow( void ) ti.hwnd = _s.hWnd; ti.uId = 100000; ti.hinst = ( HINSTANCE ) s_hInstance; - ti.lpszText = HB_TCHAR_CONVTO( "" ); + ti.lpszText = TEXT( "" ); ti.rect.left = ti.rect.top = ti.rect.bottom = ti.rect.right = 0; /* Add the tool to the control, displaying an error if needed. */ @@ -1805,7 +1805,7 @@ int HB_EXPORT hb_wvt_gtGetWindowTitle( char * cTitle, int length ) //-------------------------------------------------------------------// -void HB_EXPORT hb_wvt_gtAddCharToInputQueue ( int iKey ) +void HB_EXPORT hb_wvt_gtAddCharToInputQueue( int iKey ) { hb_gt_wvt_AddCharToInputQueue( iKey ); } diff --git a/harbour/contrib/gtwvg/wvtutils.c b/harbour/contrib/gtwvg/wvtutils.c index bfd39ad1bc..ec60313174 100644 --- a/harbour/contrib/gtwvg/wvtutils.c +++ b/harbour/contrib/gtwvg/wvtutils.c @@ -167,9 +167,9 @@ HB_FUNC( WVT_CHOOSEFONT ) cf.rgbColors = RGB( 0,0,0 ); cf.lCustData = 0L; cf.lpfnHook = ( LPCFHOOKPROC ) NULL; - cf.lpTemplateName = ( LPSTR ) NULL; + cf.lpTemplateName = ( LPTSTR ) NULL; cf.hInstance = ( HINSTANCE ) NULL; - cf.lpszStyle = ( LPSTR ) NULL; + cf.lpszStyle = ( LPTSTR ) NULL; cf.nFontType = SCREEN_FONTTYPE; cf.nSizeMin = 0; cf.nSizeMax = 0; @@ -292,6 +292,8 @@ HB_FUNC( WVT_SETTOOLTIP ) if ( SendMessage( _s->hWndTT, TTM_GETTOOLINFO, 0, ( LPARAM ) &ti ) ) { + LPTSTR text = HB_TCHAR_CONVTO( hb_parcx( 5 ) ); + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); iTop = xy.y; iLeft = xy.x; @@ -300,13 +302,16 @@ HB_FUNC( WVT_SETTOOLTIP ) iBottom = xy.y - 1; iRight = xy.x - 1; - HB_TCHAR_CPTO( ti.lpszText, hb_parc( 5 ), sizeof( ti.lpszText )-1 ); + ti.lpszText = text; + ti.rect.left = iLeft; ti.rect.top = iTop; ti.rect.right = iRight; ti.rect.bottom = iBottom; SendMessage( _s->hWndTT, TTM_SETTOOLINFO, 0, ( LPARAM ) &ti ); + + HB_TCHAR_FREE( text ); } } @@ -322,9 +327,10 @@ HB_FUNC( WVT_SETTOOLTIPTEXT ) if ( SendMessage( _s->hWndTT, TTM_GETTOOLINFO, 0, ( LPARAM ) &ti ) ) { - HB_TCHAR_CPTO( ti.lpszText, hb_parc( 1 ), sizeof( ti.lpszText )-1 ); - //ti.lpszText = hb_parc( 1 ); + LPTSTR text = HB_TCHAR_CONVTO( hb_parcx( 1 ) ); + ti.lpszText = text; SendMessage( _s->hWndTT, TTM_UPDATETIPTEXT, 0, ( LPARAM ) &ti ); + HB_TCHAR_FREE( text ); } } @@ -999,124 +1005,43 @@ HB_FUNC( WVT_GETRGBCOLOR ) HB_FUNC( WVT_GETCLIPBOARD ) { - HGLOBAL hglb; - LPTSTR lptstr; + char * szClipboardData; + ULONG ulLen; - if ( !IsClipboardFormatAvailable( CF_TEXT ) ) - { - hb_ret(); - } - - if ( !OpenClipboard( NULL ) ) - { - hb_ret(); - } - - hglb = GetClipboardData( CF_TEXT ); - if ( hglb != NULL ) - { - lptstr = ( LPSTR ) GlobalLock( hglb ); - if ( lptstr != NULL ) - { - hb_retc( lptstr ); - GlobalUnlock( hglb ); - } - } - CloseClipboard(); + if( hb_gt_w32_GetClipboard( _s->CodePage == OEM_CHARSET ? + CF_OEMTEXT : CF_TEXT, + &szClipboardData, &ulLen ) ) + { + hb_retclen_buffer( szClipboardData, ulLen ); + } } //-------------------------------------------------------------------// HB_FUNC( WVT_SETCLIPBOARD ) { - LPTSTR lptstrCopy; - HGLOBAL hglbCopy; - char * cText; - int nLen; - - if ( !IsClipboardFormatAvailable( CF_TEXT ) ) - { - hb_retl( FALSE ); - return; - } - - // Check params - // - if ( ! ISCHAR( 1 ) ) - { - hb_retl( FALSE ); - return; - } - - if ( ! OpenClipboard( NULL ) ) - { - hb_retl( FALSE ); - return; - } - EmptyClipboard(); - - // Get text from PRG - // - cText = hb_parc( 1 ); - nLen = hb_parclen( 1 ); - - // Allocate a global memory object for the text. - // - hglbCopy = GlobalAlloc( GMEM_MOVEABLE, ( nLen+1 ) * sizeof( TCHAR ) ); - if ( hglbCopy == NULL ) - { - CloseClipboard(); - hb_retl( FALSE ); - return; - } - - // Lock the handle and copy the text to the buffer. - // - lptstrCopy = ( LPSTR ) GlobalLock( hglbCopy ); - memcpy( lptstrCopy, cText, ( nLen+1 ) * sizeof( TCHAR ) ); - lptstrCopy[ nLen+1 ] = ( TCHAR ) 0; // null character - GlobalUnlock( hglbCopy ); - - // Place the handle on the clipboard. - // - SetClipboardData( CF_TEXT, hglbCopy ); - - CloseClipboard(); - hb_retl( TRUE ); + if( ISCHAR( 1 ) ) + hb_retl( hb_gt_w32_SetClipboard( _s->CodePage == OEM_CHARSET ? + CF_OEMTEXT : CF_TEXT, + hb_parc( 1 ), hb_parclen( 1 ) ) ); + else + hb_retl( FALSE ); } //-------------------------------------------------------------------// HB_FUNC( WVT_PASTEFROMCLIPBOARD ) { - HGLOBAL hglb; - LPTSTR lptstr; - ULONG ul; + char * szClipboardData; + ULONG ulLen, ul; - if ( !IsClipboardFormatAvailable( CF_TEXT ) ) + if( hb_gt_w32_GetClipboard( _s->CodePage == OEM_CHARSET ? + CF_OEMTEXT : CF_TEXT, + &szClipboardData, &ulLen ) ) { - hb_ret(); + for( ul = 0; ul < ulLen; ul++ ) + hb_wvt_gtAddCharToInputQueue( ( UCHAR ) szClipboardData[ ul ] ); } - - if ( !OpenClipboard( NULL ) ) - { - hb_ret(); - } - - hglb = GetClipboardData( CF_TEXT ); - if ( hglb != NULL ) - { - lptstr = ( LPSTR ) GlobalLock( hglb ); - if ( lptstr != NULL ) - { - for ( ul=0; ul < GlobalSize( hglb ); ul++ ) - { - hb_wvt_gtAddCharToInputQueue( ( int ) lptstr[ ul ] ); - } - GlobalUnlock( hglb ) ; - } - } - CloseClipboard(); } //-------------------------------------------------------------------// @@ -2298,77 +2223,101 @@ void wvt_Size2ArrayEx( SIZE *siz, PHB_ITEM aSize ) //----------------------------------------------------------------------// +#define HB_PARTSTR( n ) ( ISCHAR( n ) ? HB_TCHAR_CONVTO( hb_parc(n) ) : NULL ) +#define HB_PARTFREE( p ) do { if( p ) HB_TCHAR_FREE( p ); } while( 0 ) + HB_FUNC( WVT__GETOPENFILENAME ) { - int size = ( ISNIL( 2 ) ? 1024 : hb_parcsiz( 2 ) ); - OPENFILENAME ofn ; + OPENFILENAME ofn; + LPTSTR lpFileName, lpstrTitle, lpstrFilter, lpstrInitialDir, lpstrDefExt; + int size = hb_parclen( 2 ); - char * szFileName = ( char* ) hb_xgrab( size ); + size += size ? 1 : 1024; + lpFileName = ( LPTSTR ) hb_xgrab( size * sizeof( TCHAR ) ); + HB_TCHAR_CPTO( lpFileName, hb_parcx( 2 ), size - 1 ); + lpstrTitle = HB_PARTSTR( 3 ); + lpstrFilter = HB_PARTSTR( 4 ); + lpstrInitialDir = HB_PARTSTR( 6 ); + lpstrDefExt = HB_PARTSTR( 7 ); - strcpy( szFileName, ( ISNIL( 2 ) ? "" : hb_parc( 2 ) ) ); + ZeroMemory( &ofn, sizeof( ofn ) ); - ZeroMemory( &ofn, sizeof( ofn ) ); + ofn.hInstance = GetModuleHandle( NULL ) ; + ofn.lStructSize = sizeof( ofn ); + ofn.hwndOwner = ISNIL(1) ? GetActiveWindow() : (HWND) hb_parnl( 1 ) ; + ofn.lpstrTitle = lpstrTitle; + ofn.lpstrFilter = lpstrFilter; + ofn.Flags = ISNIL(5) ? OFN_SHOWHELP|OFN_NOCHANGEDIR : hb_parnl( 5 ) ; + ofn.lpstrInitialDir = lpstrInitialDir; + ofn.lpstrDefExt = lpstrDefExt; + ofn.nFilterIndex = ISNIL(8) ? 0 : (int) hb_parni( 8 ); + ofn.lpstrFile = lpFileName; + ofn.nMaxFile = size; - ofn.hInstance = GetModuleHandle( NULL ) ; - ofn.lStructSize = sizeof( ofn ); - ofn.hwndOwner = ISNIL(1) ? GetActiveWindow() : (HWND) hb_parnl( 1 ) ; - ofn.lpstrTitle = ISNIL(3) ? NULL : hb_parc( 3 ); - ofn.lpstrFilter = ISNIL(4) ? NULL : hb_parc( 4 ); - ofn.Flags = ISNIL(5) ? OFN_SHOWHELP|OFN_NOCHANGEDIR : hb_parnl( 5 ) ; - ofn.lpstrInitialDir = ISNIL(6) ? NULL : hb_parc( 6 ); - ofn.lpstrDefExt = ISNIL(7) ? NULL : hb_parc( 7 ); - ofn.nFilterIndex = ISNIL(8) ? 0 : (int) hb_parni( 8 ); - ofn.lpstrFile = szFileName; - ofn.nMaxFile = size; + if( GetOpenFileName( &ofn ) ) + { + char * szFileName = HB_TCHAR_CONVFROM( lpFileName ); - if( GetOpenFileName( &ofn ) ) - { hb_stornl( ofn.nFilterIndex, 8 ); hb_storclen( szFileName, size, 2 ) ; - hb_retclen( ( char * ) ofn.lpstrFile, size ); - } - else - { - hb_retc( "" ); - } - hb_xfree( szFileName ); + hb_retc( szFileName ); + + } + else + { + hb_retc( NULL ); + } + hb_xfree( lpFileName ); + HB_PARTFREE( lpstrTitle ); + HB_PARTFREE( lpstrFilter ); + HB_PARTFREE( lpstrInitialDir ); + HB_PARTFREE( lpstrDefExt ); } //----------------------------------------------------------------------// HB_FUNC( WVT__GETSAVEFILENAME ) { - HINSTANCE hInstance; OPENFILENAME ofn; - char szFileName[ MAX_PATH+1 ] ; + LPTSTR lpstrTitle, lpstrFilter, lpstrInitialDir, lpstrDefExt; + TCHAR lpFileName[MAX_PATH + 1]; - hInstance = GetModuleHandle( NULL ); - - strcpy( szFileName, hb_parc( 2 ) ); + HB_TCHAR_CPTO( lpFileName, hb_parcx( 2 ), MAX_PATH ); + lpstrTitle = HB_PARTSTR( 3 ); + lpstrFilter = HB_PARTSTR( 4 ); + lpstrInitialDir = HB_PARTSTR( 6 ); + lpstrDefExt = HB_PARTSTR( 7 ); ZeroMemory( &ofn, sizeof( ofn ) ); - ofn.hInstance = hInstance ; + ofn.hInstance = GetModuleHandle( NULL ); ofn.lStructSize = sizeof( ofn ); ofn.hwndOwner = ISNIL (1) ? GetActiveWindow() : (HWND) hb_parnl( 1 ); - ofn.lpstrTitle = hb_parc (3); - ofn.lpstrFilter = hb_parc (4); + ofn.lpstrTitle = lpstrTitle; + ofn.lpstrFilter = lpstrFilter; ofn.Flags = (ISNIL (5) ? OFN_FILEMUSTEXIST|OFN_EXPLORER|OFN_NOCHANGEDIR : hb_parnl( 4 ) ); - ofn.lpstrInitialDir = hb_parc (6); - ofn.lpstrDefExt = hb_parc (7); + ofn.lpstrInitialDir = lpstrInitialDir; + ofn.lpstrDefExt = lpstrDefExt; ofn.nFilterIndex = hb_parni(8); - ofn.lpstrFile = szFileName; + ofn.lpstrFile = lpFileName; ofn.nMaxFile = MAX_PATH; if( GetSaveFileName( &ofn ) ) { + char * szFileName = HB_TCHAR_CONVFROM( lpFileName ); hb_stornl( ofn.nFilterIndex, 8 ); - hb_retc( ofn.lpstrFile ); + hb_retc( szFileName ); + HB_TCHAR_FREE( szFileName ); } else { - hb_retc( "" ); + hb_retc( NULL ); } + + HB_PARTFREE( lpstrTitle ); + HB_PARTFREE( lpstrFilter ); + HB_PARTFREE( lpstrInitialDir ); + HB_PARTFREE( lpstrDefExt ); } //----------------------------------------------------------------------// diff --git a/harbour/include/hbgtcore.h b/harbour/include/hbgtcore.h index 83492dc9dc..d971dc8cf7 100644 --- a/harbour/include/hbgtcore.h +++ b/harbour/include/hbgtcore.h @@ -527,7 +527,7 @@ extern HB_EXPORT void hb_gtStartupInit( void ); extern int hb_gt_chrmapinit( int *piTransTbl, const char *pszTerm, BOOL fSetACSC ); #if defined( HB_OS_WIN_32 ) extern void hb_gt_w32_Tone( double dFrequency, double dDuration ); -extern void hb_gt_w32_SetClipboard( UINT uFormat, char * szClipData, ULONG ulLen ); +extern BOOL hb_gt_w32_SetClipboard( UINT uFormat, char * szClipData, ULONG ulLen ); extern BOOL hb_gt_w32_GetClipboard( UINT uFormat, char ** pszClipData, ULONG *pulLen ); extern int hb_gt_w32_getKbdState( void ); extern void hb_gt_w32_setKbdState( int kbdShifts ); diff --git a/harbour/source/rtl/gtclip.c b/harbour/source/rtl/gtclip.c index 80854c2c49..9e358e12a8 100644 --- a/harbour/source/rtl/gtclip.c +++ b/harbour/source/rtl/gtclip.c @@ -58,10 +58,11 @@ #if defined( HB_OS_WIN_32 ) -void hb_gt_w32_SetClipboard( UINT uFormat, char * szClipData, ULONG ulLen ) +BOOL hb_gt_w32_SetClipboard( UINT uFormat, char * szClipData, ULONG ulLen ) { LPTSTR lptstrCopy; HGLOBAL hglbCopy; + BOOL fResult = FALSE; if( OpenClipboard( NULL ) ) { @@ -77,6 +78,7 @@ void hb_gt_w32_SetClipboard( UINT uFormat, char * szClipData, ULONG ulLen ) { HB_TCHAR_SETTO( lptstrCopy, szClipData, ulLen ); lptstrCopy[ ulLen ] = '\0'; + fResult = TRUE; } GlobalUnlock( hglbCopy ); /* Place the handle on the clipboard. */ @@ -84,6 +86,7 @@ void hb_gt_w32_SetClipboard( UINT uFormat, char * szClipData, ULONG ulLen ) } CloseClipboard(); } + return fResult; } BOOL hb_gt_w32_GetClipboard( UINT uFormat, char ** pszClipData, ULONG *pulLen ) diff --git a/harbour/source/rtl/gtpca/gtpca.c b/harbour/source/rtl/gtpca/gtpca.c index b4f1478694..7d24cb3d31 100644 --- a/harbour/source/rtl/gtpca/gtpca.c +++ b/harbour/source/rtl/gtpca/gtpca.c @@ -71,7 +71,7 @@ #include #include -#if defined( OS_UNIX_COMPATIBLE ) +#if defined( OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) #include /* read() function requires it */ #include #include @@ -118,7 +118,7 @@ static int s_iOutBufSize = 0; static int s_iOutBufIndex = 0; static BYTE * s_sOutBuf; -#if defined( OS_UNIX_COMPATIBLE ) +#if defined( OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) static volatile BOOL s_fRestTTY = FALSE; static struct termios s_saved_TIO, s_curr_TIO; @@ -214,7 +214,7 @@ static void hb_gt_pca_AnsiGetCurPos( int * iRow, int * iCol ) hb_gt_pca_termOut( ( BYTE * ) "\x1B[6n", 4 ); hb_gt_pca_termFlush(); -#ifdef OS_UNIX_COMPATIBLE +#if defined( OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) { char rdbuf[ 64 ]; int i, n, y, x; @@ -443,7 +443,8 @@ static void hb_gt_pca_Init( FHANDLE hFilenoStdin, FHANDLE hFilenoStdout, FHANDLE HB_GTSUPER_INIT( hFilenoStdin, hFilenoStdout, hFilenoStderr ); /* SA_NOCLDSTOP in #if is a hack to detect POSIX compatible environment */ -#if defined( OS_UNIX_COMPATIBLE ) && defined( SA_NOCLDSTOP ) +#if ( defined( OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) ) && \ + defined( SA_NOCLDSTOP ) s_fRestTTY = FALSE; if( s_bStdinConsole ) { @@ -519,7 +520,7 @@ static void hb_gt_pca_Exit( void ) HB_GTSUPER_EXIT(); -#if defined( OS_UNIX_COMPATIBLE ) +#if defined( OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) if( s_fRestTTY ) tcsetattr( s_hFilenoStdin, TCSANOW, &s_saved_TIO ); #endif @@ -680,7 +681,7 @@ static int hb_gt_pca_ReadKey( int iEventMask ) if( _read( s_hFilenoStdin, &bChar, 1 ) == 1 ) ch = s_keyTransTbl[ bChar ]; } -#elif defined( OS_UNIX_COMPATIBLE ) +#elif defined( OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) { BYTE bChar; if( hb_fsRead( s_hFilenoStdin, &bChar, 1 ) == 1 ) @@ -750,7 +751,7 @@ static char * hb_gt_pca_Version( int iType ) static BOOL hb_gt_pca_Suspend( void ) { HB_TRACE( HB_TR_DEBUG, ( "hb_gt_pca_Suspend()" ) ); -#if defined( OS_UNIX_COMPATIBLE ) +#if defined( OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) if( s_fRestTTY ) { tcsetattr( s_hFilenoStdin, TCSANOW, &s_saved_TIO ); @@ -765,7 +766,7 @@ static BOOL hb_gt_pca_Resume( void ) { HB_TRACE( HB_TR_DEBUG, ( "hb_gt_pca_Resume()" ) ); -#if defined( OS_UNIX_COMPATIBLE ) +#if defined( OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) if( s_fRestTTY ) { tcsetattr( s_hFilenoStdin, TCSANOW, &s_curr_TIO ); diff --git a/harbour/source/rtl/gtstd/gtstd.c b/harbour/source/rtl/gtstd/gtstd.c index 61a2a36450..1346baaae8 100644 --- a/harbour/source/rtl/gtstd/gtstd.c +++ b/harbour/source/rtl/gtstd/gtstd.c @@ -62,7 +62,7 @@ #include "hbdate.h" #include "hb_io.h" -#if defined( OS_UNIX_COMPATIBLE ) +#if defined( OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) #include #include #include @@ -298,7 +298,7 @@ static int hb_gt_std_ReadKey( int iEventMask ) if( _read( s_hFilenoStdin, &bChar, 1 ) == 1 ) ch = s_keyTransTbl[ bChar ]; } -#elif defined( OS_UNIX_COMPATIBLE ) +#elif defined( OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) { struct timeval tv; fd_set rfds;