2001-07-31 10:10 UTC-0800 Ron Pinkas <ron@profit-master.com>

* source/vm/arrayshb.c
     + Added HB_FUNC( HB_AEXPRESSION )

   * source/rdd/dblist.prg
     - Removed FUNCTION HB_aExpressions()
This commit is contained in:
Ron Pinkas
2001-07-31 17:11:07 +00:00
parent 777a7beb3e
commit 0013eb731b
3 changed files with 105 additions and 89 deletions

View File

@@ -1,3 +1,10 @@
2001-07-31 10:10 UTC-0800 Ron Pinkas <ron@profit-master.com>
* source/vm/arrayshb.c
+ Added HB_FUNC( HB_AEXPRESSION )
* source/rdd/dblist.prg
- Removed FUNCTION HB_aExpressions()
2001-07-30 10:15 UTC-0800 Ron Pinkas <ron@profit-master.com>
* source/rdd/dblist.prg
- Removed HB_aTokens()

View File

@@ -159,92 +159,3 @@ FUNCTION __dbList( lOff, abEval, lAll, bFor, bWhile, nNext, nRecord, lRest, lToP
ENDIF
RETURN NIL
FUNCTION HB_aExpressions( cLine )
LOCAL aExpressions := {}
HB_INLINE( aExpressions, cLine )
{
PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
PHB_ITEM pLine = hb_param( 2, HB_IT_STRING );
size_t i, iOffset = 0, iIndex = 1;
int iParans = 0, iArrays = 0, iIndexs = 0;
BOOL bArray = FALSE;
for( i = 0; i < pLine->item.asString.length; i++ )
{
switch( pLine->item.asString.value[i] )
{
case '(' :
iParans++;
bArray = FALSE;
break;
case ')' :
iParans--;
bArray = TRUE;
break;
case '{' :
iArrays++;
bArray = FALSE;
break;
case '}' :
iArrays--;
bArray = TRUE;
break;
case '[' :
if( bArray || ( i && isalnum( pLine->item.asString.value[i - 1] ) ) )
{
iIndexs++;
}
else
{
while( ++i < pLine->item.asString.length && pLine->item.asString.value[i] != ']' );
}
bArray = FALSE;
break;
case ']' :
iIndexs--;
bArray = TRUE;
break;
case '"' :
while( ++i < pLine->item.asString.length && pLine->item.asString.value[i] != '"' );
bArray = FALSE;
break;
case '\'' :
while( ++i < pLine->item.asString.length && pLine->item.asString.value[i] != '\'' );
bArray = FALSE;
break;
case ',' :
if( iParans == 0 && iArrays == 0 && iIndexs == 0 )
{
hb_arraySize( pArray, iIndex );
hb_storclen( pLine->item.asString.value + iOffset, i - iOffset, 1, iIndex );
iOffset = i + 1;
iIndex++;
}
bArray = FALSE;
break;
default :
bArray = FALSE;
break;
}
}
if( iOffset < pLine->item.asString.length - 1 )
{
hb_arraySize( pArray, iIndex );
hb_storclen( pLine->item.asString.value + iOffset, pLine->item.asString.length - iOffset, 1, iIndex );
}
}
RETURN aExpressions

View File

@@ -50,6 +50,8 @@
*
*/
#include <ctype.h>
#include "hbapi.h"
#include "hbstack.h"
#include "hbapiitm.h"
@@ -313,3 +315,99 @@ HB_FUNC( HB_APARAMS )
hb_itemRelease( hb_itemReturn( hb_arrayFromParams( pBase ) ) );
}
HB_FUNC( HB_AEXPRESSIONS )
{
PHB_ITEM pArray = &hb_stack.Return;
PHB_ITEM pLine = hb_param( 1, HB_IT_STRING );
size_t i, iOffset = 0;
int iParans = 0, iArrays = 0, iIndexs = 0;
BOOL bArray = FALSE;
if( pLine == NULL )
{
hb_errRT_BASE_SubstR( EG_ARG, 1123, NULL, "HB_AEXPRESSIONS", 1, hb_paramError(1) );
return;
}
hb_arrayNew( pArray, 0 );
for( i = 0; i < pLine->item.asString.length; i++ )
{
switch( pLine->item.asString.value[i] )
{
case '(' :
iParans++;
bArray = FALSE;
break;
case ')' :
iParans--;
bArray = TRUE;
break;
case '{' :
iArrays++;
bArray = FALSE;
break;
case '}' :
iArrays--;
bArray = TRUE;
break;
case '[' :
if( bArray || ( i && isalnum( pLine->item.asString.value[i - 1] ) ) )
{
iIndexs++;
}
else
{
while( ++i < pLine->item.asString.length && pLine->item.asString.value[i] != ']' );
}
bArray = FALSE;
break;
case ']' :
iIndexs--;
bArray = TRUE;
break;
case '"' :
while( ++i < pLine->item.asString.length && pLine->item.asString.value[i] != '"' );
bArray = FALSE;
break;
case '\'' :
while( ++i < pLine->item.asString.length && pLine->item.asString.value[i] != '\'' );
bArray = FALSE;
break;
case ',' :
if( iParans == 0 && iArrays == 0 && iIndexs == 0 )
{
PHB_ITEM pExp = hb_itemNew( NULL );
hb_arrayAdd( pArray, hb_itemPutCL( pExp, pLine->item.asString.value + iOffset, i - iOffset ) );
iOffset = i + 1;
hb_itemRelease( pExp );
}
bArray = FALSE;
break;
default :
bArray = FALSE;
break;
}
}
if( iOffset < pLine->item.asString.length - 1 )
{
PHB_ITEM pExp = hb_itemNew( NULL );
hb_arrayAdd( pArray, hb_itemPutCL( pExp, pLine->item.asString.value + iOffset, pLine->item.asString.length - iOffset ) );
hb_itemRelease( pExp );
}
}