2003-03-05 13:35 UTC+0300 Alexander Kresin <alex@belacy.belgorod.su>
This commit is contained in:
@@ -8,6 +8,14 @@
|
||||
2002-12-01 23:12 UTC+0100 Foo Bar <foo.bar@foobar.org>
|
||||
*/
|
||||
|
||||
2003-03-05 13:35 UTC+0300 Alexander Kresin <alex@belacy.belgorod.su>
|
||||
* source/vm/hvm.c
|
||||
* source/vm/itemapi.c
|
||||
* source/vm/asort.c
|
||||
* Reverted changes, related to short strings optimization, because they
|
||||
causes problems with arrays and inmplemented 1-byte length string
|
||||
optimization, borrowed from xHarbour.
|
||||
|
||||
2003-02-25 22:10 UTC+0300 Alexander Kresin <alex@belacy.belgorod.su>
|
||||
* contrib/rdd_ads/adsfunc.c
|
||||
+ Transaction processing functions added.
|
||||
|
||||
@@ -117,13 +117,9 @@ static LONG hb_arraySortQuickPartition( PHB_ITEM pItems, LONG lb, LONG ub, PHB_I
|
||||
|
||||
#ifdef HB_ASORT_OPT_ITEMCOPY
|
||||
memcpy( &pivot, pItems + p, sizeof( HB_ITEM ) );
|
||||
if( HB_IS_STRING( &pivot ) && (&pivot)->item.asString.bStatic < 0 )
|
||||
(&pivot)->item.asString.value = (&pivot)->item.asString.u.value;
|
||||
if( p != lb )
|
||||
{
|
||||
memcpy( pItems + p, pItems + lb, sizeof( HB_ITEM ) );
|
||||
if( HB_IS_STRING( pItems + p ) && (pItems + p)->item.asString.bStatic < 0 )
|
||||
(pItems + p)->item.asString.value = (pItems + p)->item.asString.u.value;
|
||||
}
|
||||
#else
|
||||
hb_itemInit( &pivot );
|
||||
@@ -190,10 +186,6 @@ static LONG hb_arraySortQuickPartition( PHB_ITEM pItems, LONG lb, LONG ub, PHB_I
|
||||
memcpy( &temp, pItems + j, sizeof( HB_ITEM ) );
|
||||
memcpy( pItems + j, pItems + i, sizeof( HB_ITEM ) );
|
||||
memcpy( pItems + i, &temp, sizeof( HB_ITEM ) );
|
||||
if( HB_IS_STRING( pItems + i ) && (pItems + i)->item.asString.bStatic < 0 )
|
||||
(pItems + i)->item.asString.value = (pItems + i)->item.asString.u.value;
|
||||
if( HB_IS_STRING( pItems + j ) && (pItems + j)->item.asString.bStatic < 0 )
|
||||
(pItems + j)->item.asString.value = (pItems + j)->item.asString.u.value;
|
||||
#else
|
||||
hb_itemInit( &temp );
|
||||
hb_itemCopy( &temp, pItems + j );
|
||||
@@ -212,12 +204,8 @@ static LONG hb_arraySortQuickPartition( PHB_ITEM pItems, LONG lb, LONG ub, PHB_I
|
||||
if( lb != j )
|
||||
{
|
||||
memcpy( pItems + lb, pItems + j, sizeof( HB_ITEM ) );
|
||||
if( HB_IS_STRING( pItems + lb ) && (pItems + lb)->item.asString.bStatic < 0 )
|
||||
(pItems + lb)->item.asString.value = (pItems + lb)->item.asString.u.value;
|
||||
}
|
||||
memcpy( pItems + j, &pivot, sizeof( HB_ITEM ) );
|
||||
if( HB_IS_STRING( pItems + j ) && (pItems + j)->item.asString.bStatic < 0 )
|
||||
(pItems + j)->item.asString.value = (pItems + j)->item.asString.u.value;
|
||||
#else
|
||||
if( lb != j )
|
||||
hb_itemCopy( pItems + lb, pItems + j );
|
||||
|
||||
@@ -239,6 +239,25 @@ int hb_vm_iExtraIndex;
|
||||
*/
|
||||
static USHORT s_uiActionRequest;
|
||||
|
||||
char *hb_vm_sNull = "";
|
||||
|
||||
char *hb_vm_acAscii[256] = { "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\x09", "\x0A", "\x0B", "\x0C", "\x0D", "\x0E", "\x0F",
|
||||
"\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", "\x18", "\x19", "\x1A", "\x1B", "\x1C", "\x1D", "\x1E", "\x1F",
|
||||
"\x20", "\x21", "\x22", "\x23", "\x24", "\x25", "\x26", "\x27", "\x28", "\x29", "\x2A", "\x2B", "\x2C", "\x2D", "\x2E", "\x2F",
|
||||
"\x30", "\x31", "\x32", "\x33", "\x34", "\x35", "\x36", "\x37", "\x38", "\x39", "\x3A", "\x3B", "\x3C", "\x3D", "\x3E", "\x3F",
|
||||
"\x40", "\x41", "\x42", "\x43", "\x44", "\x45", "\x46", "\x47", "\x48", "\x49", "\x4A", "\x4B", "\x4C", "\x4D", "\x4E", "\x4F",
|
||||
"\x50", "\x51", "\x52", "\x53", "\x54", "\x55", "\x56", "\x57", "\x58", "\x59", "\x5A", "\x5B", "\x5C", "\x5D", "\x5E", "\x5F",
|
||||
"\x60", "\x61", "\x62", "\x63", "\x64", "\x65", "\x66", "\x67", "\x68", "\x69", "\x6A", "\x6B", "\x6C", "\x6D", "\x6E", "\x6F",
|
||||
"\x70", "\x71", "\x72", "\x73", "\x74", "\x75", "\x76", "\x77", "\x78", "\x79", "\x7A", "\x7B", "\x7C", "\x7D", "\x7E", "\x7F",
|
||||
"\x80", "\x81", "\x82", "\x83", "\x84", "\x85", "\x86", "\x87", "\x88", "\x89", "\x8A", "\x8B", "\x8C", "\x8D", "\x8E", "\x8F",
|
||||
"\x90", "\x91", "\x92", "\x93", "\x94", "\x95", "\x96", "\x97", "\x98", "\x99", "\x9A", "\x9B", "\x9C", "\x9D", "\x9E", "\x9F",
|
||||
"\xA0", "\xA1", "\xA2", "\xA3", "\xA4", "\xA5", "\xA6", "\xA7", "\xA8", "\xA9", "\xAA", "\xAB", "\xAC", "\xAD", "\xAE", "\xAF",
|
||||
"\xB0", "\xB1", "\xB2", "\xB3", "\xB4", "\xB5", "\xB6", "\xB7", "\xB8", "\xB9", "\xBA", "\xBB", "\xBC", "\xBD", "\xBE", "\xBF",
|
||||
"\xC0", "\xC1", "\xC2", "\xC3", "\xC4", "\xC5", "\xC6", "\xC7", "\xC8", "\xC9", "\xCA", "\xCB", "\xCC", "\xCD", "\xCE", "\xCF",
|
||||
"\xD0", "\xD1", "\xD2", "\xD3", "\xD4", "\xD5", "\xD6", "\xD7", "\xD8", "\xD9", "\xDA", "\xDB", "\xDC", "\xDD", "\xDE", "\xDF",
|
||||
"\xE0", "\xE1", "\xE2", "\xE3", "\xE4", "\xE5", "\xE6", "\xE7", "\xE8", "\xE9", "\xEA", "\xEB", "\xEC", "\xED", "\xEE", "\xEF",
|
||||
"\xF0", "\xF1", "\xF2", "\xF3", "\xF4", "\xF5", "\xF6", "\xF7", "\xF8", "\xF9", "\xFA", "\xFB", "\xFC", "\xFD", "\xFE", "\xFF" };
|
||||
|
||||
/* 21/10/00 - maurilio.longo@libero.it
|
||||
This Exception Handler gets called in case of an abnormal termination of an harbour program and
|
||||
displays a full stack trace at the harbour language level */
|
||||
@@ -3968,13 +3987,16 @@ void hb_vmPushString( char * szText, ULONG length )
|
||||
|
||||
pStackTopItem->type = HB_IT_STRING;
|
||||
pStackTopItem->item.asString.length = length;
|
||||
if( length < sizeof(USHORT*) )
|
||||
if( length == 0 )
|
||||
{
|
||||
ULONG i = 0;
|
||||
pStackTopItem->item.asString.value = pStackTopItem->item.asString.u.value;
|
||||
for( ; i<length; szText++, i++ )
|
||||
pStackTopItem->item.asString.value[i] = *szText;
|
||||
pStackTopItem->item.asString.value[ length ] = '\0';
|
||||
pStackTopItem->item.asString.length = 0;
|
||||
pStackTopItem->item.asString.value = hb_vm_sNull;
|
||||
pStackTopItem->item.asString.bStatic = -1;
|
||||
}
|
||||
else if( length == 1 )
|
||||
{
|
||||
pStackTopItem->item.asString.length = 1;
|
||||
pStackTopItem->item.asString.value = hb_vm_acAscii[ (unsigned char) ( szText[0] ) ];
|
||||
pStackTopItem->item.asString.bStatic = -1;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -100,6 +100,8 @@
|
||||
#include "hbapicdp.h"
|
||||
|
||||
extern PHB_CODEPAGE s_cdpage;
|
||||
extern char *hb_vm_sNull;
|
||||
extern char *hb_vm_acAscii[256];
|
||||
|
||||
/* DJGPP can sprintf a float that is almost 320 digits long */
|
||||
#define HB_MAX_DOUBLE_LENGTH 320
|
||||
@@ -204,33 +206,26 @@ PHB_ITEM hb_itemPutC( PHB_ITEM pItem, char * szText )
|
||||
|
||||
pItem->type = HB_IT_STRING;
|
||||
|
||||
if( szText == NULL || szText[0] == '\0' )
|
||||
if( szText == NULL || szText[0] == '\0' )
|
||||
{
|
||||
pItem->item.asString.length = 0;
|
||||
pItem->item.asString.value = pItem->item.asString.u.value;
|
||||
pItem->item.asString.u.value[0] = '\0';
|
||||
pItem->item.asString.bStatic = -1;
|
||||
pItem->item.asString.length = 0;
|
||||
pItem->item.asString.value = hb_vm_sNull;
|
||||
pItem->item.asString.bStatic = TRUE;
|
||||
}
|
||||
else if( szText[1] == '\0' )
|
||||
{
|
||||
pItem->item.asString.length = 1;
|
||||
pItem->item.asString.value = hb_vm_acAscii[ (unsigned char) ( szText[0] ) ];
|
||||
pItem->item.asString.bStatic = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
pItem->item.asString.length = strlen( szText );
|
||||
if( pItem->item.asString.length < sizeof(USHORT*) )
|
||||
{
|
||||
int i = 0;
|
||||
pItem->item.asString.value = pItem->item.asString.u.value;
|
||||
for( ; *szText; szText++, i++ )
|
||||
pItem->item.asString.value[i] = *szText;
|
||||
pItem->item.asString.u.value[i] = '\0';
|
||||
pItem->item.asString.bStatic = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pItem->item.asString.value = ( char * ) hb_xgrab( pItem->item.asString.length + 1 );
|
||||
pItem->item.asString.bStatic = 0;
|
||||
pItem->item.asString.u.puiHolders = ( USHORT * ) hb_xgrab( sizeof( USHORT ) );
|
||||
* ( pItem->item.asString.u.puiHolders ) = 1;
|
||||
strcpy( pItem->item.asString.value, szText );
|
||||
}
|
||||
pItem->item.asString.value = ( char * ) hb_xgrab( pItem->item.asString.length + 1 );
|
||||
pItem->item.asString.bStatic = 0;
|
||||
pItem->item.asString.u.puiHolders = ( USHORT * ) hb_xgrab( sizeof( USHORT ) );
|
||||
* ( pItem->item.asString.u.puiHolders ) = 1;
|
||||
strcpy( pItem->item.asString.value, szText );
|
||||
}
|
||||
|
||||
return pItem;
|
||||
@@ -277,32 +272,26 @@ PHB_ITEM hb_itemPutCL( PHB_ITEM pItem, char * szText, ULONG ulLen )
|
||||
|
||||
pItem->type = HB_IT_STRING;
|
||||
|
||||
if( szText == NULL || ulLen == 0)
|
||||
if( szText == NULL || ulLen == 0 )
|
||||
{
|
||||
pItem->item.asString.length = 0;
|
||||
pItem->item.asString.value = pItem->item.asString.u.value;
|
||||
pItem->item.asString.u.value[0] = '\0';
|
||||
pItem->item.asString.bStatic = -1;
|
||||
pItem->item.asString.length = 0;
|
||||
pItem->item.asString.value = hb_vm_sNull;
|
||||
pItem->item.asString.bStatic = TRUE;
|
||||
}
|
||||
else if( ulLen == 1 )
|
||||
{
|
||||
pItem->item.asString.length = 1;
|
||||
pItem->item.asString.value = hb_vm_acAscii[ (unsigned char) ( szText[0] ) ];
|
||||
pItem->item.asString.bStatic = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
pItem->item.asString.length = ulLen;
|
||||
if( ulLen < sizeof(USHORT*) )
|
||||
{
|
||||
ULONG i = 0;
|
||||
pItem->item.asString.value = pItem->item.asString.u.value;
|
||||
for( ; i<ulLen; szText++, i++ )
|
||||
pItem->item.asString.value[i] = *szText;
|
||||
pItem->item.asString.bStatic = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pItem->item.asString.value = ( char * ) hb_xgrab( ulLen + 1 );
|
||||
pItem->item.asString.bStatic = 0;
|
||||
pItem->item.asString.u.puiHolders = ( USHORT * ) hb_xgrab( sizeof( USHORT ) );
|
||||
* ( pItem->item.asString.u.puiHolders ) = 1;
|
||||
hb_xmemcpy( pItem->item.asString.value, szText, ulLen );
|
||||
}
|
||||
pItem->item.asString.value = ( char * ) hb_xgrab( ulLen + 1 );
|
||||
pItem->item.asString.bStatic = 0;
|
||||
pItem->item.asString.u.puiHolders = ( USHORT * ) hb_xgrab( sizeof( USHORT ) );
|
||||
* ( pItem->item.asString.u.puiHolders ) = 1;
|
||||
hb_xmemcpy( pItem->item.asString.value, szText, ulLen );
|
||||
pItem->item.asString.value[ ulLen ] = '\0';
|
||||
}
|
||||
|
||||
@@ -922,12 +911,7 @@ void hb_itemCopy( PHB_ITEM pDest, PHB_ITEM pSource )
|
||||
|
||||
if( HB_IS_STRING( pSource ) )
|
||||
{
|
||||
if( pSource->item.asString.bStatic )
|
||||
{
|
||||
if( pSource->item.asString.bStatic < 0 )
|
||||
pDest->item.asString.value = pDest->item.asString.u.value;
|
||||
}
|
||||
else
|
||||
if( !pSource->item.asString.bStatic )
|
||||
++*( pSource->item.asString.u.puiHolders );
|
||||
}
|
||||
else if( HB_IS_ARRAY( pSource ) )
|
||||
@@ -953,8 +937,6 @@ void hb_itemMove( PHB_ITEM pDest, PHB_ITEM pSource )
|
||||
hb_itemClear( pDest );
|
||||
|
||||
memcpy( pDest, pSource, sizeof( HB_ITEM ) );
|
||||
if( HB_IS_STRING( pSource ) && pSource->item.asString.bStatic < 0 )
|
||||
pDest->item.asString.value = pDest->item.asString.u.value;
|
||||
pSource->type = HB_IT_NIL;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user