From 24ae545b3e314d8cdc2cb4a7edf3b417352aa4cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czerpak?= Date: Thu, 21 Aug 2014 01:11:26 +0200 Subject: [PATCH] 2014-08-21 01:11 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * contrib/hbtip/mail.prg ! fixed missing 1-st adress in CC and BCC parameters - many for information about the bug and patch * contrib/hbtip/sendmail.prg ! typo in comment - thanks to Heinz V Bergen too * src/rtl/gtwvt/gtwvt.c * some minor modification to sync code with Vitkor's branch * src/vm/hvm.c * src/vm/itemapi.c * small optimization in string comparison --- ChangeLog.txt | 15 ++++++++ contrib/hbtip/mail.prg | 4 +-- contrib/hbtip/sendmail.prg | 2 +- src/rtl/gtwvt/gtwvt.c | 74 +++++++++++++++++++++----------------- src/vm/hvm.c | 7 ++-- src/vm/itemapi.c | 4 +++ 6 files changed, 67 insertions(+), 39 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 23c30c363b..2499f83c12 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,21 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2014-08-21 01:11 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * contrib/hbtip/mail.prg + ! fixed missing 1-st adress in CC and BCC parameters - many + for information about the bug and patch + + * contrib/hbtip/sendmail.prg + ! typo in comment - thanks to Heinz V Bergen too + + * src/rtl/gtwvt/gtwvt.c + * some minor modification to sync code with Vitkor's branch + + * src/vm/hvm.c + * src/vm/itemapi.c + * small optimization in string comparison + 2014-08-19 11:11 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/debug/debugger.prg + implemented commmand window resizing with ALT+U and ALT+D keys diff --git a/contrib/hbtip/mail.prg b/contrib/hbtip/mail.prg index 1eb5ef4195..86294b1218 100644 --- a/contrib/hbtip/mail.prg +++ b/contrib/hbtip/mail.prg @@ -586,7 +586,7 @@ METHOD setHeader( cSubject, cFrom, xTo, xCC, xBCC ) CLASS TIPMail IF ! Empty( aCC ) cCC := "" imax := Len( aCC ) - FOR i := 2 TO imax + FOR i := 1 TO imax cCC += LTrim( WordEncodeQ( tip_GetNameEmail( AllTrim( aCC[ i ] ) ), ::cCharset ) + " <" + tip_GetRawEmail( AllTrim( aCC[ i ] ) ) + ">" ) IF i < imax cCC += "," + tip_CRLF() + " " @@ -601,7 +601,7 @@ METHOD setHeader( cSubject, cFrom, xTo, xCC, xBCC ) CLASS TIPMail IF ! Empty( aBCC ) cBCC := "" imax := Len( aBCC ) - FOR i := 2 TO imax + FOR i := 1 TO imax cBCC += LTrim( WordEncodeQ( tip_GetNameEmail( AllTrim( aBCC[ i ] ) ), ::cCharset ) + " <" + tip_GetRawEmail( AllTrim( aBCC[ i ] ) ) + ">" ) IF i < imax cBCC += "," + tip_CRLF() + " " diff --git a/contrib/hbtip/sendmail.prg b/contrib/hbtip/sendmail.prg index 71ba9c0bf2..fb80762041 100644 --- a/contrib/hbtip/sendmail.prg +++ b/contrib/hbtip/sendmail.prg @@ -318,7 +318,7 @@ FUNCTION hb_MailAssemble( cFrom, xTo, xCC, cBody, cSubject, ; /* cFrom -> Required. Email address of the sender xTo -> Required. Character string or array of email addresses to send the email to - xCC -> Optional. Character string or array of email adresses for CC (Carbon Copy) + xCC -> Optional. Character string or array of email addresses for CC (Carbon Copy) cBody -> Optional. The body message of the email as text, or the filename of the HTML message to send. cSubject -> Optional. Subject of the sending email aFiles -> Optional. Array of attachments to the email to send diff --git a/src/rtl/gtwvt/gtwvt.c b/src/rtl/gtwvt/gtwvt.c index 9e12860f3e..862cfd1ba1 100644 --- a/src/rtl/gtwvt/gtwvt.c +++ b/src/rtl/gtwvt/gtwvt.c @@ -183,7 +183,7 @@ static PHB_GTWVT hb_gt_wvt_Find( HWND hWnd ) HB_WVT_LOCK(); - while( iCount && iPos < WVT_MAX_WINDOWS ) + while( iCount && iPos < ( int ) HB_SIZEOFARRAY( s_wvtWindows ) ) { if( s_wvtWindows[ iPos ] ) { @@ -208,7 +208,7 @@ static HB_BOOL hb_gt_wvt_Alloc( PHB_GTWVT pWVT ) HB_WVT_LOCK(); - if( s_wvtCount < WVT_MAX_WINDOWS ) + if( s_wvtCount < ( int ) HB_SIZEOFARRAY( s_wvtWindows ) ) { int iPos = 0; do @@ -224,7 +224,7 @@ static HB_BOOL hb_gt_wvt_Alloc( PHB_GTWVT pWVT ) } ++iPos; } - while( iPos < WVT_MAX_WINDOWS ); + while( iPos < ( int ) HB_SIZEOFARRAY( s_wvtWindows ) ); } HB_WVT_UNLOCK(); @@ -290,8 +290,8 @@ static PHB_GTWVT hb_gt_wvt_New( PHB_GT pGT, HINSTANCE hInstance, int iCmdShow ) { PHB_GTWVT pWVT; - pWVT = ( PHB_GTWVT ) hb_xgrab( sizeof( HB_GTWVT ) ); - memset( pWVT, 0, sizeof( HB_GTWVT ) ); + pWVT = ( PHB_GTWVT ) hb_xgrabz( sizeof( HB_GTWVT ) ); + pWVT->pGT = pGT; if( ! hb_gt_wvt_Alloc( pWVT ) ) @@ -1610,7 +1610,7 @@ static void hb_gt_wvt_KillCaret( PHB_GTWVT pWVT ) } /* - * functions for handling the input queues for the mouse and keyboard + * functions for handling the input queues for the mouse and keyboard */ static void hb_gt_wvt_AddCharToInputQueue( PHB_GTWVT pWVT, int iKey ) { @@ -1632,7 +1632,7 @@ static void hb_gt_wvt_AddCharToInputQueue( PHB_GTWVT pWVT, int iKey ) * in the buffer - it's Clipper behavior, [druzus] */ pWVT->Keys[ pWVT->keyLastPos = iPos ] = iKey; - if( ++iPos >= WVT_CHAR_QUEUE_SIZE ) + if( ++iPos >= ( int ) HB_SIZEOFARRAY( pWVT->Keys ) ) iPos = 0; if( iPos != pWVT->keyPointerOut ) pWVT->keyPointerIn = iPos; @@ -1643,7 +1643,7 @@ static HB_BOOL hb_gt_wvt_GetCharFromInputQueue( PHB_GTWVT pWVT, int * iKey ) if( pWVT->keyPointerOut != pWVT->keyPointerIn ) { *iKey = pWVT->Keys[ pWVT->keyPointerOut ]; - if( ++pWVT->keyPointerOut >= WVT_CHAR_QUEUE_SIZE ) + if( ++pWVT->keyPointerOut >= ( int ) HB_SIZEOFARRAY( pWVT->Keys ) ) pWVT->keyPointerOut = 0; return HB_TRUE; @@ -1665,10 +1665,11 @@ static int hb_gt_wvt_key_ansi_to_oem( int c ) pszDst[ 0 ] = pszDst[ 1 ] = 0; - MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, ( LPCSTR ) pszSrc, 1, ( LPWSTR ) pszWide, 1 ); - WideCharToMultiByte( CP_OEMCP, 0, ( LPCWSTR ) pszWide, 1, ( LPSTR ) pszDst, 1, NULL, NULL ); - - return pszDst[ 0 ]; + if( MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, ( LPCSTR ) pszSrc, 1, ( LPWSTR ) pszWide, 1 ) && + WideCharToMultiByte( CP_OEMCP, 0, ( LPCWSTR ) pszWide, 1, ( LPSTR ) pszDst, 1, NULL, NULL ) ) + return pszDst[ 0 ]; + else + return c; } #endif @@ -1694,7 +1695,7 @@ static void hb_gt_wvt_FitRows( PHB_GTWVT pWVT ) { HB_BOOL bOldCentre = pWVT->CentreWindow; pWVT->CentreWindow = HB_FALSE; - HB_GTSELF_SETMODE( pWVT->pGT, ( maxHeight / pWVT->PTEXTSIZE.y ), ( maxWidth / pWVT->PTEXTSIZE.x ) ); + HB_GTSELF_SETMODE( pWVT->pGT, maxHeight / pWVT->PTEXTSIZE.y, maxWidth / pWVT->PTEXTSIZE.x ); pWVT->CentreWindow = bOldCentre; } } @@ -2250,8 +2251,8 @@ static void hb_gt_wvt_MouseEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam, L rect = hb_gt_wvt_GetColRowFromXYRect( pWVT, rect ); - nSize = ( ( rect.bottom - rect.top + 1 ) * - ( rect.right - rect.left + 1 + 2 ) ); + nSize = ( rect.bottom - rect.top + 1 ) * + ( rect.right - rect.left + 1 + 2 ); sBuffer = ( TCHAR * ) hb_xgrab( nSize * sizeof( TCHAR ) + 1 ); for( n = 0, row = rect.top; row <= rect.bottom; row++ ) @@ -3068,7 +3069,7 @@ static HB_BOOL hb_gt_wvt_FullScreen( PHB_GT pGT ) HB_GTWVT_LONG_PTR nStyle; HB_GTWVT_LONG_PTR nExtendedStyle; -/*Don't need this as Windows automatically maximizes to nearest [HVB] +/* Don't need this as Windows automatically maximizes to nearest [HVB] #ifdef MONITOR_DEFAULTTONEAREST HMONITOR mon; MONITORINFO mi; @@ -3123,23 +3124,30 @@ static HB_BOOL hb_gt_wvt_FullScreen( PHB_GT pGT ) */ #if 0 #ifdef MONITOR_DEFAULTTONEAREST - pMonitorFromWindow = ( P_MFW ) - HB_WINAPI_GETPROCADDRESS( GetModuleHandle( TEXT( "user32.dll" ) ), - "MonitorFromWindow" ); - pGetMonitorInfo = ( P_GMI ) - HB_WINAPI_GETPROCADDRESS( GetModuleHandle( TEXT( "user32.dll" ) ), - "GetMonitorInfo" ); - - if( pMonitorFromWindow && pGetMonitorInfo ) { - mon = pMonitorFromWindow( pWVT->hWnd, MONITOR_DEFAULTTONEAREST ); - mi.cbSize = sizeof( mi ); - pGetMonitorInfo( mon, &mi ); - rt = mi.rcMonitor; - } - else - GetClientRect( GetDesktopWindow(), &rt ); + HMODULE hModule = GetModuleHandle( TEXT( "user32.dll" ) ); + if( hModule ) + { + pMonitorFromWindow = ( P_MFW ) HB_WINAPI_GETPROCADDRESS( hModule, "MonitorFromWindow" ); + pGetMonitorInfo = ( P_GMI ) HB_WINAPI_GETPROCADDRESS( hModule, "GetMonitorInfo" ); + } + else + { + pMonitorFromWindow = NULL; + pGetMonitorInfo = NULL; + } + + if( pMonitorFromWindow && pGetMonitorInfo ) + { + mon = pMonitorFromWindow( pWVT->hWnd, MONITOR_DEFAULTTONEAREST ); + mi.cbSize = sizeof( mi ); + pGetMonitorInfo( mon, &mi ); + rt = mi.rcMonitor; + } + else + GetClientRect( GetDesktopWindow(), &rt ); + } #else GetClientRect( GetDesktopWindow(), &rt ); #endif @@ -3767,7 +3775,7 @@ static HB_BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) #endif case HB_GTI_ICONFILE: - if( ( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) ) + if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) { HICON hIconToFree = pWVT->bIconToFree ? pWVT->hIcon : NULL; void * hImageName; @@ -4185,7 +4193,7 @@ static int hb_gt_wvt_gfx_Primitive( PHB_GT pGT, int iType, int iTop, int iLeft, break; case HB_GFX_MAKECOLOR: - iRet = ( iTop << 16 ) | ( iLeft << 8 ) | ( iBottom ); + iRet = ( iTop << 16 ) | ( iLeft << 8 ) | iBottom; break; case HB_GFX_PUTPIXEL: diff --git a/src/vm/hvm.c b/src/vm/hvm.c index 8287c193d9..74ef77041f 100644 --- a/src/vm/hvm.c +++ b/src/vm/hvm.c @@ -3784,9 +3784,10 @@ static void hb_vmExactlyEqual( void ) else if( HB_IS_STRING( pItem1 ) && HB_IS_STRING( pItem2 ) ) { HB_BOOL fResult = pItem1->item.asString.length == pItem2->item.asString.length && - memcmp( pItem1->item.asString.value, - pItem2->item.asString.value, - pItem1->item.asString.length ) == 0; + ( pItem1->item.asString.value == pItem2->item.asString.value || + memcmp( pItem1->item.asString.value, + pItem2->item.asString.value, + pItem1->item.asString.length ) == 0 ); hb_stackPop(); hb_itemClear( pItem1 ); pItem1->type = HB_IT_LOGICAL; diff --git a/src/vm/itemapi.c b/src/vm/itemapi.c index d6e6a83602..036b2e363d 100644 --- a/src/vm/itemapi.c +++ b/src/vm/itemapi.c @@ -2261,6 +2261,10 @@ int hb_itemStrCmp( PHB_ITEM pFirst, PHB_ITEM pSecond, HB_BOOL bForceExact ) szFirst = pFirst->item.asString.value; szSecond = pSecond->item.asString.value; + + if( szFirst == szSecond ) + return 0; + nLenFirst = pFirst->item.asString.length; nLenSecond = pSecond->item.asString.length;