2014-08-22 14:41 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)

* src/vm/hvm.c
    * map 0 and 1 byte length strings to the same addresses

  * src/vm/itemapi.c
    ! check also size if string addresses are the same
This commit is contained in:
Przemysław Czerpak
2014-08-22 14:41:21 +02:00
parent 24ae545b3e
commit e222fc9080
3 changed files with 42 additions and 50 deletions

View File

@@ -10,6 +10,13 @@
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
*/
2014-08-22 14:41 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* src/vm/hvm.c
* map 0 and 1 byte length strings to the same addresses
* src/vm/itemapi.c
! check also size if string addresses are the same
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

View File

@@ -6865,9 +6865,10 @@ void hb_vmPushStringPcode( const char * szText, HB_SIZE nLength )
HB_TRACE( HB_TR_DEBUG, ( "hb_vmPushStringPcode(%s, %" HB_PFS "u)", szText, nLength ) );
pItem->type = HB_IT_STRING;
pItem->item.asString.length = nLength;
pItem->item.asString.allocated = 0;
pItem->item.asString.value = ( char * ) szText;
pItem->item.asString.length = nLength;
pItem->item.asString.value = ( char * ) ( nLength <= 1 ?
hb_szAscii[ ( unsigned char ) szText[ 0 ] ] : szText );
}
void hb_vmPushSymbol( PHB_SYMB pSym )

View File

@@ -244,15 +244,15 @@ PHB_ITEM hb_itemPutC( PHB_ITEM pItem, const char * szText )
HB_TRACE( HB_TR_DEBUG, ( "hb_itemPutC(%p, %s)", pItem, szText ) );
nLen = szText ? strlen( szText ) : 0;
if( nLen > 1 )
if( nLen <= 1 )
{
nAlloc = nLen + 1;
szText = ( char * ) hb_xmemcpy( hb_xgrab( nAlloc ), szText, nAlloc );
nAlloc = 0;
szText = hb_szAscii[ nLen ? ( unsigned char ) szText[ 0 ] : 0 ];
}
else
{
nAlloc = 0;
szText = ( nLen ? hb_szAscii[ ( unsigned char ) ( szText[ 0 ] ) ] : "" );
nAlloc = nLen + 1;
szText = ( char * ) hb_xmemcpy( hb_xgrab( nAlloc ), szText, nAlloc );
}
if( pItem )
@@ -278,17 +278,17 @@ PHB_ITEM hb_itemPutCL( PHB_ITEM pItem, const char * szText, HB_SIZE nLen )
HB_TRACE( HB_TR_DEBUG, ( "hb_itemPutCL(%p, %.*s, %" HB_PFS "u)", pItem, ( int ) nLen, szText, nLen ) );
if( nLen > 1 )
if( nLen <= 1 )
{
nAlloc = 0;
szValue = ( char * ) hb_szAscii[ nLen ? ( unsigned char ) szText[ 0 ] : 0 ];
}
else
{
nAlloc = nLen + 1;
szValue = ( char * ) hb_xmemcpy( hb_xgrab( nAlloc ), szText, nLen );
szValue[ nLen ] = '\0';
}
else
{
nAlloc = 0;
szValue = ( char * ) ( nLen ? hb_szAscii[ ( unsigned char ) ( szText[ 0 ] ) ] : "" );
}
if( pItem )
{
@@ -312,6 +312,8 @@ PHB_ITEM hb_itemPutCL( PHB_ITEM pItem, const char * szText, HB_SIZE nLen )
PHB_ITEM hb_itemPutCConst( PHB_ITEM pItem, const char * szText )
{
HB_SIZE nLen;
HB_TRACE( HB_TR_DEBUG, ( "hb_itemPutCConst(%p, %s)", pItem, szText ) );
if( pItem )
@@ -322,19 +324,13 @@ PHB_ITEM hb_itemPutCConst( PHB_ITEM pItem, const char * szText )
else
pItem = hb_itemNew( NULL );
pItem->type = HB_IT_STRING;
pItem->item.asString.allocated = 0;
nLen = szText ? strlen( szText ) : 0;
if( szText == NULL )
{
pItem->item.asString.value = ( char * ) "";
pItem->item.asString.length = 0;
}
else
{
pItem->item.asString.value = ( char * ) szText;
pItem->item.asString.length = strlen( szText );
}
pItem->type = HB_IT_STRING;
pItem->item.asString.length = nLen;
pItem->item.asString.allocated = 0;
pItem->item.asString.value = ( char * ) ( nLen > 1 ? szText :
hb_szAscii[ nLen ? ( unsigned char ) szText[ 0 ] : 0 ] );
return pItem;
}
@@ -355,10 +351,10 @@ PHB_ITEM hb_itemPutCLConst( PHB_ITEM pItem, const char * szText, HB_SIZE nLen )
pItem->item.asString.length = nLen;
pItem->item.asString.allocated = 0;
if( nLen == 0 )
pItem->item.asString.value = ( char * ) "";
if( nLen <= 1 )
pItem->item.asString.value = ( char * ) hb_szAscii[ nLen ? ( unsigned char ) szText[ 0 ] : 0 ];
else if( szText[ nLen ] == '\0' )
pItem->item.asString.value = ( char * ) szText;
pItem->item.asString.value = ( char * ) szText;
else
hb_errInternal( 6003, "Internal error: hb_itemPutCLConst() missing termination character", NULL, NULL );
@@ -383,23 +379,17 @@ PHB_ITEM hb_itemPutCPtr( PHB_ITEM pItem, char * szText )
pItem->type = HB_IT_STRING;
pItem->item.asString.length = nLen;
if( nLen == 0 )
if( nLen <= 1 )
{
pItem->item.asString.allocated = 0;
pItem->item.asString.value = ( char * ) "";
pItem->item.asString.value = ( char * ) hb_szAscii[ nLen ? ( unsigned char ) szText[ 0 ] : 0 ];
if( szText )
hb_xfree( szText );
}
else if( nLen == 1 )
{
pItem->item.asString.allocated = 0;
pItem->item.asString.value = ( char * ) hb_szAscii[ ( unsigned char ) ( szText[ 0 ] ) ];
hb_xfree( szText );
}
else
{
pItem->item.asString.allocated = nLen + 1;
pItem->item.asString.value = szText;
pItem->item.asString.value = szText;
}
return pItem;
@@ -419,23 +409,17 @@ PHB_ITEM hb_itemPutCLPtr( PHB_ITEM pItem, char * szText, HB_SIZE nLen )
pItem->type = HB_IT_STRING;
pItem->item.asString.length = nLen;
if( nLen == 0 )
if( nLen <= 1 )
{
pItem->item.asString.allocated = 0;
pItem->item.asString.value = ( char * ) "";
hb_xfree( szText );
}
else if( nLen == 1 )
{
pItem->item.asString.allocated = 0;
pItem->item.asString.value = ( char * ) hb_szAscii[ ( unsigned char ) ( szText[ 0 ] ) ];
pItem->item.asString.value = ( char * ) hb_szAscii[ nLen ? ( unsigned char ) szText[ 0 ] : 0 ];
hb_xfree( szText );
}
else
{
szText[ nLen ] = '\0';
pItem->item.asString.allocated = nLen + 1;
pItem->item.asString.value = szText;
pItem->item.asString.value = szText;
}
return pItem;
@@ -2261,13 +2245,13 @@ 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;
if( szFirst == szSecond && nLenFirst == nLenSecond )
return 0;
if( ! bForceExact && hb_stackSetStruct()->HB_SET_EXACT )
{
/* SET EXACT ON and not using == */