From fe1cf38e76a4e1e47a1eb37915c10b3f513aa632 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 13 Feb 2010 12:12:35 +0000 Subject: [PATCH] 2010-02-13 13:10 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbwin/win_dll.c ! Fixed to unshare all HVM strings before passing them to callee. * contrib/hbwin/tests/testdll.prg ! Deleted two commented test call, which corrupted memory anyway due to too small buffer passed to low-level function. --- harbour/ChangeLog | 28 ++++++++++++++++--------- harbour/contrib/hbwin/tests/testdll.prg | 10 --------- harbour/contrib/hbwin/win_dll.c | 24 +++++++++++++++++---- 3 files changed, 38 insertions(+), 24 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 2f7aabd8fd..f3b3e95904 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,14 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-02-13 13:10 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbwin/win_dll.c + ! Fixed to unshare all HVM strings before passing them to callee. + + * contrib/hbwin/tests/testdll.prg + ! Deleted two commented test call, which corrupted memory anyway + due to too small buffer passed to low-level function. + 2010-02-13 03:43 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbqt/hbqt_hbqplaintextedit.cpp * contrib/hbqt/hbqt_hbqplaintextedit.h @@ -43,21 +51,21 @@ for all implemented docked windows. It facilitates clubbing all toggle actions at one convenient place. - + Implemented "Code Skeletons". + + Implemented "Code Skeletons". How to write ============ * Click main-menu option and select . * "Code Skeletons" window will open at the right-docking area. * Close other docks if open to make room for its components. * Click button, a dialog will appear requesting a "Name". - * Enter recognizable name for this skeleton, i.e., "DO CASE 3", + * Enter recognizable name for this skeleton, i.e., "DO CASE 3", where "3" will represent that this case statement contains 3 - iterations of CASE statement. It is just an example, follow + iterations of CASE statement. It is just an example, follow your way of recognitions. * After you click the name will appear in "Identity" list-box. * Start writing in "Code Snippet" editor, like: DO CASE - CASE x == + CASE x == CASE x == CASE x == ENDCASE @@ -65,7 +73,7 @@ * Repeat the process for some other skeletons. * Do not forget to click even after slightest modification. This will ensure that your skeleton is always in order. - * If you wish to change the name, click on that "Name" in + * If you wish to change the name, click on that "Name" in "Identity" list-box and click , follow next process. Click to save permanently. * is not working yet. @@ -74,20 +82,20 @@ How to Call =========== - * While in the editor tab, position your editing cursor at + * While in the editor tab, position your editing cursor at desired column. * Press Ctrl+K, a context menu will appear near left-upper part of the editing tab containing all skeletons you wrote. * Use arrow-up/down keys to desired skeleton and press . - * The code skeleton will be inserted in the source aligned + * The code skeleton will be inserted in the source aligned to the column you started with. The cursor will be anchored on the same place. - * Alternativly you can use mouse, but keyboard navigation is + * Alternativly you can use mouse, but keyboard navigation is simple in this context. - * Note that alignment and indent of inserted code skeleton is + * Note that alignment and indent of inserted code skeleton is perfect to starting column. - Note: Your suggessions are welcome to enhance this feature. + Note: Your suggessions are welcome to enhance this feature. 2010-02-13 12:36 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/src/vm/strapi.c diff --git a/harbour/contrib/hbwin/tests/testdll.prg b/harbour/contrib/hbwin/tests/testdll.prg index 78e87ccce1..f0e7320142 100644 --- a/harbour/contrib/hbwin/tests/testdll.prg +++ b/harbour/contrib/hbwin/tests/testdll.prg @@ -111,16 +111,6 @@ PROCEDURE Main() ? "cData BEFORE: ", cData ? "WIN_DLLCALL (MISSING @1): ", win_dllCall( GetProcAddress( hDLL, "SHGetFolderPath" ), 0, CSIDL_ADMINTOOLS, 0, 0, cData ) ? "cData AFTER: ", cData -/* - cData := "aaaaaaaaaaaaaaaaaaaaaa" - ? "cData BEFORE: ", cData - ? "WIN_DLLCALL (MISSING @2): ", win_dllCall( GetProcAddress( hDLL, "SHGetFolderPath" ), 0, CSIDL_ADMINTOOLS, 0, 0, cData ) - ? "cData AFTER: ", cData - cData := " " - ? "cData BEFORE: ", cData - ? "WIN_DLLCALL (MISSING @3): ", win_dllCall( GetProcAddress( hDLL, "SHGetFolderPath" ), 0, CSIDL_ADMINTOOLS, 0, 0, cData ) - ? "cData AFTER: ", cData -*/ wapi_FreeLibrary( hDLL ) ? "DLLCALL" diff --git a/harbour/contrib/hbwin/win_dll.c b/harbour/contrib/hbwin/win_dll.c index 63915665ca..b47b0ba45a 100644 --- a/harbour/contrib/hbwin/win_dll.c +++ b/harbour/contrib/hbwin/win_dll.c @@ -166,9 +166,17 @@ static HB_U64 hb_u64par( PHB_ITEM pParam, PHB_WINCALL wcall, int iParam ) case HB_WIN_DLL_CTYPE_CHAR_PTR: if( wcall->bUNICODE ) - r = ( HB_PTRUINT ) hb_itemGetStrU16( pParam, HB_CDP_ENDIAN_NATIVE, &wcall->pArg[ iParam - 1 ].hString, NULL ); + { + HB_SIZE nLen; + const HB_WCHAR * s = hb_itemGetStrU16( pParam, HB_CDP_ENDIAN_NATIVE, &wcall->pArg[ iParam - 1 ].hString, &nLen ); + r = ( HB_PTRUINT ) hb_wstrunshare( &wcall->pArg[ iParam - 1 ].hString, s, nLen ); + } else - r = ( HB_PTRUINT ) hb_itemGetStr( pParam, hb_setGetOSCP(), &wcall->pArg[ iParam - 1 ].hString, NULL ); + { + HB_SIZE nLen; + const char * s = hb_itemGetStr( pParam, hb_setGetOSCP(), &wcall->pArg[ iParam - 1 ].hString, &nLen ); + r = ( HB_PTRUINT ) hb_strunshare( &wcall->pArg[ iParam - 1 ].hString, s, nLen ); + } wcall->pArg[ iParam - 1 ].nValue = r; break; @@ -383,9 +391,17 @@ static void hb_u32par( PHB_ITEM pParam, PHB_WINCALL wcall, int iParam, HB_U32 * case HB_WIN_DLL_CTYPE_CHAR_PTR: if( wcall->bUNICODE ) - *r1 = ( HB_U32 ) hb_itemGetStrU16( pParam, HB_CDP_ENDIAN_NATIVE, &wcall->pArg[ iParam - 1 ].hString, NULL ); + { + HB_SIZE nLen; + const HB_WCHAR * s = hb_itemGetStrU16( pParam, HB_CDP_ENDIAN_NATIVE, &wcall->pArg[ iParam - 1 ].hString, &nLen ); + *r1 = ( HB_U32 ) hb_wstrunshare( &wcall->pArg[ iParam - 1 ].hString, s, nLen ); + } else - *r1 = ( HB_U32 ) hb_itemGetStr( pParam, hb_setGetOSCP(), &wcall->pArg[ iParam - 1 ].hString, NULL ); + { + HB_SIZE nLen; + const char * s = hb_itemGetStr( pParam, hb_setGetOSCP(), &wcall->pArg[ iParam - 1 ].hString, &nLen ); + *r1 = ( HB_U32 ) hb_strunshare( &wcall->pArg[ iParam - 1 ].hString, s, nLen ); + } wcall->pArg[ iParam - 1 ].value.t.n32 = *r1; break;