diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 8c5f13ba79..8055b7ef4b 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,12 @@ past entries belonging to these authors: Viktor Szakats. */ +2009-05-19 11:46 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/contrib/xhb/xhbmsgs.c + ! fixed one byte string as number emulation in some math operations + where both expressions are one byte strings, f.e.: + ? "A" * "B" + 2009-05-19 08:19 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * utils/hbmk2/hbmk2.pt_BR.po * utils/hbmk2/hbmk2.hu_HU.po diff --git a/harbour/contrib/xhb/xhbmsgs.c b/harbour/contrib/xhb/xhbmsgs.c index 692b895bb5..d6bc030c4a 100644 --- a/harbour/contrib/xhb/xhbmsgs.c +++ b/harbour/contrib/xhb/xhbmsgs.c @@ -504,6 +504,13 @@ HB_FUNC( XHB_MULT ) double dValue = hb_itemGetNDDec( pValue, &iDec ); hb_retndlen( ( double ) uc * dValue, 0, iDec ); } + else if( HB_IS_STRING( pSelf ) && hb_itemGetCLen( pSelf ) == 1 && + hb_itemGetCLen( pValue ) == 1 ) + { + UCHAR uc1 = ( UCHAR ) hb_itemGetCPtr( pSelf )[0], + uc2 = ( UCHAR ) hb_itemGetCPtr( pValue )[0]; + hb_retnint( uc1 * uc2 ); + } else { PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1083, NULL, "*", 2, pSelf, pValue ); @@ -529,11 +536,12 @@ HB_FUNC( XHB_DIV ) else hb_retnd( hb_itemGetND( pSelf ) / uc ); } - else if( HB_IS_STRING( pSelf ) && hb_itemGetCLen( pSelf ) == 1 && - pValue && HB_IS_NUMERIC( pValue ) ) + else if( HB_IS_STRING( pSelf ) && hb_itemGetCLen( pSelf ) == 1 && pValue && + ( HB_IS_NUMERIC( pValue ) || hb_itemGetCLen( pValue ) == 1 ) ) { UCHAR uc = ( UCHAR ) hb_itemGetCPtr( pSelf )[0]; - double dDivisor = hb_itemGetND( pValue ); + double dDivisor = HB_IS_NUMERIC( pValue ) ? hb_itemGetND( pValue ) : + ( double ) ( ( UCHAR ) hb_itemGetCPtr( pValue )[0] ); if( dDivisor == 0 ) { @@ -569,11 +577,12 @@ HB_FUNC( XHB_MOD ) else hb_retnd( fmod( hb_itemGetND( pSelf ), ( double ) uc ) ); } - else if( HB_IS_STRING( pSelf ) && hb_itemGetCLen( pSelf ) == 1 && - pValue && HB_IS_NUMERIC( pValue ) ) + else if( HB_IS_STRING( pSelf ) && hb_itemGetCLen( pSelf ) == 1 && pValue && + ( HB_IS_NUMERIC( pValue ) || hb_itemGetCLen( pValue ) == 1 ) ) { UCHAR uc = ( UCHAR ) hb_itemGetCPtr( pSelf )[0]; - double dDivisor = hb_itemGetND( pValue ); + double dDivisor = HB_IS_NUMERIC( pValue ) ? hb_itemGetND( pValue ) : + ( double ) ( ( UCHAR ) hb_itemGetCPtr( pValue )[0] ); if( dDivisor == 0 ) { @@ -608,6 +617,13 @@ HB_FUNC( XHB_POW ) UCHAR uc = ( UCHAR ) hb_itemGetCPtr( pSelf )[0]; hb_retnd( pow( ( double ) uc, hb_itemGetND( pValue ) ) ); } + else if( HB_IS_STRING( pSelf ) && hb_itemGetCLen( pSelf ) == 1 && + hb_itemGetCLen( pValue ) == 1 ) + { + UCHAR uc1 = ( UCHAR ) hb_itemGetCPtr( pSelf )[0], + uc2 = ( UCHAR ) hb_itemGetCPtr( pValue )[0]; + hb_retnd( pow( ( double ) uc1, ( double ) uc2 ) ); + } else { PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1088, NULL, "^", 2, pSelf, pValue );