common

  Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic! Mail us feedback on this topic!  
c:\harbour\source\common
expropt1.c
TypeFunctionSourceLine
HB_EXPR_PTRhb_compExprClone( HB_EXPR_PTR pSrc )
HB_EXPR_PTR hb_compExprClone( HB_EXPR_PTR pSrc )
{
   pSrc->Counter++;
   return pSrc;
}
expropt1.c187
CONST CHAR *hb_compExprDescription( HB_EXPR_PTR pExpr )
const char * hb_compExprDescription( HB_EXPR_PTR pExpr )
{
   if( pExpr )
      return s_OperTable[ pExpr->ExprType ];
   else
      return s_OperTable[ 0 ];
}
expropt1.c196
INThb_compExprType( HB_EXPR_PTR pExpr )
int hb_compExprType( HB_EXPR_PTR pExpr )
{
   return ( int ) pExpr->ExprType;
}
expropt1.c204
INThb_compExprIsInteger( HB_EXPR_PTR pExpr )
int hb_compExprIsInteger( HB_EXPR_PTR pExpr )
{
   return ( pExpr->ExprType == HB_ET_NUMERIC && pExpr->value.asNum.NumType == HB_ET_LONG &&
            HB_LIM_INT16( pExpr->value.asNum.val.l ) );
}
expropt1.c209
INThb_compExprIsLong( HB_EXPR_PTR pExpr )
int hb_compExprIsLong( HB_EXPR_PTR pExpr )
{
   return ( pExpr->ExprType == HB_ET_NUMERIC && pExpr->value.asNum.NumType == HB_ET_LONG );
}
expropt1.c215
INThb_compExprIsString( HB_EXPR_PTR pExpr )
int hb_compExprIsString( HB_EXPR_PTR pExpr )
{
   return ( pExpr->ExprType == HB_ET_STRING );
}
expropt1.c220
CONST CHAR *hb_compExprAsString( HB_EXPR_PTR pExpr )
const char * hb_compExprAsString( HB_EXPR_PTR pExpr )
{
   if( pExpr->ExprType == HB_ET_STRING )
      return pExpr->value.asString.string;
   return NULL;
}
expropt1.c225
INThb_compExprAsStringLen( HB_EXPR_PTR pExpr )
int hb_compExprAsStringLen( HB_EXPR_PTR pExpr )
{
   if( pExpr->ExprType == HB_ET_STRING )
      return pExpr->ulLength;
   return 0;
}
expropt1.c232
INThb_compExprAsNumSign( HB_EXPR_PTR pExpr )
int hb_compExprAsNumSign( HB_EXPR_PTR pExpr )
{
   if( pExpr->ExprType == HB_ET_NUMERIC )
   {
      if( pExpr->value.asNum.NumType == HB_ET_DOUBLE )
      {
         if( pExpr->value.asNum.val.d > 0 )
            return 1;
         else if( pExpr->value.asNum.val.d < 0 )
            return -1;
      }
      else
      {
         if( pExpr->value.asNum.val.l > 0 )
            return 1;
         else if( pExpr->value.asNum.val.l < 0 )
            return -1;
      }
   }
   return 0;
}
expropt1.c239
INThb_compExprAsInteger( HB_EXPR_PTR pExpr )
int hb_compExprAsInteger( HB_EXPR_PTR pExpr )
{
   if( pExpr->ExprType == HB_ET_NUMERIC && pExpr->value.asNum.NumType == HB_ET_LONG )
      return ( int ) pExpr->value.asNum.val.l;
   else
      return 0;
}
expropt1.c261
HB_LONGhb_compExprAsLongNum( HB_EXPR_PTR pExpr )
HB_LONG hb_compExprAsLongNum( HB_EXPR_PTR pExpr )
{
   if( pExpr->ExprType == HB_ET_NUMERIC )
   {
      if( pExpr->value.asNum.NumType == HB_ET_LONG )
         return pExpr->value.asNum.val.l;
      else
         return ( HB_LONG ) pExpr->value.asNum.val.d;
   }
   else
      return 0;
}
expropt1.c269
CONST CHAR hb_compExprAsSymbol( HB_EXPR_PTR pExpr )
const char *hb_compExprAsSymbol( HB_EXPR_PTR pExpr )
{
   switch( pExpr->ExprType )
   {
      case HB_ET_VARIABLE:
      case HB_ET_VARREF:
      case HB_ET_FUNNAME:
         return pExpr->value.asSymbol;

      case HB_ET_FUNCALL:
         return pExpr->value.asFunCall.pFunName->value.asSymbol;
   }
   return NULL;
}
expropt1.c282
HB_EXPR_PTRhb_compExprNewEmpty( HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewEmpty( HB_COMP_DECL )
{
   return HB_COMP_EXPR_NEW( HB_ET_NONE );
}
expropt1.c299
HB_EXPR_PTRhb_compExprNewDouble( double dValue, BYTE ucWidth, BYTE ucDec, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewDouble( double dValue, BYTE ucWidth, BYTE ucDec,
                                  HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewDouble(%f, %i, %p)", dValue, ucDec, HB_COMP_PARAM));

   pExpr = HB_COMP_EXPR_NEW( HB_ET_NUMERIC );

   pExpr->value.asNum.val.d   = dValue;
   pExpr->value.asNum.bWidth  = ucWidth;
   pExpr->value.asNum.bDec    = ucDec;
   pExpr->value.asNum.NumType = HB_ET_DOUBLE;
   pExpr->ValType = HB_EV_NUMERIC;

   return pExpr;
}
expropt1.c304
HB_EXPR_PTRhb_compExprNewLong( HB_LONG lValue, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewLong( HB_LONG lValue, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewLong(%" PFHL "d, %p)", lValue, HB_COMP_PARAM));

   pExpr = HB_COMP_EXPR_NEW( HB_ET_NUMERIC );

   pExpr->value.asNum.val.l   = lValue;
   pExpr->value.asNum.bDec    = 0;
   pExpr->value.asNum.NumType = HB_ET_LONG;
   pExpr->ValType = HB_EV_NUMERIC;

   return pExpr;
}
expropt1.c322
HB_EXPR_PTRhb_compExprNewDate( HB_LONG lValue, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewDate( HB_LONG lValue, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewDate(%" PFHL "d, %p)", lValue, HB_COMP_PARAM));

   pExpr = HB_COMP_EXPR_NEW( HB_ET_DATE );

   pExpr->value.asNum.val.l = lValue;
   pExpr->ValType = HB_EV_DATE;

   return pExpr;
}
expropt1.c338
HB_EXPR_PTRhb_compExprNewString( const char *szValue, ULONG ulLen, BOOL fDealloc, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewString( const char *szValue, ULONG ulLen, BOOL fDealloc, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewString(%s)", szValue));

   pExpr = HB_COMP_EXPR_NEW( HB_ET_STRING );

   pExpr->value.asString.string = ( char * ) szValue;
   pExpr->value.asString.dealloc = fDealloc;
   pExpr->ulLength = ulLen;
   pExpr->ValType = HB_EV_STRING;

   return pExpr;
}
expropt1.c352
HB_EXPR_PTRhb_compExprNewArray( HB_EXPR_PTR pArrList, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewArray( HB_EXPR_PTR pArrList, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewArray()"));

   pArrList->ExprType = HB_ET_ARRAY;   /* change type from ET_LIST */
   pArrList->ValType  = HB_EV_ARRAY;
   pArrList->ulLength = 0;
   pArrList->value.asList.reference = FALSE;

   pExpr = pArrList->value.asList.pExprList;   /* get first element on the list */
   /* Now we need to replace all EO_NONE expressions with ET_NIL expressions
    * If EO_NONE is the first expression and there is no more expressions
    * then it is an empty array {} and ET_NIL cannot be used
    */
   if( pExpr->ExprType == HB_ET_NONE && pExpr->pNext == NULL )
   {
      pArrList->value.asList.pExprList = NULL;
      HB_COMP_EXPR_FREE( pExpr );
   }
   else
   {
      /* there are at least one non-empty element specified
       */
      while( pExpr )
      {
         /* if empty element was specified replace it with NIL value */
         if( pExpr->ExprType == HB_ET_NONE )
            pExpr->ExprType = HB_ET_NIL;
         pExpr = pExpr->pNext;
         ++pArrList->ulLength;
      }
   }
   pArrList->value.asList.pIndex = NULL;

   return pArrList;
}
expropt1.c368
HB_EXPR_PTRhb_compExprNewHash( HB_EXPR_PTR pHashList, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewHash( HB_EXPR_PTR pHashList, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewHash()"));

   if( pHashList )
      pHashList->ExprType = HB_ET_HASH;   /* change type from ET_LIST */
   else
   {
      pHashList = HB_COMP_EXPR_NEW( HB_ET_HASH );
      pHashList->value.asList.pExprList = NULL;
   }
   pHashList->ValType = HB_EV_HASH;
   pHashList->ulLength = 0;
   pHashList->value.asList.reference = FALSE;
   pHashList->value.asList.pIndex = NULL;

   /*
    * replace all EO_NONE expressions with ET_NIL expressions and
    * calculate the list length
    */
   pExpr = pHashList->value.asList.pExprList;
   while( pExpr )
   {
      if( pExpr->ExprType == HB_ET_NONE )
         pExpr->ExprType = HB_ET_NIL;
      pExpr = pExpr->pNext;
      ++pHashList->ulLength;
   }

   return pHashList;
}
expropt1.c410
HB_EXPR_PTRhb_compExprNewCodeBlock( char *string, ULONG ulLen, int iFlags, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewCodeBlock( char *string, ULONG ulLen, int iFlags, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewCodeBlock(%s,%lu,%d,%p)",string, ulLen, iFlags, HB_COMP_PARAM));

   pExpr = HB_COMP_EXPR_NEW( HB_ET_CODEBLOCK );

   pExpr->value.asCodeblock.pExprList = NULL;
   pExpr->value.asCodeblock.pLocals   = NULL;  /* this will hold local variables declarations */
   pExpr->ValType = HB_EV_CODEBLOCK;
   pExpr->value.asCodeblock.flags  = ( USHORT ) iFlags;
   pExpr->value.asCodeblock.string = string;
   pExpr->ulLength = ulLen;
   return pExpr;
}
expropt1.c447
HB_EXPR_PTRhb_compExprAddCodeblockExpr( HB_EXPR_PTR pList, HB_EXPR_PTR pNewItem )
HB_EXPR_PTR hb_compExprAddCodeblockExpr( HB_EXPR_PTR pList, HB_EXPR_PTR pNewItem )
{
   if( pList->value.asCodeblock.pExprList )
   {
      HB_EXPR_PTR pExpr;

      /* add new item to the end of the list */
      pExpr = pList->value.asCodeblock.pExprList;
      while( pExpr->pNext )
         pExpr = pExpr->pNext;
      pExpr->pNext = pNewItem;
   }
   else
      pList->value.asCodeblock.pExprList = pNewItem;

   return pList;
}
expropt1.c464
HB_EXPR_PTRhb_compExprNewLogical( int iValue, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewLogical( int iValue, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewLogical(%i,%p)", iValue, HB_COMP_PARAM));

   pExpr = HB_COMP_EXPR_NEW( HB_ET_LOGICAL );

   pExpr->value.asLogical = iValue;
   pExpr->ValType = HB_EV_LOGICAL;

   return pExpr;
}
expropt1.c482
HB_EXPR_PTRhb_compExprNewNil( HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewNil( HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewNil(%p)", HB_COMP_PARAM));

   pExpr = HB_COMP_EXPR_NEW( HB_ET_NIL );

   pExpr->ValType = HB_EV_NIL;
   return pExpr;
}
expropt1.c497
HB_EXPR_PTRhb_compExprNewSelf( HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewSelf( HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewSelf(%p)", HB_COMP_PARAM));

   pExpr = HB_COMP_EXPR_NEW( HB_ET_SELF );

   pExpr->ValType = HB_EV_OBJECT;
   return pExpr;
}
expropt1.c509
HB_EXPR_PTRhb_compExprNewVarRef( const char * szVarName, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewVarRef( const char * szVarName, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewVarRef(%s,%p)", szVarName, HB_COMP_PARAM));

   pExpr = HB_COMP_EXPR_NEW( HB_ET_VARREF );

   pExpr->value.asSymbol = szVarName;
   pExpr->ValType = HB_EV_VARREF;
   return pExpr;
}
expropt1.c521
HB_EXPR_PTRhb_compExprNewFunRef( const char * szFunName, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewFunRef( const char * szFunName, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewFunRef(%s,%p)", szFunName, HB_COMP_PARAM));

   pExpr = HB_COMP_EXPR_NEW( HB_ET_FUNREF );

   pExpr->value.asSymbol = szFunName;
   pExpr->ValType = HB_EV_FUNREF;
   return pExpr;
}
expropt1.c534
HB_EXPR_PTRhb_compExprNewRef( HB_EXPR_PTR pRefer, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewRef( HB_EXPR_PTR pRefer, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewRef(%p,%p)", pRefer, HB_COMP_PARAM));

   pExpr = HB_COMP_EXPR_NEW( HB_ET_REFERENCE );

   pExpr->value.asReference = pRefer;
   pExpr->ValType = HB_EV_VARREF;
   return pExpr;
}
expropt1.c547
HB_EXPR_PTRhb_compExprNewMacro( HB_EXPR_PTR pMacroExpr, unsigned char cMacroOp, const char * szName, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewMacro( HB_EXPR_PTR pMacroExpr,
                                 unsigned char cMacroOp, const char * szName,
                                 HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   pExpr = HB_COMP_EXPR_NEW( HB_ET_MACRO );
   if( szName )
   {
      HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewMacro(%s)", szName));

      /* Macro variable is used:  &identifier
       * or macro text: [text]&variable[more_macro_text]
       */
      /*
       * NOTE: Clipper assumes that all variables used in macro expressions
       * are memvar variables
       * NOTE: Clipper pushes the complete macro expression converted
       * to string in case complex expression is used, e.g.
       * My&var.1
       * is pushed as:
       * "MY&VAR.1"
       */
      pExpr->value.asMacro.cMacroOp  = cMacroOp; /* '&' if variable or 0 if text */
      pExpr->value.asMacro.szMacro   = szName;   /* variable name or macro text */
      pExpr->value.asMacro.pExprList = NULL;     /* this is not a parenthesized expressions */
      pExpr->value.asMacro.SubType   = HB_ET_MACRO_VAR;
   }
   else
   {
      HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewMacro(&)"));

      /* Macro expression:  &( expression_list )
       */
      pExpr->value.asMacro.cMacroOp  = 0;
      pExpr->value.asMacro.szMacro   = NULL; /* this is used to distinguish &(...) from &ident */
      pExpr->value.asMacro.pExprList = pMacroExpr;
      pExpr->value.asMacro.SubType   = HB_ET_MACRO_EXPR;
   }

   return pExpr;
}
expropt1.c560
HB_EXPR_PTRhb_compExprNewAliasVar( HB_EXPR_PTR pAlias, HB_EXPR_PTR pVariable, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewAliasVar( HB_EXPR_PTR pAlias, HB_EXPR_PTR pVariable,
                                    HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewAliasVar()"));

   pExpr = HB_COMP_EXPR_NEW( HB_ET_ALIASVAR );

   pExpr->value.asAlias.pAlias    = pAlias;
   pExpr->value.asAlias.pVar      = pVariable;
   pExpr->value.asAlias.pExpList  = NULL;

   /* macro expressions in alias context require a special handling
    */
   if( pAlias->ExprType == HB_ET_MACRO )
      pAlias->value.asMacro.SubType = HB_ET_MACRO_ALIASED;
   if( pVariable->ExprType == HB_ET_MACRO )
      pVariable->value.asMacro.SubType = HB_ET_MACRO_ALIASED;

   return pExpr;
}
expropt1.c605
HB_EXPR_PTRhb_compExprNewAliasExpr( HB_EXPR_PTR pAlias, HB_EXPR_PTR pExpList, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewAliasExpr( HB_EXPR_PTR pAlias, HB_EXPR_PTR pExpList,
                                     HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewAliasExpr()"));

   pExpr = HB_COMP_EXPR_NEW( HB_ET_ALIASEXPR );

   pExpr->value.asAlias.pAlias    = pAlias;
   pExpr->value.asAlias.pExpList  = pExpList;
   pExpr->value.asAlias.pVar      = NULL;
   
   if( pAlias->ExprType == HB_ET_MACRO )
   {
      /* Is it a special case &variable->( expressionList ) */
      if( pAlias->value.asMacro.SubType == HB_ET_MACRO_VAR ||
          pAlias->value.asMacro.SubType == HB_ET_MACRO_EXPR )
        pAlias->value.asMacro.SubType = HB_ET_MACRO_ALIASED;
   }

   return pExpr;
}
expropt1.c631
HB_EXPR_PTRhb_compExprNewMethodCall( HB_EXPR_PTR pObject, HB_EXPR_PTR pArgList )
HB_EXPR_PTR hb_compExprNewMethodCall( HB_EXPR_PTR pObject, HB_EXPR_PTR pArgList )
{
   pObject->value.asMessage.pParms = pArgList;

   return pObject;
}
expropt1.c658
HB_EXPR_PTRhb_compExprNewIIF( HB_EXPR_PTR pExpr )
HB_EXPR_PTR hb_compExprNewIIF( HB_EXPR_PTR pExpr )
{
   pExpr->ExprType = HB_ET_IIF;

   return pExpr;
}
expropt1.c672
HB_EXPR_PTRhb_compExprNewList( HB_EXPR_PTR pFirstItem, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewList( HB_EXPR_PTR pFirstItem, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewList()"));

   pExpr = HB_COMP_EXPR_NEW( HB_ET_LIST );
   pExpr->value.asList.pExprList = pFirstItem;
   pExpr->value.asList.reference = FALSE;
   return pExpr;
}
expropt1.c682
HB_EXPR_PTRhb_compExprNewArgList( HB_EXPR_PTR pFirstItem, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewArgList( HB_EXPR_PTR pFirstItem, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewArgList()"));

   pExpr = HB_COMP_EXPR_NEW( HB_ET_ARGLIST );
   pExpr->value.asList.pExprList = pFirstItem;
   pExpr->value.asList.reference = FALSE;
   return pExpr;
}
expropt1.c697
HB_EXPR_PTRhb_compExprNewArgRef( HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewArgRef( HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewArgRef()"));

   pExpr = HB_COMP_EXPR_NEW( HB_ET_ARGLIST );
   pExpr->value.asList.pExprList = NULL;
   pExpr->value.asList.reference = TRUE;
   return pExpr;
}
expropt1.c711
HB_EXPR_PTRhb_compExprNewMacroArgList( HB_EXPR_PTR pFirstItem, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewMacroArgList( HB_EXPR_PTR pFirstItem, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewMacroArgList()"));

   pExpr = HB_COMP_EXPR_NEW( HB_ET_MACROARGLIST );
   pExpr->value.asList.pExprList = pFirstItem;
   pExpr->value.asList.reference = FALSE;
   return pExpr;
}
expropt1.c725
HB_EXPR_PTRhb_compExprAddListExpr( HB_EXPR_PTR pList, HB_EXPR_PTR pNewItem )
HB_EXPR_PTR hb_compExprAddListExpr( HB_EXPR_PTR pList, HB_EXPR_PTR pNewItem )
{
   if( pList->value.asList.pExprList )
   {
      HB_EXPR_PTR pExpr;

      /* add new item to the end of the list */
      pExpr = pList->value.asList.pExprList;
      while( pExpr->pNext )
         pExpr = pExpr->pNext;
      pExpr->pNext = pNewItem;
   }
   else
      pList->value.asList.pExprList = pNewItem;

   return pList;
}
expropt1.c739
HB_EXPR_PTRhb_compExprNewVar( const char * szName, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewVar( const char * szName, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewVar(%s,%p)", szName, HB_COMP_PARAM));

   pExpr = HB_COMP_EXPR_NEW( HB_ET_VARIABLE );
   pExpr->value.asSymbol = szName;
   return pExpr;
}
expropt1.c759
HB_EXPR_PTRhb_compExprNewRTVar( const char * szName, HB_EXPR_PTR pMacroVar, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewRTVar( const char * szName, HB_EXPR_PTR pMacroVar,
                                 HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewRTVar(%s, %p, %p)", szName, pMacroVar, HB_COMP_PARAM));

   pExpr = HB_COMP_EXPR_NEW( HB_ET_RTVAR );
   pExpr->value.asRTVar.szName = szName;
   pExpr->value.asRTVar.pMacro = pMacroVar;
   if( pMacroVar )
      pMacroVar->value.asMacro.SubType = HB_ET_MACRO_SYMBOL;
   return pExpr;
}
expropt1.c770
HB_EXPR_PTRhb_compExprNewFunName( const char * szName, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewFunName( const char * szName, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewFunName(%s,%p)", szName, HB_COMP_PARAM));

   pExpr = HB_COMP_EXPR_NEW( HB_ET_FUNNAME );
   pExpr->value.asSymbol = szName;
   return pExpr;
}
expropt1.c790
HB_EXPR_PTRhb_compExprNewAlias( const char * szName, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewAlias( const char * szName, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewAlias(%s,%p)", szName, HB_COMP_PARAM));

   pExpr = HB_COMP_EXPR_NEW( HB_ET_ALIAS );
   pExpr->value.asSymbol = szName;
   return pExpr;
}
expropt1.c803
HB_EXPR_PTRhb_compExprNewEqual( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewEqual( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_EQUAL );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c819
HB_EXPR_PTRhb_compExprNewPlus( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewPlus( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_PLUS );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c827
HB_EXPR_PTRhb_compExprNewMinus( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewMinus( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_MINUS );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c835
HB_EXPR_PTRhb_compExprNewMult( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewMult( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_MULT );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c843
HB_EXPR_PTRhb_compExprNewDiv( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewDiv( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_DIV );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c851
HB_EXPR_PTRhb_compExprNewMod( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewMod( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_MOD );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c859
HB_EXPR_PTRhb_compExprNewPower( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewPower( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_POWER );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c867
HB_EXPR_PTRhb_compExprNewPostInc( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewPostInc( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_POSTINC );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c875
HB_EXPR_PTRhb_compExprNewPostDec( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewPostDec( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_POSTDEC );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c883
HB_EXPR_PTRhb_compExprNewPreInc( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewPreInc( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_PREINC );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c891
HB_EXPR_PTRhb_compExprNewPreDec( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewPreDec( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_PREDEC );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c899
HB_EXPR_PTRhb_compExprNewPlusEq( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewPlusEq( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_PLUSEQ );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c907
HB_EXPR_PTRhb_compExprNewMinusEq( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewMinusEq( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_MINUSEQ );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c915
HB_EXPR_PTRhb_compExprNewMultEq( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewMultEq( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_MULTEQ );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c923
HB_EXPR_PTRhb_compExprNewDivEq( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewDivEq( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_DIVEQ );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c931
HB_EXPR_PTRhb_compExprNewModEq( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewModEq( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_MODEQ );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c939
HB_EXPR_PTRhb_compExprNewExpEq( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewExpEq( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_EXPEQ );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c947
HB_EXPR_PTRhb_compExprNewAnd( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewAnd( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_AND );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c955
HB_EXPR_PTRhb_compExprNewOr( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewOr( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_OR );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c963
HB_EXPR_PTRhb_compExprNewNot( HB_EXPR_PTR pNotExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewNot( HB_EXPR_PTR pNotExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   if( pNotExpr->ExprType == HB_ET_LOGICAL )
   {
      pNotExpr->value.asLogical = ! pNotExpr->value.asLogical;
      pExpr = pNotExpr;
   }
   else
   {
      pExpr = HB_COMP_EXPR_NEW( HB_EO_NOT );
      pExpr->value.asOperator.pLeft  = pNotExpr;
      pExpr->value.asOperator.pRight = NULL;
   }

   return pExpr;
}
expropt1.c971
HB_EXPR_PTRhb_compExprNewEQ( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewEQ( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_EQ );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c990
HB_EXPR_PTRhb_compExprNewLT( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewLT( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_LT );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c998
HB_EXPR_PTRhb_compExprNewGT( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewGT( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_GT );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c1006
HB_EXPR_PTRhb_compExprNewLE( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewLE( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_LE );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c1014
HB_EXPR_PTRhb_compExprNewGE( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewGE( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_GE );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c1022
HB_EXPR_PTRhb_compExprNewNE( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewNE( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_NE );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c1030
HB_EXPR_PTRhb_compExprNewIN( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewIN( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_IN );
   pExpr->value.asOperator.pLeft = pLeftExpr;
   pExpr->value.asOperator.pRight = NULL;
   return pExpr;
}
expropt1.c1038
HB_EXPR_PTRhb_compExprNewNegate( HB_EXPR_PTR pNegExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprNewNegate( HB_EXPR_PTR pNegExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   if( pNegExpr->ExprType == HB_ET_NUMERIC )
   {
      if( pNegExpr->value.asNum.NumType == HB_ET_DOUBLE )
      {
         pNegExpr->value.asNum.val.d = - pNegExpr->value.asNum.val.d;
         pNegExpr->value.asNum.bWidth = ( UCHAR ) HB_DBL_LENGTH( pNegExpr->value.asNum.val.d );
      }
      else
      {
#if -HB_LONG_MAX > HB_LONG_MIN
         if( pNegExpr->value.asNum.val.l < -HB_LONG_MAX )
         {
            pNegExpr->value.asNum.NumType = HB_ET_DOUBLE;
            pNegExpr->value.asNum.val.d = - ( double ) pNegExpr->value.asNum.val.l;
            pNegExpr->value.asNum.bWidth = ( UCHAR ) HB_DBL_LENGTH( pNegExpr->value.asNum.val.d );
            pNegExpr->value.asNum.bDec = 0;
         }
         else
#endif
         {
            pNegExpr->value.asNum.val.l = - pNegExpr->value.asNum.val.l;
            pNegExpr->value.asNum.bWidth = HB_DEFAULT_WIDTH;
         }
      }
      pExpr = pNegExpr;
   }
   else
   {
      pExpr = HB_COMP_EXPR_NEW( HB_EO_NEGATE );
      pExpr->value.asOperator.pLeft = pNegExpr;
      pExpr->value.asOperator.pRight = NULL;
   }
   return pExpr;
}
expropt1.c1046
HB_EXPR_PTRhb_compExprAssign( HB_EXPR_PTR pLeftExpr, HB_EXPR_PTR pRightExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprAssign( HB_EXPR_PTR pLeftExpr, HB_EXPR_PTR pRightExpr,
                               HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprAssign()"));

   pExpr = HB_COMP_EXPR_NEW( HB_EO_ASSIGN );
   pExpr->value.asOperator.pLeft  = pLeftExpr;
   pExpr->value.asOperator.pRight = pRightExpr;
   return pExpr;
}
expropt1.c1087
VOIDhb_compExprDelOperator( HB_EXPR_PTR pExpr, HB_COMP_DECL )
void hb_compExprDelOperator( HB_EXPR_PTR pExpr, HB_COMP_DECL )
{
   if( pExpr->value.asOperator.pLeft )
      HB_COMP_EXPR_FREE( pExpr->value.asOperator.pLeft );
   if( pExpr->value.asOperator.pRight )
      HB_COMP_EXPR_FREE( pExpr->value.asOperator.pRight );
}
expropt1.c1102
HB_EXPR_PTRhb_compExprSetOperand( HB_EXPR_PTR pExpr, HB_EXPR_PTR pItem, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprSetOperand( HB_EXPR_PTR pExpr, HB_EXPR_PTR pItem, HB_COMP_DECL )
{
   BYTE ucRight;

   ucRight = s_PrecedTable[ pItem->ExprType ];

   if( ucRight == HB_ET_NIL )
   {
      /* the right side of an operator is an ordinary value
       * e.g. a := 1
       */
      pExpr->value.asOperator.pRight = pItem;
   }
   else if( ucRight == HB_ET_NONE )
   {
      /* the right side of an operator is an invalid expression
       * e.g.
       *    a := 1 + b:=2
       *    a := 1 + b += 2
       */

      if( pExpr->ExprType >= HB_EO_PLUSEQ && pExpr->ExprType <= HB_EO_EXPEQ )
      {
      }
      else
      {
         HB_COMP_ERROR_SYNTAX( pItem );
      }
      pExpr->value.asOperator.pRight = pItem; /* set it anyway */
   }
   else
   {
      /* the right side of an operator is an expression with other operator
       * e.g. a := 2 + b * 3
       *   We have to set the proper order of evaluation using
       * precedence rules
       */
      BYTE ucLeft = s_PrecedTable[ pExpr->ExprType ];
      if( ucLeft < ucRight ||
          ( ucLeft == ucRight && HB_COMP_ISSUPPORTED( HB_COMPFLAG_SHORTCUTS ) &&
            ( ucLeft == HB_EO_OR || ucLeft == HB_EO_AND ) ) )
      {
         /* Left operator has a lower precedence then the right one
          * e.g.  a + b * c
          *    pItem -> b * c    -> L=b  R=c  O=*
          *    pExpr -> a +      -> l=a  r=   o=+
          *
          *    -> a + (b * c)    -> Left=a  Right=(b * c)  Oper=+
          *             Left  := l
          *             Right := L (O) R  := pItem
          *             Oper  := o
          */
         pExpr->value.asOperator.pRight = pItem;
      }
      else
      {
         /* Left operator has the same or higer precedence then the right one
          * e.g.  a * b + c
          *    pItem -> b + c   -> L=b  R=c  O=+
          *    pExpr -> a *     -> l=a  r=   o=*
          *
          *    -> (a * b) + c    -> Lelf=(a * b)  Right=c  Oper=+
          *             Left  := l (o) L
          *             Right := R
          *             Oper  := O
          */
         pItem->value.asOperator.pLeft = hb_compExprSetOperand( pExpr, pItem->value.asOperator.pLeft, HB_COMP_PARAM );
         pExpr = pItem;
      }
   }

   return pExpr;
}
expropt1.c1110
HB_EXPR_PTRhb_compExprMacroAsAlias( HB_EXPR_PTR pExpr )
HB_EXPR_PTR hb_compExprMacroAsAlias( HB_EXPR_PTR pExpr )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_compExprMacroAsAlias()"));

   if( pExpr->ExprType == HB_ET_VARIABLE )
      pExpr->ExprType = HB_ET_ALIAS;

   return pExpr;
}
expropt1.c1189
ULONGhb_compExprListLen( HB_EXPR_PTR pExpr )
ULONG hb_compExprListLen( HB_EXPR_PTR pExpr )
{
   ULONG ulLen = 0;

   pExpr = pExpr->value.asList.pExprList;
   while( pExpr )
   {
      pExpr = pExpr->pNext;
      ++ulLen;
   }

   return ulLen;
}
expropt1.c1202
ULONGhb_compExprParamListLen( HB_EXPR_PTR pExpr )
ULONG hb_compExprParamListLen( HB_EXPR_PTR pExpr )
{
   ULONG ulLen = 0;

   if( pExpr )
   {
      HB_EXPR_PTR pParam = pExpr->value.asList.pExprList;
      while( pParam )
      {
         pParam = pParam->pNext;
         ++ulLen;
      }
      /* NOTE: if method or function with no parameters is called then the
       * list of parameters contain only one expression of type HB_ET_NONE
       * There is no need to calculate this parameter
       */
      if( ulLen == 1 && pExpr->value.asList.pExprList->ExprType == HB_ET_NONE )
         ulLen = 0;
   }

   return ulLen;
}
expropt1.c1218
ULONGhb_compExprMacroListLen( HB_EXPR_PTR pExpr )
ULONG hb_compExprMacroListLen( HB_EXPR_PTR pExpr )
{
   ULONG ulLen = 0, ulItems = 0;

   pExpr = pExpr->value.asList.pExprList;
   while( pExpr )
   {
      if( pExpr->ExprType == HB_ET_MACRO &&
          ( pExpr->value.asMacro.SubType & HB_ET_MACRO_LIST ) )
      {
         if( ulItems )
         {
            ulItems = 0;
            ++ulLen;
         }
         ++ulLen;
      }
      else
         ++ulItems;
      pExpr = pExpr->pNext;
   }
   if( ulItems )
      ++ulLen;

   return ulLen;
}
expropt1.c1243
ULONGhb_compExprParamListCheck( HB_COMP_DECL, HB_EXPR_PTR pExpr )
ULONG hb_compExprParamListCheck( HB_COMP_DECL, HB_EXPR_PTR pExpr )
{
   ULONG ulLen = 0, ulItems = 0;
   if( pExpr )
   {
      HB_EXPR_PTR pElem;

      pElem = pExpr->value.asList.pExprList;
      while( pElem )
      {
         if( ( pElem->ExprType == HB_ET_MACRO && HB_SUPPORT_XBASE &&
               pElem->value.asMacro.SubType != HB_ET_MACRO_SYMBOL &&
               pElem->value.asMacro.SubType != HB_ET_MACRO_REFER &&
               pElem->value.asMacro.SubType != HB_ET_MACRO_ALIASED ) ||
             ( pElem->ExprType == HB_ET_ARGLIST &&
               pElem->value.asList.reference ) )
         {
            /* ¯o was passed
               or optional parameters list passed, f.e.: f(a,b,...)
               - handle it differently then in a normal statement */
            if( pElem->ExprType == HB_ET_MACRO )
               pElem->value.asMacro.SubType |= HB_ET_MACRO_LIST;
            if( ulItems )
            {
               ulItems = 0;
               ++ulLen;
            }
            ++ulLen;
         }
         else
            ++ulItems;
         pElem = pElem->pNext;
      }

      if( ulLen )
      {
         if( ulItems )
            ++ulLen;
         /* Note: direct type change */
         pExpr->ExprType = HB_ET_MACROARGLIST;
      }
      /* NOTE: if method or function with no parameters is called then the
       * list of parameters contain only one expression of type HB_ET_NONE
       * There is no need to calculate this parameter
       */
      else if( ulItems == 1 &&
               pExpr->value.asList.pExprList->ExprType == HB_ET_NONE )
         ulLen = 0;
      else
         ulLen = ulItems;
   }

   return ulLen;
}
expropt1.c1272
STATIC HB_CBVAR_PTRhb_compExprCBVarNew( const char * szVarName, BYTE bType )
static HB_CBVAR_PTR hb_compExprCBVarNew( const char * szVarName, BYTE bType )
{
   HB_CBVAR_PTR pVar;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprCBVarNew(%s)", szVarName));

   pVar = ( HB_CBVAR_PTR ) hb_xgrab( sizeof( HB_CBVAR ) );

   pVar->szName = szVarName;
   pVar->bType  = bType;
   pVar->pNext  = NULL;
   pVar->bUsed  = FALSE;

   return pVar;
}
expropt1.c1327
HB_EXPR_PTRhb_compExprCBVarAdd( HB_EXPR_PTR pCB, const char * szVarName, BYTE bType, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprCBVarAdd( HB_EXPR_PTR pCB, const char * szVarName, BYTE bType,
                                 HB_COMP_DECL )
{
   HB_CBVAR_PTR pVar;

   HB_TRACE(HB_TR_DEBUG, ("hb_compExprCBVarAdd(%s)", szVarName));

   if( pCB->value.asCodeblock.pLocals )
   {
      /* add it to the end of the list
      */
      pVar = pCB->value.asCodeblock.pLocals;
      while( pVar )
      {
         if( strcmp( szVarName, pVar->szName ) == 0 )
            HB_COMP_ERROR_DUPLVAR( szVarName );

         if( pVar->pNext )
            pVar = pVar->pNext;
         else
         {
            pVar->pNext = hb_compExprCBVarNew( szVarName, bType );
            break;
         }
      }
   }
   else
      pCB->value.asCodeblock.pLocals = hb_compExprCBVarNew( szVarName, bType );

   return pCB;
}
expropt1.c1345
VOIDhb_compExprCBVarDel( HB_CBVAR_PTR pVars )
void hb_compExprCBVarDel( HB_CBVAR_PTR pVars )
{
   HB_CBVAR_PTR pDel;

   while( pVars )
   {
      pDel  = pVars;
      pVars = pVars->pNext;
      hb_xfree( pDel );
   }
}
expropt1.c1379
HB_EXPR_PTRhb_compExprSetGetBlock( HB_EXPR_PTR pExpr, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprSetGetBlock( HB_EXPR_PTR pExpr, HB_COMP_DECL )
{
   HB_EXPR_PTR pIIF;
   HB_EXPR_PTR pSet;

   /* create {|var|  expression 
    * NOTE: this is not a valid variable name so there will be no collisions
   */
   /* create var==NIL */
   pIIF = hb_compExprSetOperand( hb_compExprNewEQ( hb_compExprNewVar( "~1", HB_COMP_PARAM ), HB_COMP_PARAM ),
                                 hb_compExprNewNil( HB_COMP_PARAM ), HB_COMP_PARAM );
   /* create ( var==NIL, */
   pIIF = hb_compExprNewList( pIIF, HB_COMP_PARAM );
   /* create ( var==NIL, , */
   pIIF = hb_compExprAddListExpr( pIIF, pExpr );
   /* create var */
   pSet =hb_compExprNewVar( "~1", HB_COMP_PARAM );           
   /* create :=var */
   pSet = hb_compExprAssign( hb_compExprClone( pExpr ), pSet, HB_COMP_PARAM );
   /* create ( var==nil, , :=var ) */
   pIIF = hb_compExprAddListExpr( pIIF, pSet );
   /* create IIF() expression */
   pIIF = hb_compExprNewIIF( pIIF );
   /* create a codeblock
   */
   return hb_compExprAddCodeblockExpr( hb_compExprCBVarAdd(
                     hb_compExprNewCodeBlock( NULL, 0, 0, HB_COMP_PARAM ),
                     "~1", ' ', HB_COMP_PARAM ), pIIF );
}
expropt1.c1393
expropt2.c
TypeFunctionSourceLine
STATIC HB_EXPR_PTRhb_compExprReducePlusStrings( HB_EXPR_PTR pLeft, HB_EXPR_PTR pRight, HB_COMP_DECL )
static HB_EXPR_PTR hb_compExprReducePlusStrings( HB_EXPR_PTR pLeft, HB_EXPR_PTR pRight, HB_COMP_DECL )
{
   if( pLeft->value.asString.dealloc )
   {
      pLeft->value.asString.string = (char *) hb_xrealloc( pLeft->value.asString.string, pLeft->ulLength + pRight->ulLength + 1 );
      memcpy( pLeft->value.asString.string + pLeft->ulLength,
              pRight->value.asString.string, pRight->ulLength );
      pLeft->ulLength += pRight->ulLength;
      pLeft->value.asString.string[ pLeft->ulLength ] = '\0';
   }
   else
   {
      char *szString;
      szString = (char *) hb_xgrab( pLeft->ulLength + pRight->ulLength + 1 );
      memcpy( szString, pLeft->value.asString.string, pLeft->ulLength );
      memcpy( szString + pLeft->ulLength, pRight->value.asString.string, pRight->ulLength );
      pLeft->ulLength += pRight->ulLength;
      szString[ pLeft->ulLength ] = '\0';
      pLeft->value.asString.string = szString;
      pLeft->value.asString.dealloc = TRUE;
   }
   HB_COMP_EXPR_FREE( pRight );
   return pLeft;
}
expropt2.c63
STATIC HB_EXPR_PTRhb_compExprReduceMinusStrings( HB_EXPR_PTR pLeft, HB_EXPR_PTR pRight, HB_COMP_DECL )
static HB_EXPR_PTR hb_compExprReduceMinusStrings( HB_EXPR_PTR pLeft, HB_EXPR_PTR pRight, HB_COMP_DECL )
{
   char * szText = pLeft->value.asString.string;
   ULONG ulLen = pLeft->ulLength;

   while( ulLen && szText[ ulLen - 1 ] == ' ' )
      --ulLen;

   if( pLeft->value.asString.dealloc )
   {
      pLeft->value.asString.string = (char *) hb_xrealloc( pLeft->value.asString.string, pLeft->ulLength + pRight->ulLength + 1 );
      memcpy( pLeft->value.asString.string + ulLen,
              pRight->value.asString.string, pRight->ulLength );
      memset( pLeft->value.asString.string + ulLen + pRight->ulLength, ' ',
              pLeft->ulLength - ulLen );
      pLeft->ulLength += pRight->ulLength;
      pLeft->value.asString.string[ pLeft->ulLength ] = '\0';
   }
   else
   {
      char *szString;
      szString = (char *) hb_xgrab( pLeft->ulLength + pRight->ulLength + 1 );
      memcpy( szString, pLeft->value.asString.string, ulLen );
      memcpy( szString + ulLen, pRight->value.asString.string, pRight->ulLength );
      memset( szString + ulLen + pRight->ulLength, ' ', pLeft->ulLength - ulLen );
      pLeft->ulLength += pRight->ulLength;
      szString[ pLeft->ulLength ] = '\0';
      pLeft->value.asString.string = szString;
      pLeft->value.asString.dealloc = TRUE;
   }
   HB_COMP_EXPR_FREE( pRight );
   return pLeft;
}
expropt2.c88
HB_EXPR_PTRhb_compExprReduceMod( HB_EXPR_PTR pSelf, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprReduceMod( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pLeft, pRight;

   pLeft  = pSelf->value.asOperator.pLeft;
   pRight = pSelf->value.asOperator.pRight;

   if( pLeft->ExprType == HB_ET_NUMERIC && pRight->ExprType == HB_ET_NUMERIC )
   {
      switch( pLeft->value.asNum.NumType & pRight->value.asNum.NumType )
      {
         case HB_ET_LONG:
            if( pRight->value.asNum.val.l )
            {
               pSelf->value.asNum.val.l = pLeft->value.asNum.val.l % pRight->value.asNum.val.l;
               pSelf->value.asNum.bDec = 0;
               pSelf->value.asNum.NumType = HB_ET_LONG;
               pSelf->ExprType = HB_ET_NUMERIC;
               pSelf->ValType  = HB_EV_NUMERIC;
               HB_COMP_EXPR_FREE( pLeft );
               HB_COMP_EXPR_FREE( pRight );
            }
            break;

         default:
            if( HB_SUPPORT_HARBOUR )
            {
               double dValue, dDivisor;

               dDivisor = pRight->value.asNum.NumType == HB_ET_LONG ?
                          pRight->value.asNum.val.l :
                          pRight->value.asNum.val.d;
               if( dDivisor )
               {
                  dValue = pLeft->value.asNum.NumType == HB_ET_LONG ?
                           pLeft->value.asNum.val.l :
                           pLeft->value.asNum.val.d;
                  pSelf->value.asNum.val.d = fmod( dValue, dDivisor );
                  pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
                  pSelf->value.asNum.bDec = HB_DEFAULT_DECIMALS;
                  pSelf->value.asNum.NumType = HB_ET_DOUBLE;
                  pSelf->ExprType = HB_ET_NUMERIC;
                  pSelf->ValType  = HB_EV_NUMERIC;
                  HB_COMP_EXPR_FREE( pLeft );
                  HB_COMP_EXPR_FREE( pRight );
               }
            }
      }
   }
   else
   {
      /* TODO: Check for incompatible types e.g.  3 % "txt"
      */
   }
   return pSelf;
}
expropt2.c122
HB_EXPR_PTRhb_compExprReduceDiv( HB_EXPR_PTR pSelf, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprReduceDiv( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pLeft, pRight;

   pLeft  = pSelf->value.asOperator.pLeft;
   pRight = pSelf->value.asOperator.pRight;

   if( pLeft->ExprType == HB_ET_NUMERIC && pRight->ExprType == HB_ET_NUMERIC )
   {
      BYTE bType = ( pLeft->value.asNum.NumType & pRight->value.asNum.NumType );

      switch( bType )
      {
         case HB_ET_LONG:

            if( pRight->value.asNum.val.l )
            {
               if( pLeft->value.asNum.val.l % pRight->value.asNum.val.l == 0 )
               {
                  /* Return integer results as long */
                  pSelf->value.asNum.val.l = pLeft->value.asNum.val.l / pRight->value.asNum.val.l;
                  pSelf->value.asNum.bDec = 0;
                  pSelf->value.asNum.NumType = HB_ET_LONG;
               }
               else
               {
                  /* Return non-integer results as double */
                  pSelf->value.asNum.val.d = ( double ) pLeft->value.asNum.val.l / ( double ) pRight->value.asNum.val.l;
                  pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
                  pSelf->value.asNum.bDec = HB_DEFAULT_DECIMALS;
                  pSelf->value.asNum.NumType = HB_ET_DOUBLE;
               }
               pSelf->ExprType = HB_ET_NUMERIC;
            }
            break;

         case HB_ET_DOUBLE:

            if( pRight->value.asNum.val.d != 0.0 )
            {
               pSelf->value.asNum.val.d = pLeft->value.asNum.val.d / pRight->value.asNum.val.d;
               pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
               pSelf->value.asNum.bDec = HB_DEFAULT_DECIMALS;
               pSelf->value.asNum.NumType = HB_ET_DOUBLE;
               pSelf->ExprType = HB_ET_NUMERIC;
            }
            break;

         default:

            if( pLeft->value.asNum.NumType == HB_ET_DOUBLE )
            {
               if( pRight->value.asNum.val.l )
               {
                  pSelf->value.asNum.val.d = pLeft->value.asNum.val.d / ( double ) pRight->value.asNum.val.l;
                  pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
                  pSelf->value.asNum.bDec = HB_DEFAULT_DECIMALS;
               }
            }
            else
            {
               if( pRight->value.asNum.val.d != 0.0 )
               {
                  pSelf->value.asNum.val.d = ( double ) pLeft->value.asNum.val.l / pRight->value.asNum.val.d;
                  pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
                  pSelf->value.asNum.bDec = HB_DEFAULT_DECIMALS;
               }
            }

            pSelf->value.asNum.NumType = HB_ET_DOUBLE;
            pSelf->ExprType = HB_ET_NUMERIC;

      } /* switch bType */

      if( pSelf->ExprType == HB_ET_NUMERIC )
      {
         /* The expression was reduced - delete old components */
         pSelf->ValType = HB_EV_NUMERIC;
         HB_COMP_EXPR_FREE( pLeft );
         HB_COMP_EXPR_FREE( pRight );
      }
   }
   else
   {
      /* TODO: Check for incompatible types e.g.  3 / "txt"
      */
   }
   return pSelf;
}
expropt2.c179
HB_EXPR_PTRhb_compExprReduceMult( HB_EXPR_PTR pSelf, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprReduceMult( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pLeft, pRight;

   pLeft  = pSelf->value.asOperator.pLeft;
   pRight = pSelf->value.asOperator.pRight;

   if( pLeft->ExprType == HB_ET_NUMERIC && pRight->ExprType == HB_ET_NUMERIC )
   {
      BYTE bType = ( pLeft->value.asNum.NumType & pRight->value.asNum.NumType );

      switch( bType )
      {
         case HB_ET_LONG:
         {
            HB_MAXDBL dVal = ( HB_MAXDBL ) pLeft->value.asNum.val.l * ( HB_MAXDBL ) pRight->value.asNum.val.l;

            if( HB_DBL_LIM_LONG( dVal ) )
            {
               pSelf->value.asNum.val.l = pLeft->value.asNum.val.l * pRight->value.asNum.val.l;
               pSelf->value.asNum.bDec = 0;
               pSelf->value.asNum.NumType = HB_ET_LONG;
            }
            else
            {
               pSelf->value.asNum.val.d = ( double ) dVal;
               pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
               pSelf->value.asNum.bDec = 0;
               pSelf->value.asNum.NumType = HB_ET_DOUBLE;
            }

            break;
         }

         case HB_ET_DOUBLE:
         {
            pSelf->value.asNum.val.d = pLeft->value.asNum.val.d * pRight->value.asNum.val.d;
            pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
            pSelf->value.asNum.bDec = ( UCHAR ) ( pLeft->value.asNum.bDec + pRight->value.asNum.bDec );
            pSelf->value.asNum.NumType = HB_ET_DOUBLE;

            break;
         }

         default:
         {
            if( pLeft->value.asNum.NumType == HB_ET_DOUBLE )
            {
               pSelf->value.asNum.val.d = pLeft->value.asNum.val.d * ( double ) pRight->value.asNum.val.l;
               pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
               pSelf->value.asNum.bDec = pLeft->value.asNum.bDec;
            }
            else
            {
               pSelf->value.asNum.val.d = ( double ) pLeft->value.asNum.val.l * pRight->value.asNum.val.d;
               pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
               pSelf->value.asNum.bDec = pRight->value.asNum.bDec;
            }
            pSelf->value.asNum.NumType = HB_ET_DOUBLE;
         }
      }
      pSelf->ExprType = HB_ET_NUMERIC;
      pSelf->ValType  = HB_EV_NUMERIC;
      HB_COMP_EXPR_FREE( pLeft );
      HB_COMP_EXPR_FREE( pRight );
   }
   else
   {
      /* TODO: Check for incompatible types e.g. 3 * "txt"
      */
   }
   return pSelf;
}
expropt2.c269
HB_EXPR_PTRhb_compExprReducePower( HB_EXPR_PTR pSelf, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprReducePower( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pLeft, pRight;

   pLeft  = pSelf->value.asOperator.pLeft;
   pRight = pSelf->value.asOperator.pRight;

   if( pLeft->ExprType == HB_ET_NUMERIC && pRight->ExprType == HB_ET_NUMERIC )
   {
      BYTE bType = ( pLeft->value.asNum.NumType & pRight->value.asNum.NumType );

      switch( bType )
      {
         case HB_ET_LONG:
            pSelf->value.asNum.val.d = pow( ( double ) pLeft->value.asNum.val.l,
                                            ( double ) pRight->value.asNum.val.l );
            break;

         case HB_ET_DOUBLE:
            pSelf->value.asNum.val.d = pow( pLeft->value.asNum.val.d,
                                            pRight->value.asNum.val.d );
            break;

         default:
            if( pLeft->value.asNum.NumType == HB_ET_DOUBLE )
               pSelf->value.asNum.val.d = pow( pLeft->value.asNum.val.d,
                                               ( double ) pRight->value.asNum.val.l );
            else
               pSelf->value.asNum.val.d = pow( ( double ) pLeft->value.asNum.val.l,
                                               pRight->value.asNum.val.d );
            break;
      }
      pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
      pSelf->value.asNum.bDec = HB_DEFAULT_DECIMALS;
      pSelf->value.asNum.NumType = HB_ET_DOUBLE;
      pSelf->ExprType = HB_ET_NUMERIC;
      pSelf->ValType  = HB_EV_NUMERIC;
      HB_COMP_EXPR_FREE( pLeft );
      HB_COMP_EXPR_FREE( pRight );
   }
   else
   {
      /* TODO: Check for incompatible types e.g. 3 * "txt"
      */
   }
   return pSelf;
}
expropt2.c343
HB_EXPR_PTRhb_compExprReduceMinus( HB_EXPR_PTR pSelf, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprReduceMinus( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pLeft, pRight;

   pLeft  = pSelf->value.asOperator.pLeft;
   pRight = pSelf->value.asOperator.pRight;

   if( pLeft->ExprType == HB_ET_NUMERIC && pRight->ExprType == HB_ET_NUMERIC )
   {
      BYTE bType = ( pLeft->value.asNum.NumType & pRight->value.asNum.NumType );

      switch( bType )
      {
         case HB_ET_LONG:
         {
            HB_MAXDBL dVal = ( HB_MAXDBL ) pLeft->value.asNum.val.l - ( HB_MAXDBL ) pRight->value.asNum.val.l;

            if( HB_DBL_LIM_LONG( dVal ) )
            {
               pSelf->value.asNum.val.l = pLeft->value.asNum.val.l - pRight->value.asNum.val.l;
               pSelf->value.asNum.bDec = 0;
               pSelf->value.asNum.NumType = HB_ET_LONG;
            }
            else
            {
               pSelf->value.asNum.val.d = ( double ) dVal;
               pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
               pSelf->value.asNum.bDec = 0;
               pSelf->value.asNum.NumType = HB_ET_DOUBLE;
            }

            break;
         }

         case HB_ET_DOUBLE:
         {
            pSelf->value.asNum.val.d = pLeft->value.asNum.val.d - pRight->value.asNum.val.d;
            pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
            if( pLeft->value.asNum.bDec < pRight->value.asNum.bDec )
               pSelf->value.asNum.bDec = pRight->value.asNum.bDec;
            else
               pSelf->value.asNum.bDec = pLeft->value.asNum.bDec;
            pSelf->value.asNum.NumType = HB_ET_DOUBLE;

            break;
         }

         default:
         {
            if( pLeft->value.asNum.NumType == HB_ET_DOUBLE )
            {
               pSelf->value.asNum.val.d = pLeft->value.asNum.val.d - ( double ) pRight->value.asNum.val.l;
               pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
               pSelf->value.asNum.bDec = pLeft->value.asNum.bDec;
            }
            else
            {
               pSelf->value.asNum.val.d = ( double ) pLeft->value.asNum.val.l - pRight->value.asNum.val.d;
               pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
               pSelf->value.asNum.bDec = pRight->value.asNum.bDec;
            }
            pSelf->value.asNum.NumType = HB_ET_DOUBLE;
         }
      }
      pSelf->ExprType = HB_ET_NUMERIC;
      pSelf->ValType  = HB_EV_NUMERIC;
      HB_COMP_EXPR_FREE( pLeft );
      HB_COMP_EXPR_FREE( pRight );
   }
   else if( pLeft->ExprType == HB_ET_DATE && pRight->ExprType == HB_ET_DATE )
   {
      pSelf->value.asNum.val.l = pLeft->value.asNum.val.l - pRight->value.asNum.val.l;
      pSelf->value.asNum.bDec = 0;
      pSelf->value.asNum.NumType = HB_ET_LONG;
      pSelf->ExprType = HB_ET_NUMERIC;
      pSelf->ValType  = HB_EV_NUMERIC;
      HB_COMP_EXPR_FREE( pLeft );
      HB_COMP_EXPR_FREE( pRight );
   }
   else if( pLeft->ExprType == HB_ET_DATE && pRight->ExprType == HB_ET_NUMERIC )
   {
      if( pRight->value.asNum.NumType == HB_ET_LONG )
      {
         pSelf->value.asNum.val.l = pLeft->value.asNum.val.l - pRight->value.asNum.val.l;
      }
      else
      {
         pSelf->value.asNum.val.l = pLeft->value.asNum.val.l - ( HB_LONG ) pRight->value.asNum.val.d;
      }
      pSelf->ExprType = HB_ET_DATE;
      pSelf->ValType  = HB_EV_DATE;
      HB_COMP_EXPR_FREE( pLeft );
      HB_COMP_EXPR_FREE( pRight );
   }
   else if( pLeft->ExprType == HB_ET_STRING && pRight->ExprType == HB_ET_STRING )
   {
      if( pRight->ulLength == 0 )
      {
         pSelf->ExprType = HB_ET_NONE; /* suppress deletion of operator components */
         HB_COMP_EXPR_FREE( pSelf );
         pSelf = pLeft;
         HB_COMP_EXPR_FREE( pRight );
      }
      else if( pLeft->ulLength == 0 )
      {
         pSelf->ExprType = HB_ET_NONE; /* suppress deletion of operator components */
         HB_COMP_EXPR_FREE( pSelf );
         pSelf = pRight;
         HB_COMP_EXPR_FREE( pLeft );
      }
      else
      {
         /* Do not reduce strings with the macro operator '&'
         */
         char * szText = pLeft->value.asString.string;
         ULONG ulLen = pLeft->ulLength;
         BOOL fReduce = TRUE;

         while( ulLen && szText[ ulLen - 1 ] == ' ' )
            --ulLen;

         while( ulLen-- )
         {
            if( *szText++ == '&' )
            {
               char ch = ulLen ? *szText : *pRight->value.asString.string;
               if( ( ch >= 'A' && ch <= 'Z' ) ||
                   ( ch >= 'a' && ch <= 'z' ) || ch == '_' ||
                   ! HB_SUPPORT_HARBOUR )
               {
                  fReduce = FALSE;
                  break;
               }
            }
         }

         if( fReduce )
         {
            pSelf->ExprType = HB_ET_NONE; /* suppress deletion of operator components */
            HB_COMP_EXPR_FREE( pSelf );
            pSelf = hb_compExprReduceMinusStrings( pLeft, pRight, HB_COMP_PARAM );
         }
      }
   }
   else
   {
      /* TODO: Check for incompatible types e.g. "txt" - 3
      */
   }
   return pSelf;
}
expropt2.c391
HB_EXPR_PTRhb_compExprReducePlus( HB_EXPR_PTR pSelf, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprReducePlus( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pLeft, pRight;

   pLeft  = pSelf->value.asOperator.pLeft;
   pRight = pSelf->value.asOperator.pRight;

   if( pLeft->ExprType == HB_ET_NUMERIC )
   {
      if( pRight->ExprType == HB_ET_NUMERIC )
      {
         BYTE bType = ( pLeft->value.asNum.NumType & pRight->value.asNum.NumType );

         switch( bType )
         {
            case HB_ET_LONG:
            {
               HB_MAXDBL dVal = ( HB_MAXDBL ) pLeft->value.asNum.val.l + ( HB_MAXDBL ) pRight->value.asNum.val.l;

               if( HB_DBL_LIM_LONG( dVal ) )
               {
                  pSelf->value.asNum.val.l = pLeft->value.asNum.val.l + pRight->value.asNum.val.l;
                  pSelf->value.asNum.bDec = 0;
                  pSelf->value.asNum.NumType = HB_ET_LONG;
               }
               else
               {
                  pSelf->value.asNum.val.d = ( double ) dVal;
                  pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
                  pSelf->value.asNum.bDec = 0;
                  pSelf->value.asNum.NumType = HB_ET_DOUBLE;
               }
               break;
            }

            case HB_ET_DOUBLE:
               pSelf->value.asNum.val.d = pLeft->value.asNum.val.d + pRight->value.asNum.val.d;
               pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
               if( pLeft->value.asNum.bDec < pRight->value.asNum.bDec )
                  pSelf->value.asNum.bDec = pRight->value.asNum.bDec;
               else
                  pSelf->value.asNum.bDec = pLeft->value.asNum.bDec;
               pSelf->value.asNum.NumType = HB_ET_DOUBLE;
               break;

            default:
               if( pLeft->value.asNum.NumType == HB_ET_DOUBLE )
               {
                  pSelf->value.asNum.val.d = pLeft->value.asNum.val.d + ( double ) pRight->value.asNum.val.l;
                  pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
                  pSelf->value.asNum.bDec = pLeft->value.asNum.bDec;
               }
               else
               {
                  pSelf->value.asNum.val.d = ( double ) pLeft->value.asNum.val.l + pRight->value.asNum.val.d;
                  pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
                  pSelf->value.asNum.bDec = pRight->value.asNum.bDec;
               }
               pSelf->value.asNum.NumType = HB_ET_DOUBLE;
         }
         pSelf->ExprType = HB_ET_NUMERIC;
         pSelf->ValType  = HB_EV_NUMERIC;
         HB_COMP_EXPR_FREE( pLeft );
         HB_COMP_EXPR_FREE( pRight );
      }
      else if( pRight->ExprType == HB_ET_DATE )
      {
         if( pLeft->value.asNum.NumType == HB_ET_LONG )
            pSelf->value.asNum.val.l = pRight->value.asNum.val.l + pLeft->value.asNum.val.l;
         else
            pSelf->value.asNum.val.l = pRight->value.asNum.val.l + ( HB_LONG ) pLeft->value.asNum.val.d;
         pSelf->ExprType = HB_ET_DATE;
         pSelf->ValType  = HB_EV_DATE;
         HB_COMP_EXPR_FREE( pLeft );
         HB_COMP_EXPR_FREE( pRight );
      }
      else if( HB_SUPPORT_HARBOUR &&
               ( pLeft->value.asNum.NumType == HB_ET_LONG ?
                 pLeft->value.asNum.val.l == 0 :
                 pLeft->value.asNum.val.d == 0 ) )
      {
         /* NOTE: This will not generate a runtime error if incompatible
          * data type is used
          */
         pSelf->ExprType = HB_ET_NONE; /* suppress deletion of operator components */
         HB_COMP_EXPR_FREE( pSelf );
         pSelf = pRight;
         HB_COMP_EXPR_FREE( pLeft );
      }
      else
      {
         /* TODO: Check for incompatible types e.g. "txt" + 3
         */
      }
   }
   else if( pRight->ExprType == HB_ET_NUMERIC )
   {
      if( pLeft->ExprType == HB_ET_DATE )
      {
         if( pRight->value.asNum.NumType == HB_ET_LONG )
            pSelf->value.asNum.val.l = pLeft->value.asNum.val.l + pRight->value.asNum.val.l;
         else
            pSelf->value.asNum.val.l = pLeft->value.asNum.val.l + ( HB_LONG ) pRight->value.asNum.val.d;
         pSelf->ExprType = HB_ET_DATE;
         pSelf->ValType  = HB_EV_DATE;
         HB_COMP_EXPR_FREE( pLeft );
         HB_COMP_EXPR_FREE( pRight );
      }
      else if( HB_SUPPORT_HARBOUR &&
               ( pRight->value.asNum.NumType == HB_ET_LONG ?
                 pRight->value.asNum.val.l == 0 :
                 pRight->value.asNum.val.d == 0 ) )
      {
         /* NOTE: This will not generate a runtime error if incompatible
          * data type is used
          */
         pSelf->ExprType = HB_ET_NONE; /* suppress deletion of operator components */
         HB_COMP_EXPR_FREE( pSelf );
         pSelf = pLeft;
         HB_COMP_EXPR_FREE( pRight );
      }
      else
      {
         /* TODO: Check for incompatible types e.g. "txt" + 3
         */
      }
   }
   else if( pLeft->ExprType == HB_ET_STRING && pRight->ExprType == HB_ET_STRING )
   {
      if( pRight->ulLength == 0 )
      {
         pSelf->ExprType = HB_ET_NONE; /* suppress deletion of operator components */
         HB_COMP_EXPR_FREE( pSelf );
         pSelf = pLeft;
         HB_COMP_EXPR_FREE( pRight );
      }
      else if( pLeft->ulLength == 0 )
      {
         pSelf->ExprType = HB_ET_NONE; /* suppress deletion of operator components */
         HB_COMP_EXPR_FREE( pSelf );
         pSelf = pRight;
         HB_COMP_EXPR_FREE( pLeft );
      }
      else
      {
         /* Do not reduce strings with the macro operator '&'
         */
         char * szText = pLeft->value.asString.string;
         ULONG ulLen = pLeft->ulLength;
         BOOL fReduce = TRUE;

         while( ulLen-- )
         {
            if( *szText++ == '&' )
            {
               char ch = ulLen ? *szText : *pRight->value.asString.string;
               if( ( ch >= 'A' && ch <= 'Z' ) ||
                   ( ch >= 'a' && ch <= 'z' ) || ch == '_' ||
                   ! HB_SUPPORT_HARBOUR )
               {
                  fReduce = FALSE;
                  break;
               }
            }
         }

         if( fReduce )
         {
            pSelf->ExprType = HB_ET_NONE; /* suppress deletion of operator components */
            HB_COMP_EXPR_FREE( pSelf );
            pSelf = hb_compExprReducePlusStrings( pLeft, pRight, HB_COMP_PARAM );
         }
      }
   }
   else
   {
      /* TODO: Check for incompatible types e.g. "txt" + 3
      */
   }
   return pSelf;
}
expropt2.c543
HB_EXPR_PTRhb_compExprReduceNegate( HB_EXPR_PTR pSelf, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprReduceNegate( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   pExpr = pSelf->value.asOperator.pLeft;

   if( pExpr->ExprType == HB_ET_NUMERIC )
   {
      if( pExpr->value.asNum.NumType == HB_ET_DOUBLE )
      {
         pExpr->value.asNum.val.d = - pExpr->value.asNum.val.d;
         pExpr->value.asNum.bWidth = HB_DEFAULT_WIDTH;
      }
      else
      {
#if -HB_LONG_MAX > HB_LONG_MIN
         if( pExpr->value.asNum.val.l < -HB_LONG_MAX )
         {
            pExpr->value.asNum.NumType = HB_ET_DOUBLE;
            pExpr->value.asNum.val.d = - ( double ) pExpr->value.asNum.val.l;
            pExpr->value.asNum.bWidth = HB_DEFAULT_WIDTH;
            pExpr->value.asNum.bDec = 0;
         }
         else
#endif
         {
            pExpr->value.asNum.val.l = - pExpr->value.asNum.val.l;
            pExpr->value.asNum.bWidth = HB_DEFAULT_WIDTH;
         }
      }
      pSelf->ExprType = HB_ET_NONE; /* suppress deletion of operator components */
      HB_COMP_EXPR_FREE( pSelf );
      pSelf = pExpr;
   }

   return pSelf;
}
expropt2.c725
HB_EXPR_PTRhb_compExprReduceIN( HB_EXPR_PTR pSelf, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprReduceIN( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   if( pSelf->value.asOperator.pLeft->ExprType == pSelf->value.asOperator.pRight->ExprType &&
       pSelf->value.asOperator.pLeft->ExprType == HB_ET_STRING )
   {
      /* Both arguments are literal strings
       */
      BOOL bResult;

      /* NOTE: CA-Cl*pper has a bug where the $ operator returns .T.
       *       when an empty string is searched [vszakats]
       *
       *       But this bug exist only in compiler and CA-Cl*pper macro
       *       compiler does not have optimizer. This bug is replicated
       *       by us only when Harbour extensions in compiler (-kh) are
       *       not enabled f.e. in strict Clipper cmpatible mode (-kc)
       *       [druzus]
       */
      if( pSelf->value.asOperator.pLeft->ulLength == 0 )
         bResult = HB_COMP_PARAM->mode == HB_MODE_COMPILER &&
                   ! HB_SUPPORT_HARBOUR;
      else
         bResult = ( hb_strAt( pSelf->value.asOperator.pLeft->value.asString.string, pSelf->value.asOperator.pLeft->ulLength,
                     pSelf->value.asOperator.pRight->value.asString.string, pSelf->value.asOperator.pRight->ulLength ) != 0 );

      /* NOTE:
       * "" $ "XXX" = .T.
       * "" $ "" = .T.
       */
      HB_COMP_EXPR_FREE( pSelf->value.asOperator.pLeft );
      HB_COMP_EXPR_FREE( pSelf->value.asOperator.pRight );
      pSelf->ExprType = HB_ET_LOGICAL;
      pSelf->ValType  = HB_EV_LOGICAL;
      pSelf->value.asLogical = bResult;
   }
   /* TODO: add checking for incompatible types
    */
   return pSelf;
}
expropt2.c764
HB_EXPR_PTRhb_compExprReduceNE( HB_EXPR_PTR pSelf, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprReduceNE( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pLeft, pRight;

   pLeft  = pSelf->value.asOperator.pLeft;
   pRight = pSelf->value.asOperator.pRight;

   if( pLeft->ExprType == pRight->ExprType )
   {
      switch( pLeft->ExprType )
      {
         case HB_ET_LOGICAL:
            {
               /* .F. != .T.  = .T.
               * .T. != .T.  = .F.
               * .F. != .F.  = .F.
               * .T. != .F.  = .T.
               */
               BOOL bResult = ( pLeft->value.asLogical != pRight->value.asLogical );
               HB_COMP_EXPR_FREE( pLeft );
               HB_COMP_EXPR_FREE( pRight );
               pSelf->ExprType = HB_ET_LOGICAL;
               pSelf->ValType  = HB_EV_LOGICAL;
               pSelf->value.asLogical = bResult;
            }
            break;

         case HB_ET_STRING:
            /* NOTE: the result depends on SET EXACT setting then it
            * cannot be optimized except the case when NULL string are
            * compared - "" != "" is always FALSE regardless of EXACT
            * setting
            */
            if( ( pLeft->ulLength | pRight->ulLength ) == 0 )
            {
               HB_COMP_EXPR_FREE( pLeft );
               HB_COMP_EXPR_FREE( pRight );
               pSelf->ExprType = HB_ET_LOGICAL;
               pSelf->ValType  = HB_EV_LOGICAL;
               pSelf->value.asLogical = FALSE;

               /* NOTE: COMPATIBILITY: Clipper doesn't optimize this */
            }
            break;

         case HB_ET_NUMERIC:
            {
               BOOL bResult;

               switch( pLeft->value.asNum.NumType & pRight->value.asNum.NumType )
               {
                  case HB_ET_LONG:
                     bResult = ( pLeft->value.asNum.val.l != pRight->value.asNum.val.l );
                     break;
                  case HB_ET_DOUBLE:
                     bResult = ( pLeft->value.asNum.val.d != pRight->value.asNum.val.d );
                     break;
                  default:
                     {
                        if( pLeft->value.asNum.NumType == HB_ET_LONG )
                           bResult = ( pLeft->value.asNum.val.l != pRight->value.asNum.val.d );
                        else
                           bResult = ( pLeft->value.asNum.val.d != pRight->value.asNum.val.l );
                     }
                     break;
               }
               HB_COMP_EXPR_FREE( pLeft );
               HB_COMP_EXPR_FREE( pRight );
               pSelf->ExprType = HB_ET_LOGICAL;
               pSelf->ValType  = HB_EV_LOGICAL;
               pSelf->value.asLogical = bResult;
            }
            break;

         case HB_ET_NIL:
            HB_COMP_EXPR_FREE( pLeft );
            HB_COMP_EXPR_FREE( pRight );
            pSelf->ExprType = HB_ET_LOGICAL;
            pSelf->ValType  = HB_EV_LOGICAL;
            pSelf->value.asLogical = FALSE;
            break;
      }
   }
   else if( ( pLeft->ExprType == HB_ET_NIL &&
              ( pRight->ExprType == HB_ET_NUMERIC ||
                pRight->ExprType == HB_ET_LOGICAL ||
                pRight->ExprType == HB_ET_DATE ||
                pRight->ExprType == HB_ET_STRING ||
                pRight->ExprType == HB_ET_CODEBLOCK ||
                pRight->ExprType == HB_ET_ARRAY ||
                pRight->ExprType == HB_ET_FUNREF ) ) ||
            ( pRight->ExprType == HB_ET_NIL &&
              ( pLeft->ExprType == HB_ET_NUMERIC ||
                pLeft->ExprType == HB_ET_LOGICAL ||
                pLeft->ExprType == HB_ET_DATE ||
                pLeft->ExprType == HB_ET_STRING ||
                pLeft->ExprType == HB_ET_CODEBLOCK ||
                pLeft->ExprType == HB_ET_ARRAY ||
                pLeft->ExprType == HB_ET_FUNREF ) ) )
   {
      HB_COMP_EXPR_FREE( pLeft );
      HB_COMP_EXPR_FREE( pRight );
      pSelf->ExprType = HB_ET_LOGICAL;
      pSelf->ValType  = HB_EV_LOGICAL;
      pSelf->value.asLogical = TRUE;
   }
   /* TODO: add checking of incompatible types
   else
   {
   }
   */
   return pSelf;
}
expropt2.c804
HB_EXPR_PTRhb_compExprReduceGE( HB_EXPR_PTR pSelf, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprReduceGE( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pLeft, pRight;

   pLeft  = pSelf->value.asOperator.pLeft;
   pRight = pSelf->value.asOperator.pRight;

   if( pLeft->ExprType == pRight->ExprType )
      switch( pLeft->ExprType )
      {
         case HB_ET_LOGICAL:
            {
               /* .T. >= .F.  = .T.
                * .T. >= .T.  = .T.
                * .F. >= .F.  = .T.
                * .F. >= .T.  = .f.
                */
               BOOL bResult = ! ( ! pLeft->value.asLogical && pRight->value.asLogical );
               HB_COMP_EXPR_FREE( pLeft );
               HB_COMP_EXPR_FREE( pRight );
               pSelf->ExprType = HB_ET_LOGICAL;
               pSelf->ValType  = HB_EV_LOGICAL;
               pSelf->value.asLogical = bResult;
            }
            break;

         case HB_ET_NUMERIC:
            {
               BOOL bResult;

               switch( pLeft->value.asNum.NumType & pRight->value.asNum.NumType )
               {
                  case HB_ET_LONG:
                     bResult = ( pLeft->value.asNum.val.l >= pRight->value.asNum.val.l );
                     break;
                  case HB_ET_DOUBLE:
                     bResult = ( pLeft->value.asNum.val.d >= pRight->value.asNum.val.d );
                     break;
                  default:
                     {
                        if( pLeft->value.asNum.NumType == HB_ET_LONG )
                           bResult = ( pLeft->value.asNum.val.l >= pRight->value.asNum.val.d );
                        else
                           bResult = ( pLeft->value.asNum.val.d >= pRight->value.asNum.val.l );
                     }
                     break;
               }
               HB_COMP_EXPR_FREE( pLeft );
               HB_COMP_EXPR_FREE( pRight );
               pSelf->ExprType = HB_ET_LOGICAL;
               pSelf->ValType  = HB_EV_LOGICAL;
               pSelf->value.asLogical = bResult;
            }
            break;

      }
   /* TODO: add checking of incompatible types
   else
   {
   }
   */
   return pSelf;
}
expropt2.c918
HB_EXPR_PTRhb_compExprReduceLE( HB_EXPR_PTR pSelf, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprReduceLE( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pLeft, pRight;

   pLeft  = pSelf->value.asOperator.pLeft;
   pRight = pSelf->value.asOperator.pRight;

   if( pLeft->ExprType == pRight->ExprType )
      switch( pLeft->ExprType )
      {
         case HB_ET_LOGICAL:
            {
               /* .T. <= .F.  = .F.
                * .T. <= .T.  = .T.
                * .F. <= .F.  = .T.
                * .F. <= .T.  = .T.
                */
               BOOL bResult = ! ( pLeft->value.asLogical && ! pRight->value.asLogical );
               HB_COMP_EXPR_FREE( pLeft );
               HB_COMP_EXPR_FREE( pRight );
               pSelf->ExprType = HB_ET_LOGICAL;
               pSelf->ValType  = HB_EV_LOGICAL;
               pSelf->value.asLogical = bResult;
            }
            break;

         case HB_ET_NUMERIC:
            {
               BOOL bResult;

               switch( pLeft->value.asNum.NumType & pRight->value.asNum.NumType )
               {
                  case HB_ET_LONG:
                     bResult = ( pLeft->value.asNum.val.l <= pRight->value.asNum.val.l );
                     break;
                  case HB_ET_DOUBLE:
                     bResult = ( pLeft->value.asNum.val.d <= pRight->value.asNum.val.d );
                     break;
                  default:
                     {
                        if( pLeft->value.asNum.NumType == HB_ET_LONG )
                           bResult = ( pLeft->value.asNum.val.l <= pRight->value.asNum.val.d );
                        else
                           bResult = ( pLeft->value.asNum.val.d <= pRight->value.asNum.val.l );
                     }
                     break;
               }
               HB_COMP_EXPR_FREE( pLeft );
               HB_COMP_EXPR_FREE( pRight );
               pSelf->ExprType = HB_ET_LOGICAL;
               pSelf->ValType  = HB_EV_LOGICAL;
               pSelf->value.asLogical = bResult;
            }
            break;

      }
   /* TODO: add checking of incompatible types
   else
   {
   }
   */
   return pSelf;
}
expropt2.c982
HB_EXPR_PTRhb_compExprReduceGT( HB_EXPR_PTR pSelf, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprReduceGT( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pLeft, pRight;

   pLeft  = pSelf->value.asOperator.pLeft;
   pRight = pSelf->value.asOperator.pRight;

   if( pLeft->ExprType == pRight->ExprType )
      switch( pLeft->ExprType )
      {
         case HB_ET_LOGICAL:
            {
               /* .T. > .F.  = .T.
                * .T. > .T.  = .F.
                * .F. > .F.  = .F.
                * .F. > .T.  = .F.
                */
               BOOL bResult = ( pLeft->value.asLogical && ! pRight->value.asLogical );
               HB_COMP_EXPR_FREE( pLeft );
               HB_COMP_EXPR_FREE( pRight );
               pSelf->ExprType = HB_ET_LOGICAL;
               pSelf->ValType  = HB_EV_LOGICAL;
               pSelf->value.asLogical = bResult;
            }
            break;

         case HB_ET_NUMERIC:
            {
               BOOL bResult;

               switch( pLeft->value.asNum.NumType & pRight->value.asNum.NumType )
               {
                  case HB_ET_LONG:
                     bResult = ( pLeft->value.asNum.val.l > pRight->value.asNum.val.l );
                     break;
                  case HB_ET_DOUBLE:
                     bResult = ( pLeft->value.asNum.val.d > pRight->value.asNum.val.d );
                     break;
                  default:
                     {
                        if( pLeft->value.asNum.NumType == HB_ET_LONG )
                           bResult = ( pLeft->value.asNum.val.l > pRight->value.asNum.val.d );
                        else
                           bResult = ( pLeft->value.asNum.val.d > pRight->value.asNum.val.l );
                     }
                     break;
               }
               HB_COMP_EXPR_FREE( pLeft );
               HB_COMP_EXPR_FREE( pRight );
               pSelf->ExprType = HB_ET_LOGICAL;
               pSelf->ValType  = HB_EV_LOGICAL;
               pSelf->value.asLogical = bResult;
            }
            break;

      }
   /* TODO: add checking of incompatible types
   else
   {
   }
   */
   return pSelf;
}
expropt2.c1046
HB_EXPR_PTRhb_compExprReduceLT( HB_EXPR_PTR pSelf, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprReduceLT( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pLeft, pRight;

   pLeft  = pSelf->value.asOperator.pLeft;
   pRight = pSelf->value.asOperator.pRight;

   if( pLeft->ExprType == pRight->ExprType )
      switch( pLeft->ExprType )
      {
         case HB_ET_LOGICAL:
            {
               /* .F. < .T.  = .T.
                * .T. < .T.  = .F.
                * .F. < .F.  = .F.
                * .T. < .F.  = .F.
                */
               BOOL bResult = ( ! pLeft->value.asLogical && pRight->value.asLogical );
               HB_COMP_EXPR_FREE( pLeft );
               HB_COMP_EXPR_FREE( pRight );
               pSelf->ExprType = HB_ET_LOGICAL;
               pSelf->ValType  = HB_EV_LOGICAL;
               pSelf->value.asLogical = bResult;
            }
            break;

         case HB_ET_NUMERIC:
            {
               BOOL bResult;

               switch( pLeft->value.asNum.NumType & pRight->value.asNum.NumType )
               {
                  case HB_ET_LONG:
                     bResult = ( pLeft->value.asNum.val.l < pRight->value.asNum.val.l );
                     break;
                  case HB_ET_DOUBLE:
                     bResult = ( pLeft->value.asNum.val.d < pRight->value.asNum.val.d );
                     break;
                  default:
                     {
                        if( pLeft->value.asNum.NumType == HB_ET_LONG )
                           bResult = ( pLeft->value.asNum.val.l < pRight->value.asNum.val.d );
                        else
                           bResult = ( pLeft->value.asNum.val.d < pRight->value.asNum.val.l );
                     }
                     break;
               }
               HB_COMP_EXPR_FREE( pLeft );
               HB_COMP_EXPR_FREE( pRight );
               pSelf->ExprType = HB_ET_LOGICAL;
               pSelf->ValType  = HB_EV_LOGICAL;
               pSelf->value.asLogical = bResult;
            }
            break;

         default:
            break;
      }
   /* TODO: add checking of incompatible types
   else
   {
   }
   */
   return pSelf;
}
expropt2.c1110
HB_EXPR_PTRhb_compExprReduceEQ( HB_EXPR_PTR pSelf, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprReduceEQ( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pLeft, pRight;

   pLeft  = pSelf->value.asOperator.pLeft;
   pRight = pSelf->value.asOperator.pRight;

   if( pLeft->ExprType == pRight->ExprType )
   {
      switch( pLeft->ExprType )
      {
         case HB_ET_LOGICAL:
            {
               BOOL bResult = ( pLeft->value.asLogical == pRight->value.asLogical );
               HB_COMP_EXPR_FREE( pLeft );
               HB_COMP_EXPR_FREE( pRight );
               pSelf->ExprType = HB_ET_LOGICAL;
               pSelf->ValType  = HB_EV_LOGICAL;
               pSelf->value.asLogical = bResult;
            }
            break;

         case HB_ET_STRING:
            /* NOTE: when not exact comparison (==) is used 
             * the result depends on SET EXACT setting then it
             * cannot be optimized except the case when NULL string are
             * compared - "" = "" is always TRUE regardless of EXACT
             * setting
             */
            if( pSelf->ExprType == HB_EO_EQ ||
                ( pLeft->ulLength | pRight->ulLength ) == 0 )
            {
               BOOL bResult = pLeft->ulLength == pRight->ulLength &&
                              memcmp( pLeft->value.asString.string,
                                      pRight->value.asString.string,
                                      pLeft->ulLength ) == 0;
               HB_COMP_EXPR_FREE( pLeft );
               HB_COMP_EXPR_FREE( pRight );
               pSelf->ExprType = HB_ET_LOGICAL;
               pSelf->ValType  = HB_EV_LOGICAL;
               pSelf->value.asLogical = bResult;
            }
            break;

         case HB_ET_NUMERIC:
            {
               BOOL bResult;

               switch( pLeft->value.asNum.NumType & pRight->value.asNum.NumType )
               {
                  case HB_ET_LONG:
                     bResult = ( pLeft->value.asNum.val.l == pRight->value.asNum.val.l );
                     break;
                  case HB_ET_DOUBLE:
                     bResult = ( pLeft->value.asNum.val.d == pRight->value.asNum.val.d );
                     break;
                  default:
                     if( pLeft->value.asNum.NumType == HB_ET_LONG )
                        bResult = ( pLeft->value.asNum.val.l == pRight->value.asNum.val.d );
                     else
                        bResult = ( pLeft->value.asNum.val.d == pRight->value.asNum.val.l );
                     break;
               }
               HB_COMP_EXPR_FREE( pLeft );
               HB_COMP_EXPR_FREE( pRight );
               pSelf->ExprType = HB_ET_LOGICAL;
               pSelf->ValType  = HB_EV_LOGICAL;
               pSelf->value.asLogical = bResult;
            }
            break;

         case HB_ET_NIL:
            HB_COMP_EXPR_FREE( pLeft );
            HB_COMP_EXPR_FREE( pRight );
            pSelf->ExprType = HB_ET_LOGICAL;
            pSelf->ValType  = HB_EV_LOGICAL;
            pSelf->value.asLogical = TRUE;
            break;
      }
   }
   else if( ( pLeft->ExprType == HB_ET_NIL &&
              ( pRight->ExprType == HB_ET_NUMERIC ||
                pRight->ExprType == HB_ET_LOGICAL ||
                pRight->ExprType == HB_ET_DATE ||
                pRight->ExprType == HB_ET_STRING ||
                pRight->ExprType == HB_ET_CODEBLOCK ||
                pRight->ExprType == HB_ET_ARRAY ||
                pRight->ExprType == HB_ET_FUNREF ) ) ||
            ( pRight->ExprType == HB_ET_NIL &&
              ( pLeft->ExprType == HB_ET_NUMERIC ||
                pLeft->ExprType == HB_ET_LOGICAL ||
                pLeft->ExprType == HB_ET_DATE ||
                pLeft->ExprType == HB_ET_STRING ||
                pLeft->ExprType == HB_ET_CODEBLOCK ||
                pLeft->ExprType == HB_ET_ARRAY ||
                pLeft->ExprType == HB_ET_FUNREF ) ) )
   {
      HB_COMP_EXPR_FREE( pLeft );
      HB_COMP_EXPR_FREE( pRight );
      pSelf->ExprType = HB_ET_LOGICAL;
      pSelf->ValType  = HB_EV_LOGICAL;
      pSelf->value.asLogical = FALSE;
   }
   /* TODO: add checking of incompatible types
   else
   {
   }
   */
   return pSelf;
}
expropt2.c1176
HB_EXPR_PTRhb_compExprReduceAnd( HB_EXPR_PTR pSelf, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprReduceAnd( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pLeft, pRight;

   pLeft  = pSelf->value.asOperator.pLeft;
   pRight = pSelf->value.asOperator.pRight;

   if( pLeft->ExprType == HB_ET_LOGICAL && pRight->ExprType == HB_ET_LOGICAL )
   {
      BOOL bResult;

      bResult = pLeft->value.asLogical && pRight->value.asLogical;
      HB_COMP_EXPR_FREE( pLeft );
      HB_COMP_EXPR_FREE( pRight );
      pSelf->ExprType = HB_ET_LOGICAL;
      pSelf->ValType  = HB_EV_LOGICAL;
      pSelf->value.asLogical = bResult;
   }
   else if( pLeft->ExprType == HB_ET_LOGICAL &&
            HB_COMP_ISSUPPORTED( HB_COMPFLAG_SHORTCUTS ) )
   {
      if( pLeft->value.asLogical )
      {
         /* .T. .AND. expr => expr
          */
         HB_COMP_EXPR_FREE( pLeft );
         pSelf->ExprType = HB_ET_NONE;    /* don't delete expression components */
         HB_COMP_EXPR_FREE( pSelf );
         pSelf = pRight;
      }
      else
      {
         /* .F. .AND. expr => .F.
          */
         HB_COMP_EXPR_FREE( pLeft );
         HB_COMP_EXPR_FREE( pRight );         /* discard expression */
         pSelf->ExprType = HB_ET_LOGICAL;
         pSelf->ValType  = HB_EV_LOGICAL;
         pSelf->value.asLogical = FALSE;
      }
   }
   else if( pRight->ExprType == HB_ET_LOGICAL &&
            HB_COMP_ISSUPPORTED( HB_COMPFLAG_SHORTCUTS ) )
   {
      if( pRight->value.asLogical )
      {
         /* expr .AND. .T. => expr
          */
         HB_COMP_EXPR_FREE( pRight );
         pSelf->ExprType = HB_ET_NONE;    /* don't delete expression components */
         HB_COMP_EXPR_FREE( pSelf );
         pSelf = pLeft;
      }
      else
      {
         /* expr .AND. .F. => .F.
          */
         HB_COMP_EXPR_FREE( pLeft );      /* discard expression */
         HB_COMP_EXPR_FREE( pRight );
         pSelf->ExprType = HB_ET_LOGICAL;
         pSelf->ValType  = HB_EV_LOGICAL;
         pSelf->value.asLogical = FALSE;
      }
   }
   return pSelf;
}
expropt2.c1287
HB_EXPR_PTRhb_compExprReduceOr( HB_EXPR_PTR pSelf, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprReduceOr( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pLeft, pRight;

   pLeft  = pSelf->value.asOperator.pLeft;
   pRight = pSelf->value.asOperator.pRight;

   if( pLeft->ExprType == HB_ET_LOGICAL && pRight->ExprType == HB_ET_LOGICAL )
   {
      BOOL bResult;

      bResult = pLeft->value.asLogical || pRight->value.asLogical;
      HB_COMP_EXPR_FREE( pLeft );
      HB_COMP_EXPR_FREE( pRight );
      pSelf->ExprType = HB_ET_LOGICAL;
      pSelf->ValType  = HB_EV_LOGICAL;
      pSelf->value.asLogical = bResult;
   }
   else if( pLeft->ExprType == HB_ET_LOGICAL &&
            HB_COMP_ISSUPPORTED( HB_COMPFLAG_SHORTCUTS ) )
   {
      if( pLeft->value.asLogical )
      {
         /* .T. .OR. expr => .T.
          */
         HB_COMP_EXPR_FREE( pLeft );
         HB_COMP_EXPR_FREE( pRight );     /* discard expression */
         pSelf->ExprType = HB_ET_LOGICAL;
         pSelf->ValType  = HB_EV_LOGICAL;
         pSelf->value.asLogical = TRUE;
      }
      else
      {
         /* .F. .OR. expr => expr
          */
         HB_COMP_EXPR_FREE( pLeft );
         pSelf->ExprType = HB_ET_NONE;    /* don't delete expression components */
         HB_COMP_EXPR_FREE( pSelf );
         pSelf = pRight;
      }
   }
   else if( pRight->ExprType == HB_ET_LOGICAL &&
            HB_COMP_ISSUPPORTED( HB_COMPFLAG_SHORTCUTS ) )
   {
      if( pRight->value.asLogical )
      {
         /* expr .OR. .T. => .T.
          */
         HB_COMP_EXPR_FREE( pLeft );      /* discard expression */
         HB_COMP_EXPR_FREE( pRight );
         pSelf->ExprType = HB_ET_LOGICAL;
         pSelf->ValType  = HB_EV_LOGICAL;
         pSelf->value.asLogical = TRUE;
      }
      else
      {
         /* expr .OR. .F. => expr
          */
         HB_COMP_EXPR_FREE( pRight );
         pSelf->ExprType = HB_ET_NONE;    /* don't delete expression components */
         HB_COMP_EXPR_FREE( pSelf );
         pSelf = pLeft;
      }
   }
   return pSelf;
}
expropt2.c1354
HB_EXPR_PTRhb_compExprReduceIIF( HB_EXPR_PTR pSelf, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprReduceIIF( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pExpr;

   /* get conditional expression */
   pExpr = pSelf->value.asList.pExprList;

   if( pExpr->ExprType == HB_ET_LOGICAL )
   {
      /* the condition was reduced to a logical value: .T. or .F.
      */
      if( pExpr->value.asLogical )
      {
         /* .T. was specified
         */
         pExpr = pExpr->pNext;   /* skip to TRUE expression */
         /* delete condition  - it is no longer needed
            */
         HB_COMP_EXPR_FREE( pSelf->value.asList.pExprList );
         /* assign NULL to a start of expressions list to suppress
          * deletion of expression's components - we are deleting them
          * here
          */
         pSelf->value.asList.pExprList = NULL;
         HB_COMP_EXPR_FREE( pSelf );
         /* store the TRUE expression as a result of reduction
          */
         pSelf = pExpr;
         pExpr = pExpr->pNext;     /* skip to FALSE expression */
         HB_COMP_EXPR_FREE( pExpr );      /* delete FALSE expr */
         pSelf->pNext = NULL;
      }
      else
      {
         /* .F. was specified
         */
         pExpr = pExpr->pNext;   /* skip to TRUE expression */
         /* delete condition  - it is no longer needed
          */
         HB_COMP_EXPR_FREE( pSelf->value.asList.pExprList );
         /* assign NULL to a start of expressions list to suppress
          * deletion of expression's components - we are deleting them
          * here
          */
         pSelf->value.asList.pExprList = NULL;
         HB_COMP_EXPR_FREE( pSelf );
         /* store the FALSE expression as a result of reduction
            */
         pSelf = pExpr->pNext;
         HB_COMP_EXPR_FREE( pExpr );      /* delete TRUE expr */
         pSelf->pNext = NULL;
      }

      /* this will cause warning when IIF is used as statement */
      /*
      if( pSelf->ExprType == HB_ET_NONE )
      {
         pSelf->ExprType = HB_ET_NIL;
         pSelf->ValType = HB_EV_NIL;
      }
      */
   }
   /* check if valid expression is passed
   */
   else if( pExpr->ExprType == HB_ET_NIL ||
            pExpr->ExprType == HB_ET_NUMERIC ||
            pExpr->ExprType == HB_ET_DATE ||
            pExpr->ExprType == HB_ET_STRING ||
            pExpr->ExprType == HB_ET_CODEBLOCK ||
            pExpr->ExprType == HB_ET_ARRAY ||
            pExpr->ExprType == HB_ET_VARREF ||
            pExpr->ExprType == HB_ET_REFERENCE ||
            pExpr->ExprType == HB_ET_FUNREF )
   {
      HB_COMP_ERROR_TYPE( pExpr );
   }
   return pSelf;
}
expropt2.c1421
HB_EXPR_PTRhb_compExprListStrip( HB_EXPR_PTR pSelf, HB_COMP_DECL )
HB_EXPR_PTR hb_compExprListStrip( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   while( pSelf->ExprType == HB_ET_LIST &&
          pSelf->value.asList.pExprList->ExprType <= HB_ET_VARIABLE &&
          hb_compExprListLen( pSelf ) == 1 )
   {
      /* replace the list with a simple expression
       *  ( EXPR ) -> EXPR
       */
      HB_EXPR_PTR pExpr = pSelf;

      pSelf = pSelf->value.asList.pExprList;
      pExpr->value.asList.pExprList = NULL;
      HB_COMP_EXPR_FREE( pExpr );
   }

   return pSelf;
}
expropt2.c1500
BOOLhb_compExprReduceAT( HB_EXPR_PTR pSelf, HB_COMP_DECL )
BOOL hb_compExprReduceAT( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pParms = pSelf->value.asFunCall.pParms;
   HB_EXPR_PTR pSub  = pParms->value.asList.pExprList;
   HB_EXPR_PTR pText = pSub->pNext;
   HB_EXPR_PTR pReduced;

   if( pSub->ExprType == HB_ET_STRING && pText->ExprType == HB_ET_STRING )
   {
      /* NOTE: CA-Cl*pper has a bug in AT("",cText) compile time
       *       optimization and always set 1 as result in such cses.
       *       This bug exist only in compiler and CA-Cl*pper macro
       *       compiler does not have optimizer. This bug is replicated
       *       by us only when Harbour extensions in compiler (-kh) are
       *       not enabled f.e. in strict Clipper cmpatible mode (-kc)
       *       [druzus]
       */
      if( pSub->ulLength == 0 )
      {
         pReduced = hb_compExprNewLong( ( HB_COMP_PARAM->mode == HB_MODE_COMPILER &&
                                          ! HB_SUPPORT_HARBOUR ) ? 1 : 0, HB_COMP_PARAM );
      }
      else
      {
         pReduced = hb_compExprNewLong( hb_strAt( pSub->value.asString.string,
                               pSub->ulLength, pText->value.asString.string,
                               pText->ulLength ), HB_COMP_PARAM );
      }

      HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pFunName );
      HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pParms );

      memcpy( pSelf, pReduced, sizeof( HB_EXPR ) );
      HB_COMP_EXPR_CLEAR( pReduced );
      return TRUE;
   }
   else
      return FALSE;
}
expropt2.c1523
BOOLhb_compExprReduceCHR( HB_EXPR_PTR pSelf, HB_COMP_DECL )
BOOL hb_compExprReduceCHR( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pParms = pSelf->value.asFunCall.pParms;
   HB_EXPR_PTR pArg = pParms->value.asList.pExprList;

   /* try to change it into a string */
   if( pArg->ExprType == HB_ET_NUMERIC )
   {
      /* NOTE: CA-Cl*pper's compiler optimizer will be wrong for those
       *       CHR() cases where the passed parameter is a constant which
       *       can be divided by 256 but it's not zero, in this case it
       *       will return an empty string instead of a Chr(0). [vszakats]
       *
       *       But this bug exist only in compiler and CA-Cl*pper macro
       *       compiler does not have optimizer. This bug is replicated
       *       by us only when Harbour extensions in compiler (-kh) are
       *       not enabled f.e. in strict Clipper cmpatible mode (-kc)
       *       [druzus]
       */

      HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_ET_STRING );

      pExpr->ValType = HB_EV_STRING;
      if( pArg->value.asNum.NumType == HB_ET_LONG )
      {
         if( HB_COMP_PARAM->mode == HB_MODE_COMPILER &&
             ! HB_SUPPORT_HARBOUR &&
             ( pArg->value.asNum.val.l & 0xff ) == 0 &&
               pArg->value.asNum.val.l != 0 )
         {
            pExpr->value.asString.string = ( char * ) "";
            pExpr->value.asString.dealloc = FALSE;
            pExpr->ulLength = 0;
         }
         else
         {
            pExpr->value.asString.string = ( char * ) hb_szAscii[ ( int ) pArg->value.asNum.val.l & 0xff ];
            pExpr->value.asString.dealloc = FALSE;
            pExpr->ulLength = 1;
         }
      }
      else
      {
         pExpr->value.asString.string = ( char * ) hb_szAscii[ ( unsigned int ) pArg->value.asNum.val.d & 0xff ];
         pExpr->value.asString.dealloc = FALSE;
         pExpr->ulLength = 1;
      }
      
      HB_COMP_EXPR_FREE( pParms );
      HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pFunName );
      memcpy( pSelf, pExpr, sizeof( HB_EXPR ) );
      HB_COMP_EXPR_CLEAR( pExpr );
      return TRUE;
   }
   
   return FALSE;
}
expropt2.c1563
BOOLhb_compExprReduceLEN( HB_EXPR_PTR pSelf, HB_COMP_DECL )
BOOL hb_compExprReduceLEN( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pParms = pSelf->value.asFunCall.pParms;
   HB_EXPR_PTR pArg = pParms->value.asList.pExprList;

   /* TOFIX: do not optimize when array/hash args have user expressions */
   if( pArg->ExprType == HB_ET_STRING || pArg->ExprType == HB_ET_ARRAY ||
       pArg->ExprType == HB_ET_HASH )
   {
      HB_EXPR_PTR pExpr = hb_compExprNewLong( pArg->ExprType == HB_ET_HASH ?
                        pArg->ulLength >> 1 : pArg->ulLength, HB_COMP_PARAM );

      HB_COMP_EXPR_FREE( pParms );
      HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pFunName );
      memcpy( pSelf, pExpr, sizeof( HB_EXPR ) );
      HB_COMP_EXPR_CLEAR( pExpr );
      return TRUE;
   }
   return FALSE;
}
expropt2.c1621
BOOLhb_compExprReduceEMPTY( HB_EXPR_PTR pSelf, HB_COMP_DECL )
BOOL hb_compExprReduceEMPTY( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pParms = pSelf->value.asFunCall.pParms;
   HB_EXPR_PTR pArg = pParms->value.asList.pExprList;
   BOOL fReduced = TRUE, fResult = FALSE;

   switch( pArg->ExprType )
   {
      case HB_ET_STRING:
         fResult = hb_strEmpty( pArg->value.asString.string, pArg->ulLength );
         break;

      case HB_ET_ARRAY:
      case HB_ET_HASH:
         /* TOFIX: do not optimize when array/hash args have user expressions */
         fResult = pArg->ulLength == 0;
         break;

      case HB_ET_NUMERIC:
         if( pArg->value.asNum.NumType == HB_ET_DOUBLE )
            fResult = pArg->value.asNum.val.d == 0.0;
         else
            fResult = pArg->value.asNum.val.l == 0;
         break;

      case HB_ET_LOGICAL:
         fResult = !pArg->value.asLogical;
         break;

      case HB_ET_NIL:
         fResult = TRUE;
         break;

      case HB_ET_DATE:
         fResult = pArg->value.asNum.val.l == 0;
         break;

      case HB_ET_CODEBLOCK:
         break;

      /* case HB_ET_FUNREF: */
      default:
         fReduced = FALSE;
   }

   if( fReduced )
   {
      HB_EXPR_PTR pExpr = hb_compExprNewLogical( fResult, HB_COMP_PARAM );

      HB_COMP_EXPR_FREE( pParms );
      HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pFunName );
      memcpy( pSelf, pExpr, sizeof( HB_EXPR ) );
      HB_COMP_EXPR_CLEAR( pExpr );
      return TRUE;
   }
   return FALSE;
}
expropt2.c1642
BOOLhb_compExprReduceASC( HB_EXPR_PTR pSelf, HB_COMP_DECL )
BOOL hb_compExprReduceASC( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pParms = pSelf->value.asFunCall.pParms;
   HB_EXPR_PTR pArg = pParms->value.asList.pExprList;

   if( pArg->ExprType == HB_ET_STRING )
   {
      HB_EXPR_PTR pExpr = hb_compExprNewLong(
                ( UCHAR ) pArg->value.asString.string[0], HB_COMP_PARAM );

      HB_COMP_EXPR_FREE( pParms );
      HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pFunName );
      memcpy( pSelf, pExpr, sizeof( HB_EXPR ) );
      HB_COMP_EXPR_CLEAR( pExpr );
      return TRUE;
   }
   return FALSE;
}
expropt2.c1700
BOOLhb_compExprReduceINT( HB_EXPR_PTR pSelf, HB_COMP_DECL )
BOOL hb_compExprReduceINT( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pParms = pSelf->value.asFunCall.pParms;
   HB_EXPR_PTR pArg = pParms->value.asList.pExprList;

   if( pArg->ExprType == HB_ET_NUMERIC )
   {
      HB_EXPR_PTR pExpr;

      if( pArg->value.asNum.NumType == HB_ET_LONG )
         pExpr = hb_compExprNewLong( pArg->value.asNum.val.l, HB_COMP_PARAM );
      else
      {
         HB_MAXDBL dVal = ( HB_MAXDBL ) pArg->value.asNum.val.d;
         if( HB_DBL_LIM_LONG( dVal ) )
            pExpr = hb_compExprNewLong( ( HB_LONG ) pArg->value.asNum.val.d, HB_COMP_PARAM );
         else
            pExpr = hb_compExprNewDouble( pArg->value.asNum.val.d,
                                          pArg->value.asNum.bWidth, 0,
                                          HB_COMP_PARAM );
      }
      HB_COMP_EXPR_FREE( pParms );
      HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pFunName );
      memcpy( pSelf, pExpr, sizeof( HB_EXPR ) );
      HB_COMP_EXPR_CLEAR( pExpr );
      return TRUE;
   }
   return FALSE;
}
expropt2.c1719
BOOLhb_compExprReduceDTOS( HB_EXPR_PTR pSelf, HB_COMP_DECL )
BOOL hb_compExprReduceDTOS( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pParms = pSelf->value.asFunCall.pParms;
   HB_EXPR_PTR pArg = pParms->value.asList.pExprList;

   if( pArg->ExprType == HB_ET_DATE )
   {
      char szBuffer[ 9 ];
      char * szDate = ( char * ) memcpy( hb_xgrab( 9 ),
                      hb_dateDecStr( szBuffer, ( long ) pArg->value.asNum.val.l ), 9 );
      HB_EXPR_PTR pExpr = hb_compExprNewString( szDate, 8, TRUE, HB_COMP_PARAM );

      HB_COMP_EXPR_FREE( pParms );
      HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pFunName );
      memcpy( pSelf, pExpr, sizeof( HB_EXPR ) );
      HB_COMP_EXPR_CLEAR( pExpr );
      return TRUE;
   }

   return FALSE;
}
expropt2.c1749
BOOLhb_compExprReduceSTOD( HB_EXPR_PTR pSelf, USHORT usCount, HB_COMP_DECL )
BOOL hb_compExprReduceSTOD( HB_EXPR_PTR pSelf, USHORT usCount, HB_COMP_DECL )
{
   if( usCount == 1 )
   {
      HB_EXPR_PTR pParms = pSelf->value.asFunCall.pParms;
      HB_EXPR_PTR pArg = pParms->value.asList.pExprList;

      if( pArg->ExprType == HB_ET_STRING && ( pArg->ulLength == 8 || pArg->ulLength == 0 ) )
      {
         HB_EXPR_PTR pExpr = hb_compExprNewDate( pArg->ulLength == 0 ? 0 :
                                  hb_dateEncStr( pArg->value.asString.string ),
                                  HB_COMP_PARAM );

         HB_COMP_EXPR_FREE( pParms );
         HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pFunName );
         memcpy( pSelf, pExpr, sizeof( HB_EXPR ) );
         HB_COMP_EXPR_CLEAR( pExpr );
         return TRUE;
      }
   }
   else
   {
      HB_EXPR_PTR pExpr = hb_compExprNewDate( 0, HB_COMP_PARAM );

      HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pParms );
      HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pFunName );
      memcpy( pSelf, pExpr, sizeof( HB_EXPR ) );
      HB_COMP_EXPR_CLEAR( pExpr );
      return TRUE;
   }

   return FALSE;
}
expropt2.c1771
BOOLhb_compExprReduceCTOD( HB_EXPR_PTR pSelf, HB_COMP_DECL )
BOOL hb_compExprReduceCTOD( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pParms = pSelf->value.asFunCall.pParms;
   HB_EXPR_PTR pArg = pParms->value.asList.pExprList;

   if( pArg->ExprType == HB_ET_STRING && pArg->ulLength == 0 )
   {
      HB_EXPR_PTR pExpr = hb_compExprNewDate( 0, HB_COMP_PARAM );

      HB_COMP_EXPR_FREE( pParms );
      HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pFunName );
      memcpy( pSelf, pExpr, sizeof( HB_EXPR ) );
      HB_COMP_EXPR_CLEAR( pExpr );
      return TRUE;
   }

   return FALSE;
}
expropt2.c1805
BOOLhb_compExprReduceUPPER( HB_EXPR_PTR pSelf, HB_COMP_DECL )
BOOL hb_compExprReduceUPPER( HB_EXPR_PTR pSelf, HB_COMP_DECL )
{
   HB_EXPR_PTR pParms = pSelf->value.asFunCall.pParms;
   HB_EXPR_PTR pArg = pParms->value.asList.pExprList;

   if( pArg->ExprType == HB_ET_STRING )
   {
      ULONG ulLen = pArg->ulLength;
      BOOL fLower = FALSE;

      if( ulLen )
      {
         char * szValue = pArg->value.asString.string;
         do
         {
            char c = * szValue++;
            if( c >= 'a' && c <= 'z' )
               fLower = TRUE;
            else if( !( ( c >= 'A' && c <= 'Z' ) ||
                        ( c >= '0' && c <= '9' ) || c == ' ' ) )
               break;
         }
         while( --ulLen );
      }

      if( ulLen == 0 )
      {
         HB_EXPR_PTR pExpr;
         char * szValue;
         BOOL fDealloc;

         if( fLower )
         {
            if( pArg->ulLength == 1 )
            {
               szValue = ( char * ) hb_szAscii[ toupper( (unsigned char)
                                          pArg->value.asString.string[ 0 ] ) ];
               fDealloc = FALSE;
            }
            else
            {
               if( pArg->value.asString.dealloc )
               {
                  szValue = pArg->value.asString.string;
                  pArg->value.asString.dealloc = FALSE;
                  fDealloc = TRUE;
               }
               else
               {
                  szValue = ( char * ) hb_xgrab( pArg->ulLength + 1 );
                  memcpy( szValue, pArg->value.asString.string, pArg->ulLength + 1 );
                  fDealloc = TRUE;
               }
               do
                  szValue[ ulLen ] = ( char ) toupper( ( unsigned char ) szValue[ ulLen ] );
               while( ++ulLen < pArg->ulLength );
            }
         }
         else
         {
            szValue = pArg->value.asString.string;
            fDealloc = pArg->value.asString.dealloc;
            pArg->value.asString.dealloc = FALSE;
         }

         pExpr = HB_COMP_EXPR_NEW( HB_ET_STRING );
         pExpr->ValType = HB_EV_STRING;
         pExpr->value.asString.string = szValue;
         pExpr->value.asString.dealloc = fDealloc;
         pExpr->ulLength = pArg->ulLength;

         HB_COMP_EXPR_FREE( pParms );
         HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pFunName );
         memcpy( pSelf, pExpr, sizeof( HB_EXPR ) );
         HB_COMP_EXPR_CLEAR( pExpr );

         return TRUE;
      }
   }

   return FALSE;
}
expropt2.c1824
BOOLhb_compExprReduceBitFunc( HB_EXPR_PTR pSelf, HB_LONG lResult, BOOL fBool, HB_COMP_DECL )
BOOL hb_compExprReduceBitFunc( HB_EXPR_PTR pSelf, HB_LONG lResult, BOOL fBool, HB_COMP_DECL )
{
   HB_EXPR_PTR pParms = pSelf->value.asFunCall.pParms;
   HB_EXPR_PTR pExpr = fBool ? hb_compExprNewLogical( lResult != 0, HB_COMP_PARAM ) :
                               hb_compExprNewLong( lResult, HB_COMP_PARAM );

   HB_COMP_EXPR_FREE( pParms );
   HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pFunName );
   memcpy( pSelf, pExpr, sizeof( HB_EXPR ) );
   HB_COMP_EXPR_CLEAR( pExpr );
   return TRUE;
}
expropt2.c1907
hbarch.c
TypeFunctionSourceLine
HB_EXPORT VOIDhb_put_ieee754( BYTE * ptr, double d )
HB_EXPORT void hb_put_ieee754( BYTE * ptr, double d )
{
   int iExp, iSig;
   double df;
#if defined( HB_LONG_LONG_OFF )
   UINT32 l1, l2;

   HB_TRACE(HB_TR_DEBUG, ("hb_put_ieee754(%p, %f)", ptr, d));

   iSig = d < 0 ? 1 : 0;
   if( d == 0.0 )
   {
      l1 = l2 = 0;
   }
   else
   {
      df = frexp( iSig ? -d : d, &iExp );
      l1 = ( UINT32 ) ldexp( df, HB_MANTISSA_BITS + 1 );
      l2 = ( UINT32 ) ldexp( df, HB_MANTISSA_BITS + 1 - 32 ) &
                         ( ( ( UINT32 ) 1 << ( HB_MANTISSA_BITS - 32 ) ) - 1 );
      l2 |= ( UINT32 ) ( ( iExp + HB_EXPONENT_ADD - 1 ) & HB_EXPONENT_MASK ) <<
                       ( HB_MANTISSA_BITS - 32 );
   }
   l2 |= ( UINT32 ) iSig << ( HB_MANTISSA_BITS + HB_EXPONENT_BITS - 32 );
   HB_PUT_LE_UINT32( ptr, l1 );
   HB_PUT_LE_UINT32( ptr + 4, l2 );
#else
   UINT64 ll;

   HB_TRACE(HB_TR_DEBUG, ("hb_put_ieee754(%p, %f)", ptr, d));

   iSig = d < 0 ? 1 : 0;
   if( d == 0.0 )
   {
      ll = 0;
   }
   else
   {
      df = frexp( iSig ? -d : d, &iExp );
      ll = ( UINT64 ) ldexp( df, HB_MANTISSA_BITS + 1 ) & HB_MANTISSA_MASK;
      ll |= ( UINT64 ) ( ( iExp + HB_EXPONENT_ADD - 1 ) & HB_EXPONENT_MASK ) <<
                       HB_MANTISSA_BITS;
   }
   ll |= ( UINT64 ) iSig << ( HB_MANTISSA_BITS + HB_EXPONENT_BITS );
   HB_PUT_LE_UINT64( ptr, ll );
#endif
}
hbarch.c74
HB_EXPORT DOUBLEhb_get_ieee754( BYTE * ptr )
HB_EXPORT double hb_get_ieee754( BYTE * ptr )
{
   int iExp, iSig;
#if defined( HB_LONG_LONG_OFF )
   UINT32 l1, l2;
   double d;

   HB_TRACE(HB_TR_DEBUG, ("hb_get_ieee754(%p)", ptr));

   l1 = HB_GET_LE_UINT32( ptr );
   l2 = HB_GET_LE_UINT32( ptr + 4 );
   iSig = ( int ) ( l2 >> ( HB_MANTISSA_BITS + HB_EXPONENT_BITS - 32 ) ) & 1;
   iExp = ( int ) ( ( l2 >> ( HB_MANTISSA_BITS - 32 ) ) & HB_EXPONENT_MASK );
   l2 &= ( ( UINT32 ) 1 << ( HB_MANTISSA_BITS - 32 ) ) - 1;

   if( ( l1 | l2 | iExp ) != 0 )
      l2 |= ( UINT32 ) 1 << ( HB_MANTISSA_BITS - 32 );

   d = ldexp( ( double ) l2, 32 ) + ( double ) l1;
   return ldexp( iSig ? -d : d, iExp - HB_MANTISSA_BITS - HB_EXPONENT_ADD );
#else
   UINT64 ll;

   HB_TRACE(HB_TR_DEBUG, ("hb_get_ieee754(%p)", ptr));

   ll = HB_GET_LE_UINT64( ptr );
   iSig = ( int ) ( ll >> ( HB_MANTISSA_BITS + HB_EXPONENT_BITS ) ) & 1;
   iExp = ( int ) ( ( ll >> HB_MANTISSA_BITS ) & HB_EXPONENT_MASK );
   ll &= HB_MANTISSA_MASK;
   if( ( ll | iExp ) != 0 )
      ll |= ( UINT64 ) 1 << HB_MANTISSA_BITS;
   /* the casting form UINT64 to INT64 is necessary for some
      compilers which does not support UINT64 -> double conversion
      It will not change results because there is only up to 53bits
      set in mantissa */
   return ldexp( iSig ? -( double ) ( INT64 ) ll : ( double ) ( INT64 ) ll,
                 iExp - HB_MANTISSA_BITS - HB_EXPONENT_ADD );
#endif
}
hbarch.c122
HB_EXPORT VOIDhb_put_ord_ieee754( BYTE * ptr, double d )
HB_EXPORT void hb_put_ord_ieee754( BYTE * ptr, double d )
{
   int iExp, iSig;
   double df;
   UINT32 l1, l2;

   HB_TRACE(HB_TR_DEBUG, ("hb_put_ord_ieee754(%p, %f)", ptr, d));

   iSig = d < 0 ? 1 : 0;
   if( d == 0.0 )
   {
      l1 = l2 = 0;
   }
   else
   {
      df = frexp( iSig ? -d : d, &iExp );
      l1 = ( UINT32 ) ldexp( df, HB_MANTISSA_BITS + 1 );
      l2 = ( UINT32 ) ldexp( df, HB_MANTISSA_BITS + 1 - 32 ) &
                         ( ( ( UINT32 ) 1 << ( HB_MANTISSA_BITS - 32 ) ) - 1 );
      l2 |= ( UINT32 ) ( ( iExp + HB_EXPONENT_ADD - 1 ) & HB_EXPONENT_MASK ) <<
                       ( HB_MANTISSA_BITS - 32 );
   }
   if( iSig )
   {
      l2 ^= 0x7FFFFFFFL;
      l1 ^= 0xFFFFFFFFL;
   }
   else
   {
      l2 ^= 0x80000000L;
   }
   HB_PUT_BE_UINT32( ptr, l2 );
   HB_PUT_BE_UINT32( ptr + 4, l1 );
}
hbarch.c162
HB_EXPORT DOUBLEhb_get_ord_ieee754( BYTE * ptr )
HB_EXPORT double hb_get_ord_ieee754( BYTE * ptr )
{
   int iExp, iSig;
   UINT32 l1, l2;
   double d;

   HB_TRACE(HB_TR_DEBUG, ("hb_get_ord_ieee754(%p)", ptr));

   l1 = HB_GET_BE_UINT32( ptr + 4 );
   l2 = HB_GET_BE_UINT32( ptr );
   iSig = ( l2 & 0x80000000L ) ? 0 : 1;
   if( iSig )
   {
      l2 ^= 0x7FFFFFFFL;
      l1 ^= 0xFFFFFFFFL;
   }
   iExp = ( ( l2 >> ( HB_MANTISSA_BITS - 32 ) ) & HB_EXPONENT_MASK );
   l2 &= ( ( UINT32 ) 1 << ( HB_MANTISSA_BITS - 32 ) ) - 1;

   if( ( l1 | l2 | iExp ) != 0 )
      l2 |= ( UINT32 ) 1 << ( HB_MANTISSA_BITS - 32 );

   d = ldexp( ( double ) l2, 32 ) + ( double ) l1;
   return ldexp( iSig ? -d : d, iExp - HB_MANTISSA_BITS - HB_EXPONENT_ADD );
}
hbarch.c197
HB_EXPORT DOUBLEhb_get_rev_double( BYTE * ptr )
HB_EXPORT double hb_get_rev_double( BYTE * ptr )
{
   union {
      double dbl;
      BYTE buffer[ 8 ];
   } u;

   HB_TRACE(HB_TR_DEBUG, ("hb_get_rev_double(%p)", ptr));

   u.buffer[ 0 ] = ptr[ 7 ];
   u.buffer[ 1 ] = ptr[ 6 ];
   u.buffer[ 2 ] = ptr[ 5 ];
   u.buffer[ 3 ] = ptr[ 4 ];
   u.buffer[ 4 ] = ptr[ 3 ];
   u.buffer[ 5 ] = ptr[ 2 ];
   u.buffer[ 6 ] = ptr[ 1 ];
   u.buffer[ 7 ] = ptr[ 0 ];

   return u.dbl;
}
hbarch.c223
HB_EXPORT DOUBLEhb_get_std_double( BYTE * ptr )
HB_EXPORT double hb_get_std_double( BYTE * ptr )
{
   union {
      double dbl;
      BYTE buffer[ 8 ];
   } u;

   HB_TRACE(HB_TR_DEBUG, ("hb_get_std_double(%p)", ptr));

   u.buffer[ 0 ] = ptr[ 0 ];
   u.buffer[ 1 ] = ptr[ 1 ];
   u.buffer[ 2 ] = ptr[ 2 ];
   u.buffer[ 3 ] = ptr[ 3 ];
   u.buffer[ 4 ] = ptr[ 4 ];
   u.buffer[ 5 ] = ptr[ 5 ];
   u.buffer[ 6 ] = ptr[ 6 ];
   u.buffer[ 7 ] = ptr[ 7 ];

   return u.dbl;
}
hbarch.c249
HB_EXPORT DOUBLEhb_get_le_uint64( BYTE * ptr )
HB_EXPORT double hb_get_le_uint64( BYTE * ptr )
{
   UINT32 l1, l2;

   HB_TRACE(HB_TR_DEBUG, ("hb_get_le_uint64(%p)", ptr));

   l1 = HB_GET_LE_UINT32( ptr );
   l2 = HB_GET_LE_UINT32( ptr + 4 );
   return ldexp( ( double ) l2, 32 ) + ( double ) l1;
}
hbarch.c272
HB_EXPORT DOUBLEhb_get_le_int64( BYTE * ptr )
HB_EXPORT double hb_get_le_int64( BYTE * ptr )
{
   UINT32 l1;
   INT32 l2;

   HB_TRACE(HB_TR_DEBUG, ("hb_get_le_int64(%p)", ptr));

   l1 = HB_GET_LE_UINT32( ptr );
   l2 = HB_GET_LE_INT32( ptr + 4 );
   return ldexp( ( double ) l2, 32 ) + ( double ) l1;
}
hbarch.c289
HB_EXPORT VOIDhb_put_le_uint64( BYTE * ptr, double d )
HB_EXPORT void hb_put_le_uint64( BYTE * ptr, double d )
{
   UINT32 l1, l2;

   HB_TRACE(HB_TR_DEBUG, ("hb_put_le_uint64(%p)", ptr));

   l1 = ( UINT32 ) ( d );
   l2 = ( UINT32 ) ( d / 4294967296.0 );
   HB_PUT_LE_UINT32( ptr, l1 );
   HB_PUT_LE_UINT32( ptr + 4, l2 );
}
hbarch.c301
hbdate.c
TypeFunctionSourceLine
HB_EXPORT LONGhb_dateEncode( int iYear, int iMonth, int iDay )
HB_EXPORT LONG hb_dateEncode( int iYear, int iMonth, int iDay )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_dateEncode(%d, %d, %d)", iYear, iMonth, iDay));

   /* Perform date validation */
   if( iYear >= 0 && iYear <= HB_DATE_YEAR_LIMIT &&
       iMonth >= 1 && iMonth <= 12 &&
       iDay >= 1 )
   {
      /* Month, year, and lower day limits are simple,
         but upper day limit is dependent upon month and leap year */
      static const int auiDayLimit[ 12 ] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

      if( iDay <= auiDayLimit[ iMonth - 1 ] ||
          ( iDay == 29 && iMonth == 2 &&
            ( iYear & 3 ) == 0 && ( iYear % 100 != 0 || iYear % 400 == 0 ) ) )
      {
         int iFactor = ( iMonth < 3 ) ? -1 : 0;

         return ( ( LONG )( iFactor + 4800 + iYear ) * 1461 / 4 ) +
                ( ( LONG )( iMonth - 2 - ( iFactor * 12 ) ) * 367 ) / 12 -
                ( ( LONG )( ( iFactor + 4900 + iYear ) / 100 ) * 3 / 4 ) +
                ( LONG ) iDay - 32075;
      }
   }

   return 0;
}
hbdate.c85
HB_EXPORT VOIDhb_dateDecode( LONG lJulian, int *piYear, int *piMonth, int *piDay )
HB_EXPORT void hb_dateDecode( LONG lJulian, int *piYear, int *piMonth, int *piDay )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_dateDecode(%ld, %p, %p, %p)", lJulian, piYear, piMonth, piDay));

   if( lJulian >= HB_STR_DATE_BASE )
   {
      LONG U, V, W, X;

      lJulian += 68569;
      W = ( lJulian * 4 ) / 146097;
      lJulian -= ( ( 146097 * W ) + 3 ) / 4;
      X = 4000 * ( lJulian + 1 ) / 1461001;
      lJulian -= ( ( 1461 * X ) / 4 ) - 31;
      V = 80 * lJulian / 2447;
      U = V / 11;

      *piYear  = (int) ( X + U + ( W - 49 ) * 100 );
      *piMonth = (int) ( V + 2 - ( U * 12 ) );
      *piDay   = (int) ( lJulian - ( 2447 * V / 80 ) );
   }
   else
   {
      *piYear  =
      *piMonth =
      *piDay   = 0;
   }
}
hbdate.c114
HB_EXPORT VOIDhb_dateStrPut( char * szDate, int iYear, int iMonth, int iDay )
HB_EXPORT void hb_dateStrPut( char * szDate, int iYear, int iMonth, int iDay )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_dateStrPut(%p, %d, %d, %d)", szDate, iYear, iMonth, iDay));

   if( iYear >= 0 && iMonth > 0 && iDay > 0 )
   {
      szDate[ 0 ] = ( char ) ( ( ( iYear / 1000 ) % 10 ) + '0' );
      szDate[ 1 ] = ( char ) ( ( ( iYear / 100 ) % 10 ) + '0' );
      szDate[ 2 ] = ( char ) ( ( ( iYear / 10 ) % 10 ) + '0' );
      szDate[ 3 ] = ( char ) ( ( iYear % 10 ) + '0' );

      szDate[ 4 ] = ( char ) ( ( iMonth / 10 ) + '0' );
      szDate[ 5 ] = ( char ) ( ( iMonth % 10 ) + '0' );

      szDate[ 6 ] = ( char ) ( ( iDay / 10 ) + '0' );
      szDate[ 7 ] = ( char ) ( ( iDay % 10 ) + '0' );
   }
   else
   {
      memset( szDate, '0', 8 );
   }
}
hbdate.c142
HB_EXPORT VOIDhb_dateStrGet( const char * szDate, int * piYear, int * piMonth, int * piDay )
HB_EXPORT void hb_dateStrGet( const char * szDate, int * piYear, int * piMonth, int * piDay )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_dateStrGet(%s, %p, %p, %p)", szDate, piYear, piMonth, piDay));

#if defined( HB_C52_STRICT ) || 1
   if( szDate )
#else
   if( szDate &&
       szDate[ 0 ] >= '0' && szDate[ 0 ] <= '9' &&
       szDate[ 1 ] >= '0' && szDate[ 1 ] <= '9' &&
       szDate[ 2 ] >= '0' && szDate[ 2 ] <= '9' &&
       szDate[ 3 ] >= '0' && szDate[ 3 ] <= '9' &&
       szDate[ 4 ] >= '0' && szDate[ 4 ] <= '9' &&
       szDate[ 5 ] >= '0' && szDate[ 5 ] <= '9' &&
       szDate[ 6 ] >= '0' && szDate[ 6 ] <= '9' &&
       szDate[ 7 ] >= '0' && szDate[ 7 ] <= '9' )
#endif
   {
      /* Date string has correct length, so attempt to convert */
      *piYear  = ( ( ( int ) ( szDate[ 0 ] - '0' )   * 10 +
                     ( int ) ( szDate[ 1 ] - '0' ) ) * 10 +
                     ( int ) ( szDate[ 2 ] - '0' ) ) * 10 +
                     ( int ) ( szDate[ 3 ] - '0' );
      *piMonth = ( szDate[ 4 ] - '0' ) * 10 + ( szDate[ 5 ] - '0' );
      *piDay   = ( szDate[ 6 ] - '0' ) * 10 + ( szDate[ 7 ] - '0' );
   }
   else
   {
      /* Date string missing or bad length, so force an empty date */
      *piYear  =
      *piMonth =
      *piDay   = 0;
   }
}
hbdate.c165
HB_EXPORT CHAR *hb_dateDecStr( char * szDate, LONG lJulian )
HB_EXPORT char * hb_dateDecStr( char * szDate, LONG lJulian )
{
   int iYear, iMonth, iDay;

   HB_TRACE(HB_TR_DEBUG, ("hb_dateDecStr(%p, %ld)", szDate, lJulian));

   if( lJulian <= 0 )
   {
      memset( szDate, ' ', 8 );
   }
   else
   {
      hb_dateDecode( lJulian, &iYear, &iMonth, &iDay );
      hb_dateStrPut( szDate, iYear, iMonth, iDay );
   }
   szDate[ 8 ] = '\0';

   return szDate;
}
hbdate.c203
HB_EXPORT LONGhb_dateEncStr( const char * szDate )
HB_EXPORT LONG hb_dateEncStr( const char * szDate )
{
   int  iYear, iMonth, iDay;

   HB_TRACE(HB_TR_DEBUG, ("hb_dateEncStr(%s)", szDate));

   hb_dateStrGet( szDate, &iYear, &iMonth, &iDay );

   return hb_dateEncode( iYear, iMonth, iDay );
}
hbdate.c223
HB_EXPORT INThb_dateJulianDOW( LONG lJulian )
HB_EXPORT int hb_dateJulianDOW( LONG lJulian )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_dateJulianDOW(%ld)", lJulian));

   if( lJulian >= HB_STR_DATE_BASE )
      return ( int ) ( ( lJulian + 1 ) % 7 ) + 1;
   else
      return 0;
}
hbdate.c234
HB_EXPORT INThb_dateDOW( int iYear, int iMonth, int iDay )
HB_EXPORT int hb_dateDOW( int iYear, int iMonth, int iDay )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_dateDOW(%d, %d, %d)", iYear, iMonth, iDay));

   if( iMonth < 3 )
   {
      iMonth += 13;
      iYear--;
   }
   else
      iMonth++;

   return ( iDay + 26 * iMonth / 10 +
            iYear + iYear / 4 - iYear / 100 + iYear / 400 + 6 ) % 7 + 1;
}
hbdate.c244
HB_EXPORT VOIDhb_dateToday( int * piYear, int * piMonth, int * piDay )
HB_EXPORT void hb_dateToday( int * piYear, int * piMonth, int * piDay )
{
#if defined(HB_OS_WIN_32)

   SYSTEMTIME st;
   GetLocalTime( &st );

   *piYear  = st.wYear;
   *piMonth = st.wMonth;
   *piDay   = st.wDay;

#elif defined( HB_OS_LINUX ) && !defined( __WATCOMC__ )

   time_t t;
   struct tm st;

   time( &t );
   localtime_r( &t, &st );

   *piYear  = st.tm_year + 1900;
   *piMonth = st.tm_mon + 1;
   *piDay   = st.tm_mday;

#else

   time_t t;
   struct tm * oTime;

   time( &t );
   oTime = localtime( &t );

   *piYear  = oTime->tm_year + 1900;
   *piMonth = oTime->tm_mon + 1;
   *piDay   = oTime->tm_mday;

#endif
}
hbdate.c260
HB_EXPORT VOIDhb_dateTimeStr( char * pszTime )
HB_EXPORT void hb_dateTimeStr( char * pszTime )
{
#if defined(HB_OS_WIN_32)
   {
      SYSTEMTIME st;
      GetLocalTime( &st );
      snprintf( pszTime, 9, "%02d:%02d:%02d", st.wHour, st.wMinute, st.wSecond );
   }
#elif defined( HB_OS_LINUX ) && !defined( __WATCOMC__ )
   {
      time_t t;
      struct tm st;

      time( &t );
      localtime_r( &t, &st );

      snprintf( pszTime, 9, "%02d:%02d:%02d", st.tm_hour, st.tm_min, st.tm_sec );
   }
#else
   {
      time_t t;
      struct tm * oTime;

      time( &t );
      oTime = localtime( &t );
      snprintf( pszTime, 9, "%02d:%02d:%02d", oTime->tm_hour, oTime->tm_min, oTime->tm_sec );
   }
#endif
}
hbdate.c300
HB_EXPORT LONGhb_timeStampEncode( int iHour, int iMinutes, int iSeconds, int iMSec )
HB_EXPORT LONG hb_timeStampEncode( int iHour, int iMinutes, int iSeconds, int iMSec )
{
   LONG lMillisec;

   HB_TRACE(HB_TR_DEBUG, ("hb_timeStampEncode(%d, %d, %d, %d)", iHour, iMinutes, iSeconds, iMSec));

   if( iHour >= 0 && iHour < 24 &&
       iMinutes >= 0 && iMinutes < 60 &&
       iSeconds >= 0 && iSeconds < 60 &&
       iMSec >= 0 && iMSec < 1000 )
   {
      lMillisec = ( ( LONG ) ( iHour * 60 + iMinutes ) * 60 + iSeconds ) *
                  1000 + iMSec;
   }
   else
   {
      lMillisec = 0;
   }

   return lMillisec;
}
hbdate.c330
HB_EXPORT VOIDhb_timeStampDecode( LONG lMillisec, int * piHour, int * piMinutes, int * piSeconds, int * piMSec )
HB_EXPORT void hb_timeStampDecode( LONG lMillisec, int * piHour, int * piMinutes,
                                   int * piSeconds, int * piMSec )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_timeStampDecode(%ld, %p, %p, %p, %p)", lMillisec, piHour, piMinutes, piSeconds, piMSec));

   if( lMillisec <= 0 )
   {
      *piHour = *piMinutes = *piSeconds = *piMSec = 0;
   }
   else
   {
      *piMSec = lMillisec % 1000;
      lMillisec /= 1000;
      *piSeconds = lMillisec % 60;
      lMillisec /= 60;
      *piMinutes = lMillisec % 60;
      lMillisec /= 60;
      if( lMillisec >= 24 )
         *piHour = *piMinutes = *piSeconds = *piMSec = 0;
      else
         *piHour = ( int ) lMillisec;
   }
}
hbdate.c352
HB_EXPORT CHAR *hb_timeStampStr( char * szTime, LONG lMillisec )
HB_EXPORT char * hb_timeStampStr( char * szTime, LONG lMillisec )
{
   int iHour, iMinutes, iSeconds, iMSec;

   HB_TRACE(HB_TR_DEBUG, ("hb_timeStampStr(%p, %ld)", szTime, lMillisec));

   hb_timeStampDecode( lMillisec, &iHour, &iMinutes, &iSeconds, &iMSec );
   snprintf( szTime, 13, "%02d:%02d:%02d.%03d",
             iHour, iMinutes, iSeconds, iMSec );
   szTime[ 12 ] = '\0';

   return szTime;
}
hbdate.c379
HB_EXPORT CHAR *hb_dateTimeStampStr( char * szDateTime, LONG lJulian, LONG lMillisec )
HB_EXPORT char * hb_dateTimeStampStr( char * szDateTime, LONG lJulian, LONG lMillisec )
{
   int iYear, iMonth, iDay, iHour, iMinutes, iSeconds, iMSec;

   HB_TRACE(HB_TR_DEBUG, ("hb_dateTimeStampStr(%p, %ld, %ld)", szDateTime, lJulian, lMillisec));

   hb_dateDecode( lJulian, &iYear, &iMonth, &iDay );
   hb_timeStampDecode( lMillisec, &iHour, &iMinutes, &iSeconds, &iMSec );
   snprintf( szDateTime, 24, "%04d-%02d-%02d %02d:%02d:%02d.%03d",
             iYear, iMonth, iDay, iHour, iMinutes, iSeconds, iMSec );
   szDateTime[ 23 ] = '\0';

   return szDateTime;
}
hbdate.c396
HB_EXPORT VOIDhb_timeStrGet( const char * szTime, int * piHour, int * piMinutes, int * piSeconds, int * piMSec )
HB_EXPORT void hb_timeStrGet( const char * szTime, int * piHour, int * piMinutes,
                              int * piSeconds, int * piMSec )
{
   int iHour, iMinutes, iSeconds, iMSec;

   HB_TRACE(HB_TR_DEBUG, ("hb_timeStrGet(%s, %p, %p, %p, %p)", szTime, piHour, piMinutes, piSeconds, piMSec));

   iHour = iMinutes = iSeconds = iMSec = 0;

   if( szTime )
   {
      int iLen = hb_strnlen( szTime, 12 );

      if( iLen >= 5 )
      {

         iHour    = ( szTime[ 0 ] - '0' ) * 10 +
                    ( szTime[ 1 ] - '0' );
         iMinutes = ( szTime[ 3 ] - '0' ) * 10 +
                    ( szTime[ 4 ] - '0' );
         if( iHour >= 0 && iHour < 24 && iMinutes >= 0 && iMinutes < 60 )
         {
            if( iLen >= 8 )
            {
               iSeconds = ( szTime[ 6 ] - '0' ) * 10 +
                          ( szTime[ 7 ] - '0' );
               if( iSeconds < 0 || iSeconds >= 60 )
                  iSeconds = 0;
               else if( iLen >= 12 )
               {
                  iMSec = ( ( szTime[  9 ] - '0' )   * 10 +
                            ( szTime[ 10 ] - '0' ) ) * 10 +
                            ( szTime[ 11 ] - '0' );
                  if( iMSec < 0 || iMSec >= 1000 )
                     iMSec = 0;
               }
            }
         }
      }
   }

   if( piHour )
      *piHour = iHour;
   if( piMinutes )
      *piMinutes = iMinutes;
   if( piSeconds )
      *piSeconds = iSeconds;
   if( piMSec )
      *piMSec = iMSec;
}
hbdate.c411
HB_EXPORT VOIDhb_dateTimeStampStrGet( const char * szDateTime, LONG * plJulian, LONG * plMillisec )
HB_EXPORT void hb_dateTimeStampStrGet( const char * szDateTime, LONG * plJulian, LONG * plMillisec )
{
   int iLen;

   HB_TRACE(HB_TR_DEBUG, ("hb_dateTimeStampStr(%s, %p, %p)", szDateTime, plJulian, plMillisec));

   *plJulian = *plMillisec = 0;
   iLen = szDateTime ? hb_strnlen( szDateTime, 23 ) : 0;
   if( iLen >= 10 )
   {
      int iYear, iMonth, iDay;

      iYear  = ( ( ( int ) ( szDateTime[ 0 ] - '0' )   * 10 +
                   ( int ) ( szDateTime[ 1 ] - '0' ) ) * 10 +
                   ( int ) ( szDateTime[ 2 ] - '0' ) ) * 10 +
                   ( int ) ( szDateTime[ 3 ] - '0' );
      iMonth = ( szDateTime[ 5 ] - '0' ) * 10 + ( szDateTime[ 6 ] - '0' );
      iDay   = ( szDateTime[ 8 ] - '0' ) * 10 + ( szDateTime[ 9 ] - '0' );

      *plJulian = hb_dateEncode( iYear, iMonth, iDay );
      if( iLen >= 16 )
      {
         int iHour, iMinutes, iSeconds = 0, iMSec = 0;

         iHour    = ( szDateTime[ 11 ] - '0' ) * 10 +
                    ( szDateTime[ 12 ] - '0' );
         iMinutes = ( szDateTime[ 14 ] - '0' ) * 10 +
                    ( szDateTime[ 15 ] - '0' );
         if( iHour >= 0 && iHour < 24 && iMinutes >= 0 && iMinutes < 60 )
         {
            if( iLen >= 19 )
            {
               iSeconds = ( szDateTime[ 17 ] - '0' ) * 10 +
                          ( szDateTime[ 18 ] - '0' );
               if( iSeconds < 0 || iSeconds >= 60 )
                  iSeconds = 0;
               else if( iLen >= 23 )
               {
                  iMSec = ( ( szDateTime[ 20 ] - '0' )   * 10 +
                            ( szDateTime[ 21 ] - '0' ) ) * 10 +
                            ( szDateTime[ 22 ] - '0' );
                  if( iMSec < 0 || iMSec >= 1000 )
                     iMSec = 0;
               }
            }
            *plMillisec = ( ( ( iHour * 60 ) + iMinutes ) * 60 + iSeconds ) *
                          1000 + iMSec;
         }
      }
   }
}
hbdate.c462
hbfopen.c
TypeFunctionSourceLine
FILE *hb_fopen( const char *path, const char *mode )
FILE * hb_fopen( const char *path, const char *mode )
{
   BOOL fFree;
   char * pszFile = ( char * ) hb_fsNameConv( ( BYTE * ) path, &fFree );
   FILE * file = fopen( pszFile, mode );

   if( fFree )
      hb_xfree( pszFile );

   return file;
}
hbfopen.c55
hbfsapi.c
TypeFunctionSourceLine
HB_EXPORT VOIDhb_fsAddSearchPath( const char * szPath, HB_PATHNAMES ** pSearchList )
HB_EXPORT void hb_fsAddSearchPath( const char * szPath, HB_PATHNAMES ** pSearchList )
{
   char * pPath;
   char * pDelim;
   BOOL fFree = TRUE;

   while( *pSearchList )
   {
      pSearchList = &(*pSearchList)->pNext;
   }

   pPath = hb_strdup( szPath );
   while( ( pDelim = strchr( pPath, HB_OS_PATH_LIST_SEP_CHR ) ) != NULL )
   {
      *pDelim = '\0';
      *pSearchList = ( HB_PATHNAMES * ) hb_xgrab( sizeof( HB_PATHNAMES ) );
      (*pSearchList)->szPath = pPath;
      (*pSearchList)->fFree  = fFree;
      pSearchList = &(*pSearchList)->pNext;
      pPath = pDelim + 1;
      fFree = FALSE;
   }
   *pSearchList = ( HB_PATHNAMES * ) hb_xgrab( sizeof( HB_PATHNAMES ) );
   (*pSearchList)->szPath = pPath;
   (*pSearchList)->pNext  = NULL;
   (*pSearchList)->fFree  = fFree;
}
hbfsapi.c87
HB_EXPORT VOIDhb_fsFreeSearchPath( HB_PATHNAMES * pSearchList )
HB_EXPORT void hb_fsFreeSearchPath( HB_PATHNAMES * pSearchList )
{
   HB_PATHNAMES * pNext;

   /* Only the first path holds an allocated string.
      All of the other paths in the list are part of
      that first string. */

   while( pSearchList )
   {
      if( pSearchList->fFree )
         hb_xfree( pSearchList->szPath );
      pNext = pSearchList->pNext;
      hb_xfree( pSearchList );
      pSearchList = pNext;
   }
}
hbfsapi.c118
HB_EXPORT PHB_FNAMEhb_fsFNameSplit( const char * pszFileName )
HB_EXPORT PHB_FNAME hb_fsFNameSplit( const char * pszFileName )
{
   PHB_FNAME pFileName;
   char * pszPos, cDirSep;
   int iSize, iPos;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsFNameSplit(%s)", pszFileName));

   HB_TRACE(HB_TR_INFO, ("hb_fsFNameSplit: Filename: |%s|\n", pszFileName));

   iPos = iSize = hb_strnlen( pszFileName, _POSIX_PATH_MAX );
   cDirSep = ( char ) hb_setGetDirSeparator();

   /* Grab memory, set defaults */
   pFileName = ( PHB_FNAME ) hb_xgrab( sizeof( HB_FNAME ) );

   pszPos = pFileName->szBuffer;

   pFileName->szPath = pFileName->szName = pFileName->szExtension =
   pFileName->szDrive = NULL;

   /* Find the end of the path part, and find out where the
      name+ext starts */

   while( --iPos >= 0 )
   {
      if( pszFileName[ iPos ] == cDirSep ||
          strchr( HB_OS_PATH_DELIM_CHR_LIST, pszFileName[ iPos ] ) )
      {
         pFileName->szPath = pszPos;
         hb_strncpy( pszPos, pszFileName, iPos + 1 );
         pszPos += iPos + 2;
         pszFileName += iPos + 1;
         iSize -= iPos + 1;
         break;
      }
   }

   /* From this point pszFileName will point to the name+ext part of the path */
   /* Split the filename part to name and extension */
   iPos = iSize;
   while( --iPos > 0 )
   {
      if( pszFileName[ iPos ] == '.' )
      {
         pFileName->szExtension = pszPos;
         hb_strncpy( pszPos, pszFileName + iPos, iSize - iPos );
         pszPos += iSize - iPos + 1;
         iSize = iPos;
         break;
      }
   }
   if( iSize )
   {
      pFileName->szName = pszPos;
      hb_strncpy( pszPos, pszFileName, iSize );
      pszPos += iSize + 1;
   }

   /* Duplicate the drive letter from the path for easy access on
      platforms where applicable. Note that the drive info is always
      present also in the path itself. */

   if( pFileName->szPath )
   {
      iPos = 0;
      while( iPos < HB_MAX_DRIVE_LENGTH && pFileName->szPath[ iPos ] != '\0' )
      {
         if( pFileName->szPath[ iPos ] == ':' )
         {
            pFileName->szDrive = pszPos;
            hb_strncpy( pszPos, pFileName->szPath, iPos );
            break;
         }
         ++iPos;
      }
   }

   HB_TRACE(HB_TR_INFO, ("hb_fsFNameSplit:   szPath: |%s|\n", pFileName->szPath));
   HB_TRACE(HB_TR_INFO, ("hb_fsFNameSplit:   szName: |%s|\n", pFileName->szName));
   HB_TRACE(HB_TR_INFO, ("hb_fsFNameSplit:    szExt: |%s|\n", pFileName->szExtension));
   HB_TRACE(HB_TR_INFO, ("hb_fsFNameSplit:  szDrive: |%s|\n", pFileName->szDrive));

   return pFileName;
}
hbfsapi.c139
HB_EXPORT CHAR *hb_fsFNameMerge( char * pszFileName, PHB_FNAME pFileName )
HB_EXPORT char * hb_fsFNameMerge( char * pszFileName, PHB_FNAME pFileName )
{
   const char * pszName;
   char cDirSep;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsFNameMerge(%p, %p)", pszFileName, pFileName));

   /* dir separator set by user */ 
   cDirSep = ( char ) hb_setGetDirSeparator();

   /* Set the result to an empty string */
   pszFileName[ 0 ] = '\0';

   /* Strip preceding path separators from the filename */
   pszName = pFileName->szName;
   if( pszName && pszName[ 0 ] != '\0' && ( pszName[ 0 ] == cDirSep ||
       strchr( HB_OS_PATH_DELIM_CHR_LIST, pszName[ 0 ] ) != NULL ) )
      pszName++;

   /* Add path if specified */
   if( pFileName->szPath )
      hb_strncat( pszFileName, pFileName->szPath, _POSIX_PATH_MAX - 1 );

   /* If we have a path, append a path separator to the path if there
      was none. */
   if( pszFileName[ 0 ] != '\0' && ( pszName || pFileName->szExtension ) )
   {
      int iLen = strlen( pszFileName ) - 1;

      if( iLen < _POSIX_PATH_MAX - 2 && pszFileName[ iLen ] != cDirSep &&
          strchr( HB_OS_PATH_DELIM_CHR_LIST, pszFileName[ iLen ] ) == NULL )
      {
         pszFileName[ iLen + 1 ] = HB_OS_PATH_DELIM_CHR;
         pszFileName[ iLen + 2 ] = '\0';
      }
   }

   /* Add filename (without extension) if specified */
   if( pszName )
      hb_strncat( pszFileName, pszName, _POSIX_PATH_MAX - 1 );

   /* Add extension if specified */
   if( pFileName->szExtension )
   {
      /* Add a dot if the extension doesn't have it */
      if( pFileName->szExtension[ 0 ] != '\0' &&
          pFileName->szExtension[ 0 ] != '.' )
         hb_strncat( pszFileName, ".", _POSIX_PATH_MAX - 1 );

      hb_strncat( pszFileName, pFileName->szExtension, _POSIX_PATH_MAX - 1 );
   }

   HB_TRACE(HB_TR_INFO, ("hb_fsFNameMerge:   szPath: |%s|\n", pFileName->szPath));
   HB_TRACE(HB_TR_INFO, ("hb_fsFNameMerge:   szName: |%s|\n", pFileName->szName));
   HB_TRACE(HB_TR_INFO, ("hb_fsFNameMerge:    szExt: |%s|\n", pFileName->szExtension));
   HB_TRACE(HB_TR_INFO, ("hb_fsFNameMerge:  szDrive: |%s|\n", pFileName->szDrive));
   HB_TRACE(HB_TR_INFO, ("hb_fsFNameMerge: Filename: |%s|\n", pszFileName));

   return pszFileName;
}
hbfsapi.c232
HB_EXPORT BOOLhb_fsFileExists( const char * pszFileName )
HB_EXPORT BOOL hb_fsFileExists( const char * pszFileName )
{
   BOOL fExist;
   BOOL fFree;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsFileExists(%p)", pszFileName));

   if( pszFileName == NULL )
      return FALSE;

   pszFileName = ( char * ) hb_fsNameConv( ( BYTE * ) pszFileName, &fFree );

#if defined( HB_OS_DOS )
   {
#if defined( __DJGPP__ ) || defined(__BORLANDC__)
      int iAttr = _chmod( pszFileName, 0, 0 );
      fExist = iAttr != -1 && ( iAttr & 0x10 ) == 0;
#else
      unsigned int iAttr = 0;
      fExist = _dos_getfileattr( pszFileName, &iAttr ) == 0 &&
               ( iAttr & 0x10 ) == 0;
#endif
   }
#elif defined( HB_OS_WIN_32 )
   {
      DWORD   dwAttr;

      dwAttr = GetFileAttributesA( pszFileName );
      fExist = ( dwAttr != INVALID_FILE_ATTRIBUTES ) &&
               ( dwAttr & ( FILE_ATTRIBUTE_DIRECTORY |
                            FILE_ATTRIBUTE_DEVICE ) ) == 0;
   }
#elif defined( HB_OS_OS2 )
   {
      FILESTATUS3 fs3;
      fExist = DosQueryPathInfo( pszFileName, FIL_STANDARD,
                                 &fs3, sizeof( fs3 ) ) == NO_ERROR &&
               ( fs3.attrFile & FILE_DIRECTORY ) == 0;
   }
#elif defined( HB_OS_UNIX )
   {
      struct stat statbuf;

      fExist = stat( pszFileName, &statbuf ) == 0 &&
               S_ISREG( statbuf.st_mode );
   }
#else
   {
      int TODO; /* To force warning */

      fExist = FALSE;
   }
#endif

   if( fFree )
      hb_xfree( ( void * ) pszFileName );

   return fExist;
}
hbfsapi.c294
HB_EXPORT BOOLhb_fsDirExists( const char * pszDirName )
HB_EXPORT BOOL hb_fsDirExists( const char * pszDirName )
{
   BOOL fExist;
   BOOL fFree;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsDirExists(%p)", pszDirName));

   if( pszDirName == NULL )
      return FALSE;

   pszDirName = ( char * ) hb_fsNameConv( ( BYTE * ) pszDirName, &fFree );

#if defined( HB_OS_DOS )
   {
#if defined( __DJGPP__ ) || defined(__BORLANDC__)
      int iAttr = _chmod( pszDirName, 0, 0 );
      fExist = iAttr != -1 && ( iAttr & 0x10 ) != 0;
#else
      unsigned int iAttr = 0;
      fExist = _dos_getfileattr( pszDirName, &iAttr ) == 0 &&
               ( iAttr & 0x10 ) != 0;
#endif
   }
#elif defined( HB_OS_WIN_32 )
   {
      DWORD   dwAttr;

      dwAttr = GetFileAttributesA( pszDirName );
      fExist = ( dwAttr != INVALID_FILE_ATTRIBUTES ) &&
               ( dwAttr & FILE_ATTRIBUTE_DIRECTORY );
   }
#elif defined( HB_OS_OS2 )
   {
      FILESTATUS3 fs3;
      fExist = DosQueryPathInfo( pszDirName, FIL_STANDARD,
                                 &fs3, sizeof( fs3 ) ) == NO_ERROR &&
               ( fs3.attrFile & FILE_DIRECTORY ) != 0;
   }
#elif defined( HB_OS_UNIX )
   {
      struct stat statbuf;

      fExist = stat( pszDirName, &statbuf ) == 0 &&
               S_ISDIR( statbuf.st_mode );
   }
#else
   {
      int TODO; /* To force warning */

      fExist = FALSE;
   }
#endif

   if( fFree )
      hb_xfree( ( void * ) pszDirName );

   return fExist;
}
hbfsapi.c354
HB_EXPORT BOOLhb_fsMaxFilesError( void )
HB_EXPORT BOOL hb_fsMaxFilesError( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_fsMaxFilesError()"));

#if defined( HB_WIN32_IO )
   return GetLastError() == ERROR_TOO_MANY_OPEN_FILES;
#else
   return errno == EMFILE;
#endif
}
hbfsapi.c413
hbgete.c
TypeFunctionSourceLine
CHAR *hb_getenv( const char * szName )
char * hb_getenv( const char * szName )
{
   char * pszBuffer = NULL;

#if defined(HB_OS_WIN_32)

   {
      DWORD size = GetEnvironmentVariableA( szName, NULL, 0 );

      if( size != 0 )
      {
         pszBuffer = ( char * ) hb_xgrab( size );
         GetEnvironmentVariableA( szName, pszBuffer, size );
      }
   }

#elif defined(HB_OS_OS2)

   {
   #ifdef __GNUC__
      PSZ EnvValue = "";
   #else
      PCSZ EnvValue = "";
   #endif

      if( DosScanEnv( szName, &EnvValue ) == NO_ERROR )
      {
         pszBuffer = hb_strdup( EnvValue );
      }
   }

#else

   {
      char * pszTemp = getenv( szName );

      if( pszTemp != NULL )
      {
         pszBuffer = hb_strdup( pszTemp );
      }
   }

#endif

   return pszBuffer;
}
hbgete.c68
hbhash.c
TypeFunctionSourceLine
STATIC HB_HASH_ITEM_PTRhb_hashItemNew( ULONG ulKey, void *pKey, void * pValue )
static HB_HASH_ITEM_PTR hb_hashItemNew( ULONG ulKey, void *pKey, void * pValue )
{
   HB_HASH_ITEM_PTR pItem = (HB_HASH_ITEM_PTR) hb_xgrab( sizeof( HB_HASH_ITEM ) );

   pItem->key = ulKey;
   pItem->KeyPtr = pKey;
   pItem->ValPtr = pValue;
   pItem->next = NULL;

   return pItem;
}
hbhash.c55
STATIC VOIDhb_hashItemDelete( HB_HASH_TABLE_PTR pTable, HB_HASH_ITEM_PTR pItem )
static void hb_hashItemDelete( HB_HASH_TABLE_PTR pTable, HB_HASH_ITEM_PTR pItem )
{
   if( pTable->pDeleteItemFunc )
      ( pTable->pDeleteItemFunc )( pTable, pItem->KeyPtr, pItem->ValPtr );
   hb_xfree( (void *) pItem );
}
hbhash.c67
HB_HASH_TABLE_PTRhb_hashTableCreate( ULONG ulSize, HB_HASH_FUNC_PTR pHashFunc, HB_HASH_FUNC_PTR pDelete, HB_HASH_FUNC_PTR pComp )
HB_HASH_TABLE_PTR hb_hashTableCreate( ULONG ulSize, 
                                   HB_HASH_FUNC_PTR pHashFunc, 
                                   HB_HASH_FUNC_PTR pDelete,
                                   HB_HASH_FUNC_PTR pComp )
{
   HB_HASH_TABLE_PTR pTable = ( HB_HASH_TABLE_PTR ) hb_xgrab( sizeof( HB_HASH_TABLE ) );

   pTable->ulTableSize = ulSize;
   pTable->pKeyFunc = pHashFunc;
   pTable->pDeleteItemFunc = pDelete;
   pTable->pCompFunc = pComp;
   pTable->ulCount = pTable->ulUsed = 0;

   pTable->pItems = ( HB_HASH_ITEM_PTR * ) hb_xgrab( sizeof( HB_HASH_ITEM_PTR ) * ulSize );
   memset( pTable->pItems, 0, sizeof( HB_HASH_ITEM_PTR ) * ulSize );

   return pTable;
}
hbhash.c74
VOIDhb_hashTableKill( HB_HASH_TABLE_PTR pTable )
void hb_hashTableKill( HB_HASH_TABLE_PTR pTable )
{
   ULONG ulSize = 0;
   
   while( ulSize < pTable->ulTableSize )
   {
      if( pTable->pItems[ ulSize ] )
      {
         HB_HASH_ITEM_PTR pItem, pFree;
         pItem = pTable->pItems[ ulSize ];
         while( pItem )
         {
            pFree = pItem;
            pItem = pItem->next;
            hb_hashItemDelete( pTable, pFree );
         }
      }
      ++ulSize;
   }
   hb_xfree( ( void * ) pTable->pItems );
   hb_xfree( ( void * ) pTable );
}
hbhash.c103
HB_HASH_TABLE_PTRhb_hashTableResize( HB_HASH_TABLE_PTR pTable, ULONG ulNewSize )
HB_HASH_TABLE_PTR hb_hashTableResize( HB_HASH_TABLE_PTR pTable, ULONG ulNewSize )
{
   HB_HASH_TABLE_PTR pNew;
   ULONG ulSize = 0;

   if( ulNewSize == 0 )
      ulNewSize = 2 * pTable->ulTableSize + 1; 
   pNew = hb_hashTableCreate( ulNewSize, 
                              pTable->pKeyFunc,
                              pTable->pDeleteItemFunc,
                              pTable->pCompFunc );

   while( ulSize < pTable->ulTableSize )
   {
      if( pTable->pItems[ ulSize ] )
      {
         HB_HASH_ITEM_PTR pItem;

         pItem = pTable->pItems[ ulSize ];
         while( pItem )
         {
            ULONG ulKey;
            HB_HASH_ITEM_PTR pNewItem, pNext;

            pNext = pItem->next;
            ulKey = ( pTable->pKeyFunc )( pNew, pItem->KeyPtr, pItem->ValPtr );
            pNewItem = pNew->pItems[ ulKey ];
            if( pNewItem )
            {
               while( pNewItem->next )
                  pNewItem = pNewItem->next;
               pNewItem->next = pItem;
            }
            else
            {
               pNew->pItems[ ulKey ] = pItem;
               ++pNew->ulUsed;
            }
            pItem->key = ulKey;
            pItem->next = NULL;
            ++pNew->ulCount;
            pItem = pNext;
         }
      }
      ++ulSize;
   }
   hb_xfree( ( void * ) pTable->pItems );
   hb_xfree( ( void * ) pTable );

   return pNew;
}
hbhash.c128
BOOLhb_hashTableAdd( HB_HASH_TABLE_PTR pTable, void *pKey, void *pValue )
BOOL hb_hashTableAdd( HB_HASH_TABLE_PTR pTable, void *pKey, void *pValue )
{
   ULONG ulKey;
   HB_HASH_ITEM_PTR pItem;

   ulKey = ( pTable->pKeyFunc )( pTable, pKey, pValue );
   pItem = pTable->pItems[ ulKey ];
   if( pItem )
   {
      while( pItem->next )
         pItem = pItem->next;
      pItem->next = hb_hashItemNew( ulKey, pKey, pValue );
   }
   else
   {
      pTable->pItems[ ulKey ] = hb_hashItemNew( ulKey, pKey, pValue );
      ++pTable->ulUsed;
   }
   ++pTable->ulCount;

   return TRUE;
}
hbhash.c181
VOID *hb_hashTableFind( HB_HASH_TABLE_PTR pTable, void *pKey )
void * hb_hashTableFind( HB_HASH_TABLE_PTR pTable, void *pKey )
{
   ULONG ulKey;
   HB_HASH_ITEM_PTR pItem;
   void * pFound = NULL;

   ulKey = ( pTable->pKeyFunc )( pTable, pKey, NULL );
   pItem = pTable->pItems[ ulKey ];
   if( pItem )
   {
      while( pItem && (( pTable->pCompFunc )( pTable, pItem->KeyPtr, pKey ) != 0) )
         pItem = pItem->next;

      if( pItem )
         pFound = pItem->ValPtr;
   }

   return pFound;
}
hbhash.c205
BOOLhb_hashTableDel( HB_HASH_TABLE_PTR pTable, void *pKey )
BOOL hb_hashTableDel( HB_HASH_TABLE_PTR pTable, void *pKey )
{
   ULONG ulKey;
   HB_HASH_ITEM_PTR pItem;
   HB_HASH_ITEM_PTR pPrev = NULL;
   BOOL bFound = FALSE;

   ulKey = ( pTable->pKeyFunc )( pTable, pKey, NULL );
   if( ulKey > pTable->ulTableSize )
      return FALSE;

   pItem = pTable->pItems[ ulKey ];
   while( pItem && !bFound )
   {
      if( ( pTable->pCompFunc )( pTable, pItem->KeyPtr, pKey ) == 0 )
      {
         if( pPrev )
         {
            pPrev->next = pItem->next;
         }
         else
         {
            pTable->pItems[ ulKey ] = pItem->next;
            if( !pItem->next )
            {
               --pTable->ulUsed;
               pTable->pItems[ ulKey ] = NULL;
            }
         }
         --pTable->ulCount;
         hb_hashItemDelete( pTable, pItem );
         bFound = TRUE;
      }
      else
      {
         pPrev = pItem;
         pItem = pItem->next;
      }
   }

   return bFound;
}
hbhash.c227
ULONGhb_hashTableSize( HB_HASH_TABLE_PTR pTable )
ULONG hb_hashTableSize( HB_HASH_TABLE_PTR pTable )
{
   return pTable->ulTableSize;
}
hbhash.c274
hbstr.c
TypeFunctionSourceLine
HB_EXPORT ULONGhb_strAt( const char * szSub, ULONG ulSubLen, const char * szText, ULONG ulLen )
HB_EXPORT ULONG hb_strAt( const char * szSub, ULONG ulSubLen, const char * szText, ULONG ulLen )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_strAt(%s, %lu, %s, %lu)", szSub, ulSubLen, szText, ulLen));

   if( ulSubLen > 0 && ulLen >= ulSubLen )
   {
      ULONG ulPos = 0;
      ULONG ulSubPos = 0;

      while( ulPos < ulLen && ulSubPos < ulSubLen )
      {
         if( szText[ ulPos ] == szSub[ ulSubPos ] )
         {
            ulSubPos++;
            ulPos++;
         }
         else if( ulSubPos )
         {
            /* Go back to the first character after the first match,
               or else tests like "22345" $ "012223456789" will fail. */
            ulPos -= ( ulSubPos - 1 );
            ulSubPos = 0;
         }
         else
            ulPos++;
      }

      return ( ulSubPos < ulSubLen ) ? 0 : ( ulPos - ulSubLen + 1 );
   }
   else
      return 0;
}
hbstr.c87
HB_EXPORT BOOLhb_strEmpty( const char * szText, ULONG ulLen )
HB_EXPORT BOOL hb_strEmpty( const char * szText, ULONG ulLen )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_strEmpty(%s, %lu)", szText, ulLen));

   while( ulLen-- )
   {
      char c = szText[ ulLen ];

      if( !HB_ISSPACE( c ) )
         return FALSE;
   }

   return TRUE;
}
hbstr.c120
HB_EXPORT CHAR *hb_strupr( char * pszText )
HB_EXPORT char * hb_strupr( char * pszText )
{
   char * pszPos;

   HB_TRACE(HB_TR_DEBUG, ("hb_strupr(%s)", pszText));

   for( pszPos = pszText; *pszPos; pszPos++ )
      *pszPos = ( char ) toupper( ( UCHAR ) *pszPos );

   return pszText;
}
hbstr.c135
HB_EXPORT CHAR *hb_strlow( char * pszText )
HB_EXPORT char * hb_strlow( char * pszText )
{
   char * pszPos;

   HB_TRACE(HB_TR_DEBUG, ("hb_strlow(%s)", pszText));

   for( pszPos = pszText; *pszPos; pszPos++ )
      *pszPos = ( char ) tolower( ( UCHAR ) *pszPos );

   return pszText;
}
hbstr.c147
HB_EXPORT CHAR *hb_strdup( const char * pszText )
HB_EXPORT char * hb_strdup( const char * pszText )
{
   char * pszDup;
   ULONG ulLen = strlen( pszText ) + 1;

   HB_TRACE(HB_TR_DEBUG, ("hb_strdup(%s, %ld)", pszText, ulLen));

   pszDup = ( char * ) hb_xgrab( ulLen );
   memcpy( pszDup, pszText, ulLen );

   return pszDup;
}
hbstr.c159
HB_EXPORT CHAR *hb_strndup( const char * pszText, ULONG ulLen )
HB_EXPORT char * hb_strndup( const char * pszText, ULONG ulLen )
{
   char * pszDup;
   ULONG ul;

   HB_TRACE(HB_TR_DEBUG, ("hb_strndup(%s, %ld)", pszText, ulLen));

   ul = 0;
   pszDup = ( char * ) pszText;
   while( ulLen-- && *pszDup++ )
   {
      ++ul;
   }

   pszDup = ( char * ) hb_xgrab( ul + 1 );
   memcpy( pszDup, pszText, ul );
   pszDup[ ul ] = '\0';

   return pszDup;
}
hbstr.c172
HB_EXPORT ULONGhb_strnlen( const char * pszText, ULONG ulLen )
HB_EXPORT ULONG hb_strnlen( const char * pszText, ULONG ulLen )
{
   ULONG ul = 0;

   HB_TRACE(HB_TR_DEBUG, ("hb_strnlen(%s, %ld)", pszText, ulLen));

   while( ulLen-- && *pszText++ )
   {
      ++ul;
   }
   return ul;
}
hbstr.c193
HB_EXPORT CHAR *hb_strduptrim( const char * pszText )
HB_EXPORT char * hb_strduptrim( const char * pszText )
{
   char * pszDup;
   ULONG ulLen;

   HB_TRACE(HB_TR_DEBUG, ("hb_strduptrim(%s)", pszText));

   while( pszText[ 0 ] == ' ' )
   {
      ++pszText;
   }
   ulLen = strlen( pszText );
   while( ulLen && pszText[ ulLen - 1 ] == ' ' )
   {
      --ulLen;
   }

   pszDup = ( char * ) hb_xgrab( ulLen + 1 );
   memcpy( pszDup, pszText, ulLen );
   pszDup[ ulLen ] = '\0';

   return pszDup;
}
hbstr.c206
HB_EXPORT ULONGhb_strlentrim( const char * pszText )
HB_EXPORT ULONG hb_strlentrim( const char * pszText )
{
   ULONG ul = 0;

   HB_TRACE(HB_TR_DEBUG, ("hb_strlentrim(%s)", pszText));

   while( pszText[ 0 ] == ' ' )
   {
      ++pszText;
   }
   while( pszText[ ul] )
   {
      ++ul;
   }
   while( ul && pszText[ ul - 1 ] == ' ' )
   {
      --ul;
   }
   return ul;
}
hbstr.c230
HB_EXPORT INThb_stricmp( const char * s1, const char * s2 )
HB_EXPORT int hb_stricmp( const char * s1, const char * s2 )
{
   int rc = 0, c1, c2;

   HB_TRACE(HB_TR_DEBUG, ("hb_stricmp(%s, %s)", s1, s2));

   do
   {
      c1 = toupper( ( unsigned char ) *s1 );
      c2 = toupper( ( unsigned char ) *s2 );

      if( c1 != c2 )
      {
         rc = ( c1 < c2 ? -1 : 1 );
         break;
      }

      s1++;
      s2++;
   }
   while( c1 );

   return rc;
}
hbstr.c251
HB_EXPORT INThb_strnicmp( const char * s1, const char * s2, ULONG count )
HB_EXPORT int hb_strnicmp( const char * s1, const char * s2, ULONG count )
{
   ULONG ulCount;
   int rc = 0;

   HB_TRACE(HB_TR_DEBUG, ("hb_strnicmp(%s, %s, %lu)", s1, s2, count));

   for( ulCount = 0; ulCount < count; ulCount++ )
   {
      unsigned char c1 = ( char ) toupper( ( unsigned char ) s1[ ulCount ] );
      unsigned char c2 = ( char ) toupper( ( unsigned char ) s2[ ulCount ] );

      if( c1 != c2 )
      {
         rc = ( c1 < c2 ? -1 : 1 );
         break;
      }
      else if( !c1 )
         break;
   }

   return rc;
}
hbstr.c276
HB_EXPORT CHAR *hb_xstrcat( char * szDest, const char * szSrc, ... )
HB_EXPORT char * hb_xstrcat( char * szDest, const char * szSrc, ... )
{
   char * szResult = szDest;
   va_list va;

   HB_TRACE(HB_TR_DEBUG, ("hb_xstrcat(%p, %p, ...)", szDest, szSrc));

   while( *szDest )
      szDest++;

   va_start( va, szSrc );
   while( szSrc )
   {
      while( *szSrc )
         *szDest++ = *szSrc++;
      szSrc = va_arg( va, char * );
   }
   *szDest = '\0';
   va_end( va );

   return szResult;
}
hbstr.c301
HB_EXPORT CHAR *hb_xstrcpy( char * szDest, const char * szSrc, ... )
HB_EXPORT char * hb_xstrcpy( char * szDest, const char * szSrc, ... )
{
   char * szResult;
   va_list va;

   HB_TRACE(HB_TR_DEBUG, ("hb_xstrcpy(%p, %p, ...)", szDest, szSrc));

   if( szDest == NULL )
   {
      const char * szSrcPtr = szSrc;
      ULONG ulSize = 1;
      va_start( va, szSrc );
      while( szSrcPtr )
      {
         ulSize += strlen( szSrcPtr );
         szSrcPtr = va_arg( va, char * );
      }
      va_end( va );
      szDest = ( char * ) hb_xgrab( ulSize );
   }
   szResult = szDest;

   va_start( va, szSrc );
   while( szSrc )
   {
      while( *szSrc )
         *szDest++ = *szSrc++;
      szSrc = va_arg( va, char * );
   }
   *szDest = '\0';
   va_end( va );

   return szResult;
}
hbstr.c329
STATIC DOUBLEhb_numPow10( int nPrecision )
static double hb_numPow10( int nPrecision )
{
   static const double s_dPow10[16] = {                1.0,   /*  0 */
                                                      10.0,   /*  1 */
                                                     100.0,   /*  2 */
                                                    1000.0,   /*  3 */
                                                   10000.0,   /*  4 */
                                                  100000.0,   /*  5 */
                                                 1000000.0,   /*  6 */
                                                10000000.0,   /*  7 */
                                               100000000.0,   /*  8 */
                                              1000000000.0,   /*  9 */
                                             10000000000.0,   /* 10 */
                                            100000000000.0,   /* 11 */
                                           1000000000000.0,   /* 12 */
                                          10000000000000.0,   /* 13 */
                                         100000000000000.0,   /* 14 */
                                        1000000000000000.0 }; /* 15 */
   if( nPrecision < 16 )
   {
      if( nPrecision >= 0 )
      {
         return s_dPow10[ nPrecision ];
      }
      else if( nPrecision > -16 )
      {
         return 1.0 / s_dPow10[ ( unsigned int ) -nPrecision ];
      }
   }

   return pow( 10.0, ( double ) nPrecision );
}
hbstr.c374
HB_EXPORT DOUBLEhb_numRound( double dNum, int iDec )
HB_EXPORT double hb_numRound( double dNum, int iDec )
{
   static const double doBase = 10.0f;
   double doComplete5, doComplete5i, dPow;

   HB_TRACE(HB_TR_DEBUG, ("hb_numRound(%lf, %d)", dNum, iDec));

   if( dNum == 0.0 )
      return 0.0;

   if( iDec < 0 )
   {
      dPow = hb_numPow10( -iDec );
      doComplete5 = dNum / dPow * doBase;
   }
   else
   {
      dPow = hb_numPow10( iDec );
      doComplete5 = dNum * dPow * doBase;
   }

/*
 * double precision if 15 digit the 16th one is usually wrong but
 * can give some information about number,
 * Clipper display 16 digit only others are set to 0
 * many people don't know/understand FL arithmetic. They expect
 * that it will behaves in the same way as real numbers. It's not
 * true but in business application we can try to hide this problem
 * for them. Usually they not need such big precision in presented
 * numbers so we can decrease the precision to 15 digits and use
 * the cut part for proper rounding. It should resolve
 * most of problems. But if someone totally  not understand FL
 * and will try to convert big matrix or sth like that it's quite
 * possible that he chose one of the natural school algorithm which
 * works nice with real numbers but can give very bad results in FL.
 * In such case it could be good to decrease precision even more.
 * It not fixes the used algorithm of course but will make many users
 * happy because they can see nice (proper) result.
 * So maybe it will be good to add SET PRECISION TO  for them and
 * use the similar hack in ==, >=, <=, <, > operations if it's set.
 */

/* #define HB_NUM_PRECISION  16 */

#ifdef HB_NUM_PRECISION
   /*
    * this is a hack for people who cannot live without hacked FL values
    * in rounding
    */
   {
      int iDecR, iPrec;
      BOOL fNeg;

      if( dNum < 0 )
      {
         fNeg = TRUE;
         dNum = -dNum;
      }
      else
      {
         fNeg = FALSE;
      }
      iDecR = (int) log10( dNum );
      iPrec = iDecR + iDec;

      if( iPrec < -1 )
      {
         return 0.0;
      }
      else
      {
         if( iPrec > HB_NUM_PRECISION )
         {
            iDec = HB_NUM_PRECISION - ( dNum < 1.0 ? 0 : 1 ) - iDecR;
            iPrec = -1;
         }
         else
         {
            iPrec -= HB_NUM_PRECISION;
         }
      }
      if( iDec < 0 )
      {
         dPow = hb_numPow10( -iDec );
         doComplete5 = dNum / dPow * doBase + 5.0 + hb_numPow10( iPrec );
      }
      else
      {
         dPow = hb_numPow10( iDec );
         doComplete5 = dNum * dPow * doBase + 5.0 + hb_numPow10( iPrec );
      }

      if( fNeg )
      {
         doComplete5 = -doComplete5;
      }
   }
#else
   if( dNum < 0.0f )
      doComplete5 -= 5.0f;
   else
      doComplete5 += 5.0f;
#endif

   doComplete5 /= doBase;

#if defined( HB_DBLFL_PREC_FACTOR ) && !defined( HB_C52_STRICT )
   /* similar operation is done by Cl5.3
      it's a hack to force rounding FL values UP */
   doComplete5 *= HB_DBLFL_PREC_FACTOR;
#endif

   modf( doComplete5, &doComplete5i );

#if defined( __XCC__ ) || defined( __POCC__ )
   if( iDec < 16 )
   {
      if( iDec >= 0 )
         return doComplete5i / (LONGLONG) dPow;
      else if( iDec > -16 )
         return doComplete5i * (LONGLONG) dPow;
   }
#endif
   if( iDec < 0 )
      return doComplete5i * dPow;
   else
      return doComplete5i / dPow;
}
hbstr.c407
HB_EXPORT DOUBLEhb_numInt( double dNum )
HB_EXPORT double hb_numInt( double dNum )
{
   double dInt;

#if defined( HB_DBLFL_PREC_FACTOR ) && !defined( HB_C52_STRICT )
   /* Similar hack as in round to make this functions compatible */
   dNum *= HB_DBLFL_PREC_FACTOR;
#endif
   modf( dNum, &dInt );

   return dInt;
}
hbstr.c536
HB_EXPORT DOUBLEhb_numDecConv( double dNum, int iDec )
HB_EXPORT double hb_numDecConv( double dNum, int iDec )
{
   if( iDec > 0 )
      return hb_numRound( dNum / hb_numPow10( iDec ), iDec );

   else if( iDec < 0 )
      return hb_numRound( dNum * hb_numPow10( -iDec ), 0 );

   else
      return hb_numRound( dNum, 0 );
}
hbstr.c549
STATIC BOOLhb_str2number( BOOL fPCode, const char* szNum, ULONG ulLen, HB_LONG * lVal, double * dVal, int * piDec, int * piWidth )
static BOOL hb_str2number( BOOL fPCode, const char* szNum, ULONG ulLen, HB_LONG * lVal, double * dVal, int * piDec, int * piWidth )
{
   BOOL fDbl = FALSE, fDec = FALSE, fNeg, fHex = FALSE;
   ULONG ulPos = 0;
   int c, iWidth, iDec = 0, iDecR = 0;

   HB_TRACE(HB_TR_DEBUG, ("hb_str2number(%d, %p, %lu, %p, %p, %p, %p)", (int) fPCode, szNum, ulLen, lVal, dVal, piDec, piWidth ));

   while( ulPos < ulLen && HB_ISSPACE( szNum[ulPos] ) )
      ulPos++;

   if( ulPos >= ulLen )
   {
      fNeg = FALSE;
   }
   else if( szNum[ulPos] == '-' )
   {
      fNeg = TRUE;
      ulPos++;
   }
   else
   {
      fNeg = FALSE;
      if( szNum[ulPos] == '+' )
         ulPos++;
   }

   *lVal = 0;

   /* Hex Number */
   if( fPCode && ulPos + 1 < ulLen && szNum[ulPos] == '0' &&
       ( szNum[ulPos+1] == 'X' || szNum[ulPos+1] == 'x' ) )
   {
      ulPos += 2;
      iWidth = HB_DEFAULT_WIDTH;
      fHex = TRUE;
      for( ; ulPos < ulLen; ulPos++ )
      {
         c = szNum[ulPos];
         if( c >= '0' && c <= '9' )
            c -= '0';
         else if( c >= 'A' && c <= 'F' )
            c -= 'A' - 10;
         else if( c >= 'a' && c <= 'f' )
            c -= 'a' - 10;
         else
            break;
         *lVal = ( *lVal << 4 ) + c;
      }
   }
   else
   {
      HB_LONG lLimV;
      int iLimC;

      lLimV = HB_LONG_MAX / 10;
      iLimC = ( int ) ( HB_LONG_MAX % 10 );

      iWidth = ulPos;

      for( ; ulPos < ulLen; ulPos++ )
      {
         c = szNum[ulPos];
         if( c >= '0' && c <= '9' )
         {
            if( fDbl )
            {
               *dVal = *dVal * 10.0 + ( c - '0' );
            }
            else if( *lVal < lLimV || ( *lVal <= lLimV && ( ( int ) ( c - '0' ) ) <= iLimC ) )
            {
               *lVal = *lVal * 10 + ( c - '0' );
            }
            else
            {
               *dVal = (double) *lVal * 10.0 + ( c - '0' );
               fDbl = TRUE;
            }
            if( fDec )
               iDec++;
            else
               iWidth++;
         }
         else if( c == '.' && !fDec )
         {
            fDec = TRUE;
         }
         else
         {
            while( !fDec && ulPos < ulLen )
            {
               if( szNum[ulPos++] == '.' )
                  fDec = TRUE;
               else
                  iWidth++;
            }
            if( fDec )
               iDecR = ulLen - ulPos;
            break;
         }
      }
   }

   if( fNeg )
   {
      if( fDbl )
         *dVal = -*dVal;
      else
         *lVal = -*lVal;
   }
   if( !fDbl && (
#if defined( PCODE_LONG_LIM )
        ( fPCode && !fHex && !PCODE_LONG_LIM( *lVal ) ) ||
#endif
        fDec ) )
   {
      *dVal = (double) *lVal;
      fDbl = TRUE;
   }
   if( iDec )
   {
#if defined( __XCC__ ) || defined( __POCC__ )
      if( iDec < 16 )
         *dVal /= ( LONGLONG ) hb_numPow10( iDec );
      else
#endif
         *dVal /= hb_numPow10( iDec );
   }

   if( piDec )
      *piDec = iDec + iDecR;
   if( piWidth )
   {
      if( fHex )
         *piWidth = iWidth;
      else
      {
         if( fPCode )
         {
            if( iWidth < 10 || fNeg )
               *piWidth = fDbl ? HB_DBL_LENGTH( *dVal ) : HB_LONG_LENGTH( *lVal );
            else
               *piWidth = iWidth + ( iDec == 0 ? 1 : 0 );
         }
         else if( iWidth > 10 )
         {
            *piWidth = fDbl ? HB_DBL_LENGTH( *dVal ) : HB_LONG_LENGTH( *lVal );
         }
         else
         {
            if( iDec + iDecR == 0 )
               *piWidth = ( int ) ulLen;
            else if( iWidth == 0 )
               *piWidth = 1;
            else if( fNeg && iWidth == 1 && *dVal != 0 )
               *piWidth = 2;
            else
               *piWidth = iWidth;
         }
      }
   }

   return fDbl;
}
hbstr.c561
HB_EXPORT BOOLhb_compStrToNum( const char* szNum, ULONG ulLen, HB_LONG * plVal, double * pdVal, int * piDec, int * piWidth )
HB_EXPORT BOOL hb_compStrToNum( const char* szNum, ULONG ulLen, HB_LONG * plVal, double * pdVal, int * piDec, int * piWidth )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_compStrToNum( %s, %lu, %p, %p, %p, %p)", szNum, ulLen, plVal, pdVal, piDec, piWidth ));
   return hb_str2number( TRUE, szNum, ulLen, plVal, pdVal, piDec, piWidth );
}
hbstr.c726
HB_EXPORT BOOLhb_valStrnToNum( const char* szNum, ULONG ulLen, HB_LONG * plVal, double * pdVal, int * piDec, int * piWidth )
HB_EXPORT BOOL hb_valStrnToNum( const char* szNum, ULONG ulLen, HB_LONG * plVal, double * pdVal, int * piDec, int * piWidth )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_valStrToNum( %s, %lu, %p, %p, %p, %p)", szNum, ulLen, plVal, pdVal, piDec, piWidth ));
   return hb_str2number( FALSE, szNum, ulLen, plVal, pdVal, piDec, piWidth );
}
hbstr.c732
HB_EXPORT BOOLhb_strToNum( const char* szNum, HB_LONG * plVal, double * pdVal )
HB_EXPORT BOOL hb_strToNum( const char* szNum, HB_LONG * plVal, double * pdVal )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_strToNum(%s, %p, %p)", szNum, plVal, pdVal ));
   return hb_str2number( FALSE, szNum, strlen( szNum ), plVal, pdVal, NULL, NULL );
}
hbstr.c738
HB_EXPORT BOOLhb_strnToNum( const char* szNum, ULONG ulLen, HB_LONG * plVal, double * pdVal )
HB_EXPORT BOOL hb_strnToNum( const char* szNum, ULONG ulLen, HB_LONG * plVal, double * pdVal )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_strToNum(%s, %lu, %p, %p)", szNum, ulLen, plVal, pdVal ));
   return hb_str2number( FALSE, szNum, ulLen, plVal, pdVal, NULL, NULL );
}
hbstr.c744
HB_EXPORT DOUBLEhb_strVal( const char * szText, ULONG ulLen )
HB_EXPORT double hb_strVal( const char * szText, ULONG ulLen )
{
   HB_LONG lVal;
   double dVal;

   HB_TRACE(HB_TR_DEBUG, ("hb_strVal(%s, %lu)", szText, ulLen));

   if( ! hb_str2number( FALSE, szText, ulLen, &lVal, &dVal, NULL, NULL ) )
      dVal = ( double ) lVal;
   return dVal;
}
hbstr.c750
HB_EXPORT HB_LONGhb_strValInt( const char * szText, int * iOverflow )
HB_EXPORT HB_LONG hb_strValInt( const char * szText, int * iOverflow )
{
   HB_LONG lVal;
   double dVal;

   HB_TRACE(HB_TR_DEBUG, ("hb_strValInt(%s)", szText));

   if( hb_str2number( TRUE, szText, strlen( szText ), &lVal, &dVal, NULL, NULL ) )
   {
      *iOverflow = 1;
      return 0;
   }
   *iOverflow = 0;
   return lVal;
}
hbstr.c763
HB_EXPORT CHAR *hb_strncpy( char * pDest, const char * pSource, ULONG ulLen )
HB_EXPORT char * hb_strncpy( char * pDest, const char * pSource, ULONG ulLen )
{
   char *pBuf = pDest;

   HB_TRACE(HB_TR_DEBUG, ("hb_strncpy(%p, %s, %lu)", pDest, pSource, ulLen));

   pDest[ ulLen ] ='\0';

   while( ulLen && ( *pDest++ = *pSource++ ) != '\0' )
   {
      ulLen--;
   }

   while(ulLen--)
   {
      *pDest++ = '\0';
   }

   return pBuf;
}
hbstr.c779
HB_EXPORT CHAR *hb_strncat( char * pDest, const char * pSource, ULONG ulLen )
HB_EXPORT char * hb_strncat( char * pDest, const char * pSource, ULONG ulLen )
{
   char *pBuf = pDest;

   HB_TRACE(HB_TR_DEBUG, ("hb_strncpy(%p, %s, %lu)", pDest, pSource, ulLen));

   pDest[ ulLen ] ='\0';

   while( ulLen && *pDest )
   {
      pDest++;
      ulLen--;
   }

   while( ulLen && ( *pDest++ = *pSource++ ) != '\0' )
   {
      ulLen--;
   }

/* if someone will need this then please uncomment the cleaning the rest of
   buffer. */
/*
   while(ulLen--)
   {
      *pDest++ = '\0';
   }
*/
   return pBuf;
}
hbstr.c805
HB_EXPORT CHAR *hb_strncpyLower( char * pDest, const char * pSource, ULONG ulLen )
HB_EXPORT char * hb_strncpyLower( char * pDest, const char * pSource, ULONG ulLen )
{
   char *pBuf = pDest;

   HB_TRACE(HB_TR_DEBUG, ("hb_strncpyLower(%p, %s, %lu)", pDest, pSource, ulLen));

   pDest[ ulLen ] ='\0';

   /* some compilers implement tolower as a macro, and this has side effects! */
   /* *pDest++ = tolower( *pSource++ ); */
   while( ulLen && ( *pDest++ = ( char ) tolower( ( UCHAR ) *pSource ) ) != '\0' )
   {
      ulLen--;
      pSource++;
   }

   while( ulLen-- )
   {
      *pDest++ = '\0';
   }

   return pBuf;
}
hbstr.c840
HB_EXPORT CHAR *hb_strncpyUpper( char * pDest, const char * pSource, ULONG ulLen )
HB_EXPORT char * hb_strncpyUpper( char * pDest, const char * pSource, ULONG ulLen )
{
   char *pBuf = pDest;

   HB_TRACE(HB_TR_DEBUG, ("hb_strncpyUpper(%p, %s, %lu)", pDest, pSource, ulLen));

   pDest[ ulLen ] ='\0';

   /* some compilers implement toupper as a macro, and this has side effects! */
   /* *pDest++ = toupper( *pSource++ ); */
   while( ulLen && ( *pDest++ = ( char ) toupper( ( UCHAR ) *pSource ) ) != '\0' )
   {
      ulLen--;
      pSource++;
   }

   while( ulLen-- )
   {
      *pDest++ = '\0';
   }

   return pBuf;
}
hbstr.c871
HB_EXPORT CHAR *hb_strncpyUpperTrim( char * pDest, const char * pSource, ULONG ulLen )
HB_EXPORT char * hb_strncpyUpperTrim( char * pDest, const char * pSource, ULONG ulLen )
{
   char *pBuf = pDest;
   ULONG ulSLen;

   HB_TRACE(HB_TR_DEBUG, ("hb_strncpyUpperTrim(%p, %s, %lu)", pDest, pSource, ulLen));

   ulSLen = 0;
   while( ulSLen < ulLen && pSource[ ulSLen ] )
   {
      ulSLen++;
   }
   while( ulSLen && pSource[ ulSLen - 1 ] == ' ')
   {
      ulSLen--;
   }

   pDest[ ulLen ] = '\0';

   /* some compilers impliment toupper as a macro, and this has side effects! */
   /* *pDest++ = toupper( *pSource++ ); */
   while( ulLen && ulSLen &&
          ( *pDest++ = ( char ) toupper( ( UCHAR ) *pSource ) ) != '\0' )
   {
      ulSLen--;
      ulLen--;
      pSource++;
   }

   while( ulLen-- )
   {
      *pDest++ = '\0';
   }

   return pBuf;
}
hbstr.c902
HB_EXPORT CHAR *hb_strncpyTrim( char * pDest, const char * pSource, ULONG ulLen )
HB_EXPORT char * hb_strncpyTrim( char * pDest, const char * pSource, ULONG ulLen )
{
   char *pBuf = pDest;
   ULONG ulSLen;

   HB_TRACE(HB_TR_DEBUG, ("hb_strncpyTrim(%p, %s, %lu)", pDest, pSource, ulLen));

   ulSLen = 0;
   while( ulSLen < ulLen && pSource[ ulSLen ] )
   {
      ulSLen++;
   }
   while( ulSLen && pSource[ ulSLen - 1 ] == ' ' )
   {
      ulSLen--;
   }

   pDest[ ulLen ] ='\0';

   /* some compilers impliment toupper as a macro, and this has side effects! */
   /* *pDest++ = toupper( *pSource++ ); */
   while( ulLen && ulSLen && ( *pDest++ = *pSource++ ) != '\0' )
   {
      ulSLen--;
      ulLen--;
   }

   while( ulLen-- )
   {
      *pDest++ = '\0';
   }

   return pBuf;
}
hbstr.c946
HB_EXPORT CHAR *hb_strRemEscSeq( char *str, ULONG *pLen )
HB_EXPORT char * hb_strRemEscSeq( char *str, ULONG *pLen )
{
   ULONG ul = *pLen, ulStripped = 0;
   char *ptr, *dst, ch;

   ptr = dst = str;
   while( ul )
   {
      if( *ptr == '\\' )
         break;
      ++ptr; ++dst;
      --ul;
   }

   while( ul-- )
   {
      ch = *ptr++;
      if( ch == '\\' )
      {
         ++ulStripped;
         if( ul )
         {
            ul--;
            ch = *ptr++;
            switch( ch )
            {
               case 'r':
                  ch = '\r';
                  break;
               case 'n':
                  ch = '\n';
                  break;
               case 't':
                  ch = '\t';
                  break;
               case 'b':
                  ch = '\b';
                  break;
               case '0':
               case '1':
               case '2':
               case '3':
               case '4':
               case '5':
               case '6':
               case '7':
                  ch -= '0';
                  if( ul && *ptr >= '0' && *ptr <= '7' )
                  {
                     ch = ( ch << 3 ) | ( *ptr++ - '0' );
                     ++ulStripped;
                     if( --ul && *ptr >= '0' && *ptr <= '7' )
                     {
                        ch = ( ch << 3 ) | ( *ptr++ - '0' );
                        ++ulStripped;
                        --ul;
                     }
                  }
                  break;
               case 'x':
                  ch = 0;
                  while( ul )
                  {
                     if( *ptr >= '0' && *ptr <= '9' )
                        ch = ( ch << 4 ) | ( *ptr++ - '0' );
                     else if( *ptr >= 'A' && *ptr <= 'F' )
                        ch = ( ch << 4 ) | ( *ptr++ - 'A' + 10 );
                     else if( *ptr >= 'a' && *ptr <= 'f' )
                        ch = ( ch << 4 ) | ( *ptr++ - 'a' + 10 );
                     else
                        break;
                     ++ulStripped;
                     --ul;
                  }
                  break;
               case '\\':
               default:
                  break;
            }
         }
         else
            break;
            
      }
      *dst++ = ch;
   }

   if( ulStripped )
   {
      *dst = '\0';
      *pLen -= ulStripped;
   }

   return str;
}
hbstr.c986
CHAR *hb_compEncodeString( int iMethod, const char * szText, ULONG * pulLen )
char * hb_compEncodeString( int iMethod, const char * szText, ULONG * pulLen )
{
   char * pBuffer = ( char * ) hb_xgrab( *pulLen + 1 );

   memcpy( pBuffer, szText, *pulLen );
   pBuffer[ *pulLen ] = '\0';
   if( iMethod == 1 )
   {
      ULONG ul;
      for( ul = 0; ul < *pulLen; ul++ )
         pBuffer[ ul ] ^= 0xF3;
   }
   return pBuffer;
}
hbstr.c1082
CHAR *hb_compDecodeString( int iMethod, const char * szText, ULONG * pulLen )
char * hb_compDecodeString( int iMethod, const char * szText, ULONG * pulLen )
{
   char * pBuffer = ( char * ) hb_xgrab( *pulLen + 1 );

   memcpy( pBuffer, szText, *pulLen );
   pBuffer[ *pulLen ] = '\0';
   if( iMethod == 1 )
   {
      ULONG ul;
      for( ul = 0; ul < *pulLen; ul++ )
         pBuffer[ ul ] ^= 0xF3;
   }
   return pBuffer;
}
hbstr.c1097
hbtrace.c
TypeFunctionSourceLine
INThb_tracestate( int new_state )
int hb_tracestate( int new_state )
{
   int old_state = s_enabled;

   if( new_state == 0 ||
       new_state == 1 )
      s_enabled = new_state;

   return old_state;
}
hbtrace.c82
INThb_tracelevel( int new_level )
int hb_tracelevel( int new_level )
{
   int old_level = hb_tr_level_;

   if( new_level >= HB_TR_ALWAYS &&
       new_level <  HB_TR_LAST )
      hb_tr_level_ = new_level;

   return old_level;
}
hbtrace.c93
INThb_tr_level( void )
int hb_tr_level( void )
{
   static int s_level = -1;

   if( s_level == -1 )
   {
      char * env;

      s_level = HB_TR_DEFAULT;

      /* ; */

      env = hb_getenv( "HB_TR_OUTPUT" );
      if( env != NULL && env[ 0 ] != '\0' )
      {
         s_fp = hb_fopen( env, "w" );

         if( s_fp == NULL )
            s_fp = stderr;
      }
      else
         s_fp = stderr;

      if( env )
         hb_xfree( ( void * ) env );

      /* ; */

      env = hb_getenv( "HB_TR_LEVEL" );
      if( env != NULL && env[ 0 ] != '\0' )
      {
         int i;

         for( i = 0; i < HB_TR_LAST; ++i )
         {
            /* 17/04/2000 - maurilio.longo@libero.it
               SET HB_TR_LEVEL=hb_tr_debug is valid under OS/2 and environment variable value returned is lower case */
            if( hb_stricmp( env, s_slevel[ i ] ) == 0 )
            {
               s_level = i;
               break;
            }
         }
      }

      if( env )
         hb_xfree( ( void * ) env );

      /* ; */

      env = hb_getenv( "HB_TR_FLUSH" );
      if( env != NULL && env[ 0 ] != '\0' )
         s_flush = 1;
      else
         s_flush = 0;

      if( env )
         hb_xfree( ( void * ) env );
   }

   return s_level;
}
hbtrace.c104
VOIDhb_tr_trace( const char * fmt, ... )
void hb_tr_trace( const char * fmt, ... )
{
   /*
    * If tracing is disabled, do nothing.
    */
   if( s_enabled )
   {
      int i;
      va_list ap;

      /*
       * Clean up the file, so that instead of showing
       *
       *   ../../../foo/bar/baz.c
       *
       * we just show
       *
       *   foo/bar/baz.c
       */
      for( i = 0; hb_tr_file_[ i ] != '\0'; ++i )
      {
         if( hb_tr_file_[ i ] != '.' &&
             hb_tr_file_[ i ] != '/' &&
             hb_tr_file_[ i ] != '\\' )
            break;
      }

      /*
       * Print file and line.
       */
      fprintf( s_fp, "%s:%d: %s ",
               hb_tr_file_ + i, hb_tr_line_, s_slevel[ hb_tr_level_ ] );

      /*
       * Print the name and arguments for the function.
       */
      va_start( ap, fmt );
      vfprintf( s_fp, fmt, ap );
      va_end( ap );

      /*
       * Print a new-line.
       */
      fprintf( s_fp, "\n" );

      /*
       * Reset file and line.
       */
      hb_tr_level_ = -1;
      /* NOTE: resetting file name/line number will cause that we will unable
       * to report the location of code that allocated unreleased memory blocks
       * See hb_xalloc/hb_xgrab in source/rtl/fm.c
       */
      if( hb_tr_level() < HB_TR_DEBUG )
      {
         hb_tr_file_ = "";
         hb_tr_line_ = -1;
      }

      if( s_flush )
      {
         fflush( s_fp );
      }
   }
}
hbtrace.c167
hbver.c
TypeFunctionSourceLine
CHAR *hb_verPlatform( void )
char * hb_verPlatform( void )
{
   char * pszPlatform;

   HB_TRACE(HB_TR_DEBUG, ("hb_verPlatform()"));

   pszPlatform = ( char * ) hb_xgrab( PLATFORM_BUF_SIZE + 1 );

#if defined(HB_OS_DOS)

   {
      union REGS regs;

      regs.h.ah = 0x30;
      HB_DOS_INT86( 0x21, ®s, ®s );

      snprintf( pszPlatform, PLATFORM_BUF_SIZE + 1, "DOS %d.%02d", regs.h.al, regs.h.ah );

      /* Host OS detection: Windows 2.x, 3.x, 95/98 */

      {
         regs.HB_XREGS.ax = 0x1600;
         HB_DOS_INT86( 0x2F, ®s, ®s );

         if( regs.h.al != 0x00 && regs.h.al != 0x80 )
         {
            char szHost[ 128 ];

            if( regs.h.al == 0x01 || regs.h.al == 0xFF )
               snprintf( szHost, sizeof( szHost ), " (Windows 2.x)" );
            else
               snprintf( szHost, sizeof( szHost ), " (Windows %d.%02d)", regs.h.al, regs.h.ah );

            hb_strncat( pszPlatform, szHost, PLATFORM_BUF_SIZE );
         }
      }

      /* Host OS detection: Windows NT/2000 */

      {
         regs.HB_XREGS.ax = 0x3306;
         HB_DOS_INT86( 0x21, ®s, ®s );

         if( regs.HB_XREGS.bx == 0x3205 )
            hb_strncat( pszPlatform, " (Windows NT/2000)", PLATFORM_BUF_SIZE );
      }

      /* Host OS detection: OS/2 */

      {
         regs.h.ah = 0x30;
         HB_DOS_INT86( 0x21, ®s, ®s );

         if( regs.h.al >= 10 )
         {
            char szHost[ 128 ];

            if( regs.h.al == 20 && regs.h.ah > 20 )
               snprintf( szHost, sizeof( szHost ), " (OS/2 %d.%02d)", regs.h.ah / 10, regs.h.ah % 10 );
            else
               snprintf( szHost, sizeof( szHost ), " (OS/2 %d.%02d)", regs.h.al / 10, regs.h.ah );

            hb_strncat( pszPlatform, szHost, PLATFORM_BUF_SIZE );
         }
      }
   }

#elif defined(HB_OS_OS2)

   {
      unsigned long aulQSV[ QSV_MAX ] = { 0 };
      APIRET rc;

      rc = DosQuerySysInfo( 1L, QSV_MAX, ( void * ) aulQSV, sizeof( ULONG ) * QSV_MAX );

      if( rc == 0 )
      {
         /* is this OS/2 2.x ? */
         if( aulQSV[ QSV_VERSION_MINOR - 1 ] < 30 )
         {
            snprintf( pszPlatform, PLATFORM_BUF_SIZE + 1, "OS/2 %ld.%02ld",
                      aulQSV[ QSV_VERSION_MAJOR - 1 ] / 10,
                      aulQSV[ QSV_VERSION_MINOR - 1 ] );
         }
         else
            snprintf( pszPlatform, PLATFORM_BUF_SIZE + 1, "OS/2 %2.2f",
                      ( float ) aulQSV[ QSV_VERSION_MINOR - 1 ] / 10 );
      }
      else
         snprintf( pszPlatform, PLATFORM_BUF_SIZE + 1, "OS/2" );
   }

#elif defined(HB_OS_WIN_32)

   {
      OSVERSIONINFOA osVer;

      osVer.dwOSVersionInfoSize = sizeof( osVer );

      if( GetVersionExA( &osVer ) )
      {
         char * pszName = "Windows";

         switch( osVer.dwPlatformId )
         {
            case VER_PLATFORM_WIN32_WINDOWS:

               if( osVer.dwMajorVersion == 4 && osVer.dwMinorVersion < 10 )
                  pszName = "Windows 95";
               else if( osVer.dwMajorVersion == 4 && osVer.dwMinorVersion == 10 )
                  pszName = "Windows 98";
               else
                  pszName = "Windows ME";

               break;

            case VER_PLATFORM_WIN32_NT:

               if( osVer.dwMajorVersion == 6 )
               {
#if !defined(HB_WINCE) && !defined(__DMC__) && (!defined(_MSC_VER) || _MSC_VER >= 1400)
                  OSVERSIONINFOEXA osVerEx;

                  osVerEx.dwOSVersionInfoSize = sizeof( osVerEx );

                  if( GetVersionExA( ( OSVERSIONINFOA * ) &osVerEx ) )
                  {
                     if( osVerEx.wProductType == VER_NT_WORKSTATION )
                        pszName = "Windows Vista";
                     else
                        pszName = "Windows Server 2008";
                  }
                  else
#endif
                     pszName = "Windows";
               }
               else if( osVer.dwMajorVersion == 5 && osVer.dwMinorVersion >= 2 )
                  pszName = "Windows Server 2003 / XP x64";
               else if( osVer.dwMajorVersion == 5 && osVer.dwMinorVersion == 1 )
                  pszName = "Windows XP";
               else if( osVer.dwMajorVersion == 5 )
                  pszName = "Windows 2000";
               else
                  pszName = "Windows NT";

               break;

            case VER_PLATFORM_WIN32s:
               pszName = "Windows 32s";
               break;

            case VER_PLATFORM_WIN32_CE:
               pszName = "Windows CE";
               break;
         }

         snprintf( pszPlatform, PLATFORM_BUF_SIZE + 1, "%s %lu.%lu.%04d",
                   pszName,
                   ( ULONG ) osVer.dwMajorVersion,
                   ( ULONG ) osVer.dwMinorVersion,
                   ( USHORT ) LOWORD( osVer.dwBuildNumber ) );

         /* Add service pack/other info */

         if( osVer.szCSDVersion )
         {
            int i;

            /* Skip the leading spaces (Win95B, Win98) */
            for( i = 0; osVer.szCSDVersion[ i ] != '\0' && isspace( ( int ) osVer.szCSDVersion[ i ] ); i++ ) {};

            if( osVer.szCSDVersion[ i ] != '\0' )
            {
               hb_strncat( pszPlatform, " ", PLATFORM_BUF_SIZE );
               hb_strncat( pszPlatform, osVer.szCSDVersion + i, PLATFORM_BUF_SIZE );
            }
         }
      }
      else
         snprintf( pszPlatform, PLATFORM_BUF_SIZE + 1, "Windows" );
   }

#elif defined(__CEGCC__)
   {
      snprintf( pszPlatform, PLATFORM_BUF_SIZE + 1, "Windows CE" );
   }
#elif defined(HB_OS_UNIX)

   {
      struct utsname un;

      uname( &un );
      snprintf( pszPlatform, PLATFORM_BUF_SIZE + 1, "%s %s %s", un.sysname, un.release, un.machine );
   }

#else

   {
      hb_strncpy( pszPlatform, "(unknown)", PLATFORM_BUF_SIZE );
   }

#endif

   return pszPlatform;
}
hbver.c107
HB_EXPORT BOOLhb_iswinnt( void )
HB_EXPORT BOOL hb_iswinnt( void )
{
#if defined(HB_OS_WIN_32)
   static BOOL s_fWinNT = FALSE;
   static BOOL s_fInited = FALSE;

   if( ! s_fInited )
   {
      OSVERSIONINFO osvi;
      osvi.dwOSVersionInfoSize = sizeof( osvi );
      if( GetVersionEx( &osvi ) )
         s_fWinNT = osvi.dwPlatformId == VER_PLATFORM_WIN32_NT; /* && osvi.dwMajorVersion >= 4); */
      s_fInited = TRUE;
   }
   return s_fWinNT;
#else
   return FALSE;
#endif
}
hbver.c313
HB_EXPORT BOOLhb_iswince( void )
HB_EXPORT BOOL hb_iswince( void )
{
#if defined(HB_WINCE)
   return TRUE;
#else
   return FALSE;
#endif
}
hbver.c333
CHAR *hb_verCompiler( void )
char * hb_verCompiler( void )
{
   char * pszCompiler;
   const char * pszName;
   char szSub[ 32 ];
   int iVerMajor;
   int iVerMinor;
   int iVerPatch;

   HB_TRACE(HB_TR_DEBUG, ("hb_verCompiler()"));

   pszCompiler = ( char * ) hb_xgrab( COMPILER_BUF_SIZE );
   szSub[ 0 ] = '\0';

#if defined(__IBMC__) || defined(__IBMCPP__)

   #if defined(__IBMC__)
      iVerMajor = __IBMC__;
   #else
      iVerMajor = __IBMCPP__;
   #endif

   if( iVerMajor >= 300 )
      pszName = "IBM Visual Age C++";
   else
      pszName = "IBM C++";

   iVerMajor /= 100;
   iVerMinor = iVerMajor % 100;
   iVerPatch = 0;

#elif defined(__POCC__)

   pszName = "Pelles ISO C Compiler";
   iVerMajor = __POCC__ / 100;
   iVerMinor = __POCC__ % 100;
   iVerPatch = 0;

#elif defined(__XCC__)

   pszName = "Pelles ISO C Compiler (XCC)";
   iVerMajor = __XCC__ / 100;
   iVerMinor = __XCC__ % 100;
   iVerPatch = 0;

#elif defined(__LCC__)

   pszName = "Logiciels/Informatique lcc-win32";
   iVerMajor = 0 /* __LCC__ / 100 */;
   iVerMinor = 0 /* __LCC__ % 100 */;
   iVerPatch = 0;

#elif defined(__DMC__)

   pszName = __DMC_VERSION_STRING__;
   iVerMajor = 0;
   iVerMinor = 0;
   iVerPatch = 0;

#elif defined(_MSC_VER)

   #if (_MSC_VER >= 800)
      pszName = "Microsoft Visual C";
   #else
      pszName = "Microsoft C";
   #endif

   #if defined(__cplusplus)
      hb_strncpy( szSub, "++", sizeof( szSub ) - 1 );
   #endif

   iVerMajor = _MSC_VER / 100;
   iVerMinor = _MSC_VER % 100;

   #if defined(_MSC_FULL_VER)
      iVerPatch = _MSC_FULL_VER - ( _MSC_VER * 10000 );
   #else
      iVerPatch = 0;
   #endif

#elif defined(__BORLANDC__)

   #if (__BORLANDC__ >= 1424) /* Version 5.9 */
      pszName = "CodeGear C++";
   #else
      pszName = "Borland C++";
   #endif
   #if (__BORLANDC__ == 1040) /* Version 3.1 */
      iVerMajor = 3;
      iVerMinor = 1;
      iVerPatch = 0;
   #elif (__BORLANDC__ >= 1280) /* Version 5.x */
      iVerMajor = __BORLANDC__ >> 8;
      iVerMinor = ( __BORLANDC__ & 0xFF ) >> 4;
      iVerPatch = __BORLANDC__ & 0xF;
   #else /* Version 4.x */
      iVerMajor = __BORLANDC__ >> 8;
      iVerMinor = ( __BORLANDC__ - 1 & 0xFF ) >> 4;
      iVerPatch = 0;
   #endif

#elif defined(__TURBOC__)

   pszName = "Borland Turbo C";
   iVerMajor = __TURBOC__ >> 8;
   iVerMinor = __TURBOC__ & 0xFF;
   iVerPatch = 0;

#elif defined(__MPW__)

   pszName = "MPW C";
   iVerMajor = __MPW__ / 100;
   iVerMinor = __MPW__ % 100;
   iVerPatch = 0;

#elif defined(__WATCOMC__)

   #if __WATCOMC__ < 1200
      pszName = "Watcom C";
   #else
      pszName = "Open Watcom C";
   #endif

   #if defined(__cplusplus)
      hb_strncpy( szSub, "++", sizeof( szSub ) - 1 );
   #endif

   iVerMajor = __WATCOMC__ / 100;
   iVerMinor = __WATCOMC__ % 100;

   #if defined( __WATCOM_REVISION__ )
      iVerPatch = __WATCOM_REVISION__;
   #else
      iVerPatch = 0;
   #endif

#elif defined(__GNUC__)

   #if defined(__DJGPP__)
      pszName = "Delorie GNU C";
   #elif defined(__CYGWIN__)
      pszName = "Cygwin GNU C";
   #elif defined(__MINGW32__)
      pszName = "MinGW GNU C";
   #elif defined(__RSX32__)
      pszName = "EMX/RSXNT/DOS GNU C";
   #elif defined(__RSXNT__)
      pszName = "EMX/RSXNT/Win32 GNU C";
   #elif defined(__EMX__)
      pszName = "EMX GNU C";
   #else
      pszName = "GNU C";
   #endif

   #if defined(__cplusplus)
      hb_strncpy( szSub, "++", sizeof( szSub ) - 1 );
   #endif

   iVerMajor = __GNUC__;
   iVerMinor = __GNUC_MINOR__;
   #if defined(__GNUC_PATCHLEVEL__)
      iVerPatch = __GNUC_PATCHLEVEL__;
   #else
      iVerPatch = 0;
   #endif
#else

   pszName = ( char * ) NULL;
   iVerMajor = iVerMinor = iVerPatch = 0;

#endif

   if( pszName )
   {
      if( iVerPatch != 0 )
         snprintf( pszCompiler, COMPILER_BUF_SIZE, "%s%s %hd.%hd.%hd", pszName, szSub, iVerMajor, iVerMinor, iVerPatch );
      else if( iVerMajor != 0 || iVerMinor != 0 )
         snprintf( pszCompiler, COMPILER_BUF_SIZE, "%s%s %hd.%hd", pszName, szSub, iVerMajor, iVerMinor );
      else
         snprintf( pszCompiler, COMPILER_BUF_SIZE, "%s%s", pszName, szSub );
   }
   else
      hb_strncpy( pszCompiler, "(unknown)", COMPILER_BUF_SIZE - 1 );

#if defined(__DJGPP__)

   snprintf( szSub, sizeof( szSub ), " (DJGPP %i.%02i)", ( int ) __DJGPP__, ( int ) __DJGPP_MINOR__ );
   hb_strncat( pszCompiler, szSub, COMPILER_BUF_SIZE - 1 );

#else

   #if defined( HB_ARCH_16BIT )
      hb_strncat( pszCompiler, " (16 bit)", COMPILER_BUF_SIZE - 1 );
   #elif defined( HB_ARCH_32BIT )
      hb_strncat( pszCompiler, " (32 bit)", COMPILER_BUF_SIZE - 1 );
   #elif defined( HB_ARCH_64BIT )
      hb_strncat( pszCompiler, " (64 bit)", COMPILER_BUF_SIZE - 1 );
   #endif

#endif

   return pszCompiler;
}

hbver.c346
CHAR *hb_verHarbour( void )
char * hb_verHarbour( void )
{
   char * pszVersion;

   HB_TRACE(HB_TR_DEBUG, ("hb_verHarbour()"));

   pszVersion = ( char * ) hb_xgrab( 80 );
   snprintf( pszVersion, 80, "Harbour %d.%d.%d%s (Rev. %d)",
             HB_VER_MAJOR, HB_VER_MINOR, HB_VER_REVISION, HB_VER_STATUS,
             hb_verSvnID() );

   return pszVersion;
}
hbver.c557
CHAR *hb_verPCode( void )
char * hb_verPCode( void )
{
   char * pszPCode;

   HB_TRACE(HB_TR_DEBUG, ("hb_verPCode()"));

   pszPCode = ( char * ) hb_xgrab( 24 );
   snprintf( pszPCode, 24, "PCode version: %d.%d",
             HB_PCODE_VER >> 8, HB_PCODE_VER & 0xFF );

   return pszPCode;
}
hbver.c571
CHAR *hb_verBuildDate( void )
char * hb_verBuildDate( void )
{
   char * pszDate;

   HB_TRACE(HB_TR_DEBUG, ("hb_verBuildDate()"));

   pszDate = ( char * ) hb_xgrab( 64 );
   snprintf( pszDate, 64, "%s %s", __DATE__, __TIME__ );

   return  pszDate;
}
hbver.c584
hbverdsp.c
TypeFunctionSourceLine
VOIDhb_verBuildInfo( void )
void hb_verBuildInfo( void )
{
   hb_conOutErr( "Harbour Build Info", 0 );
   hb_conOutErr( hb_conNewLine(), 0 );
   hb_conOutErr( "---------------------------", 0 );
   hb_conOutErr( hb_conNewLine(), 0 );

   {
      char * pszVersion = hb_verHarbour();
      hb_conOutErr( "Version: ", 0 );
      hb_conOutErr( pszVersion, 0 );
      hb_conOutErr( hb_conNewLine(), 0 );
      hb_xfree( pszVersion );
   }

   {
      char * pszPCode = hb_verPCode();
      hb_conOutErr( pszPCode, 0 );
      hb_conOutErr( hb_conNewLine(), 0 );
      hb_xfree( pszPCode );
   }

   {
      char * pszVersion = hb_verCompiler();
      hb_conOutErr( "Compiler: ", 0 );
      hb_conOutErr( pszVersion, 0 );
      hb_conOutErr( hb_conNewLine(), 0 );
      hb_xfree( pszVersion );
   }

   {
      char * pszVersion = hb_verPlatform();
      hb_conOutErr( "Platform: ", 0 );
      hb_conOutErr( pszVersion, 0 );
      hb_conOutErr( hb_conNewLine(), 0 );
      hb_xfree( pszVersion );
   }

   hb_conOutErr( hb_conNewLine(), 0 );

   {
      char * pszBuildDate = hb_verBuildDate();
      hb_conOutErr( "Built on: ", 0 );
      hb_conOutErr( pszBuildDate, 0 );
      hb_conOutErr( hb_conNewLine(), 0 );
      hb_xfree( pszBuildDate );
   }

   hb_conOutErr( "Last ChangeLog entry: ", 0 );
   hb_conOutErr( hb_verSvnLastEntry(), 0 );
   hb_conOutErr( hb_conNewLine(), 0 );

   hb_conOutErr( "ChangeLog SVN version: ", 0 );
   hb_conOutErr( hb_verSvnChangeLogID(), 0 );
   hb_conOutErr( hb_conNewLine(), 0 );

   {
      const char * pszFlags = hb_verFlagsPRG();
      if( pszFlags && *pszFlags )
      {
         hb_conOutErr( "Extra Harbour compiler switches: ", 0 );
         hb_conOutErr( pszFlags, 0 );
         hb_conOutErr( hb_conNewLine(), 0 );
      }
   }

   {
      const char * pszFlags = hb_verFlagsC();
      if( pszFlags && *pszFlags )
      {
         hb_conOutErr( "Extra C compiler switches: ", 0 );
         hb_conOutErr( pszFlags, 0 );
         hb_conOutErr( hb_conNewLine(), 0 );
      }
   }

   {
      const char * pszFlags = hb_verFlagsL();
      if( pszFlags && *pszFlags )
      {
         hb_conOutErr( "Extra linker switches: ", 0 );
         hb_conOutErr( pszFlags, 0 );
         hb_conOutErr( hb_conNewLine(), 0 );
      }
   }

   hb_conOutErr( "Other build settings: ", 0 );
#if defined(__cplusplus)
   hb_conOutErr( "(C++ mode) ", 0 );
#else
   hb_conOutErr( "(C mode) ", 0 );
#endif
#if defined( HB_STRICT_ANSI_C )
   hb_conOutErr( "(ANSI C symbol initialization) ", 0 );
#endif
   hb_conOutErr( hb_conNewLine(), 0 );

   hb_conOutErr( hb_conNewLine(), 0 );

   hb_conOutErr( "Clipper 5.3b compatible extensions: ", 0 );
#if defined( HB_COMPAT_C53 )
   hb_conOutErr( "yes", 0 );
#else
   hb_conOutErr( "no", 0 );
#endif
   hb_conOutErr( hb_conNewLine(), 0 );

   hb_conOutErr( "Clipper 5.2e/5.3b compatible undocumented: ", 0 );
#if defined( HB_C52_UNDOC )
   hb_conOutErr( "yes", 0 );
#else
   hb_conOutErr( "no", 0 );
#endif
   hb_conOutErr( hb_conNewLine(), 0 );

   hb_conOutErr( "Clipper 5.2e/5.3b strict compatibility: ", 0 );
#if defined( HB_C52_STRICT )
   hb_conOutErr( "yes", 0 );
#else
   hb_conOutErr( "no", 0 );
#endif
   hb_conOutErr( hb_conNewLine(), 0 );

   hb_conOutErr( "Xbase++ compatible extensions: ", 0 );
#if defined( HB_COMPAT_XPP )
   hb_conOutErr( "yes", 0 );
#else
   hb_conOutErr( "no", 0 );
#endif
   hb_conOutErr( hb_conNewLine(), 0 );

   hb_conOutErr( "FlagShip compatible extensions: ", 0 );
#if defined( HB_COMPAT_FLAGSHIP )
   hb_conOutErr( "yes", 0 );
#else
   hb_conOutErr( "no", 0 );
#endif
   hb_conOutErr( hb_conNewLine(), 0 );

   hb_conOutErr( "Visual Objects compatible extensions: ", 0 );
#if defined( HB_COMPAT_VO )
   hb_conOutErr( "yes", 0 );
#else
   hb_conOutErr( "no", 0 );
#endif
   hb_conOutErr( hb_conNewLine(), 0 );

   hb_conOutErr( "FoxPro compatible extensions: ", 0 );
#if defined( HB_COMPAT_FOXPRO )
   hb_conOutErr( "yes", 0 );
#else
   hb_conOutErr( "no", 0 );
#endif
   hb_conOutErr( hb_conNewLine(), 0 );

   hb_conOutErr( "dBase compatible extensions: ", 0 );
#if defined( HB_COMPAT_DBASE )
   hb_conOutErr( "yes", 0 );
#else
   hb_conOutErr( "no", 0 );
#endif
   hb_conOutErr( hb_conNewLine(), 0 );

   hb_conOutErr( "CLIP compatible extensions: ", 0 );
#if defined( HB_COMPAT_CLIP )
   hb_conOutErr( "yes", 0 );
#else
   hb_conOutErr( "no", 0 );
#endif
   hb_conOutErr( hb_conNewLine(), 0 );

   hb_conOutErr( "Non-portable Harbour extensions: ", 0 );
#if defined( HB_EXTENSION )
   hb_conOutErr( "yes", 0 );
#else
   hb_conOutErr( "no", 0 );
#endif
   hb_conOutErr( hb_conNewLine(), 0 );

   hb_conOutErr( "Profiler: ", 0 );
#if defined( HB_NO_PROFILER )
   hb_conOutErr( "off", 0 );
#else
   hb_conOutErr( "on", 0 );
#endif
   hb_conOutErr( hb_conNewLine(), 0 );

   hb_conOutErr( "Memory tracing and statistics: ", 0 );
   hb_conOutErr( hb_xquery( HB_MEM_USEDMAX ) != 0 ? "on" : "off", 0 );
   hb_conOutErr( hb_conNewLine(), 0 );

   {
      char buffer[ 64 ];
      snprintf( buffer, sizeof( buffer ), "Maximum symbol name length: %i", HB_SYMBOL_NAME_LEN );
      hb_conOutErr( buffer, 0 );
      hb_conOutErr( hb_conNewLine(), 0 );
   }

   hb_conOutErr( "---------------------------", 0 );
   hb_conOutErr( hb_conNewLine(), 0 );
}
hbverdsp.c56
hbwince.c
TypeFunctionSourceLine
VOIDhb_mbtowccpy( wchar_t *dstW, const char *srcA, ULONG ulLen )
void hb_mbtowccpy( wchar_t *dstW, const char *srcA, ULONG ulLen )
{
   MultiByteToWideChar( CP_ACP, 0, srcA, -1, dstW, ulLen / sizeof( wchar_t ) );
}
hbwince.c68
VOIDhb_mbtowcset( wchar_t *dstW, const char *srcA, unsigned long ulLen )
void hb_mbtowcset( wchar_t *dstW, const char *srcA, unsigned long ulLen )
{
   MultiByteToWideChar( CP_ACP, 0, srcA, ulLen, dstW, ulLen );
}
hbwince.c73
WCHAR_T hb_mbtowc( const char *srcA )
wchar_t *hb_mbtowc( const char *srcA )
{
   DWORD length;
   wchar_t *dstW;

   length = MultiByteToWideChar( CP_ACP, 0, srcA, -1, NULL, 0 );
   dstW = ( wchar_t * ) hb_xgrab( ( length + 1 ) * sizeof( wchar_t ) );
   MultiByteToWideChar( CP_ACP, 0, srcA, -1, dstW, length + 1 );

   return dstW;
}
hbwince.c78
CHAR hb_wctomb( const wchar_t *srcW )
char *hb_wctomb( const wchar_t *srcW )
{
   DWORD length;
   char *dstA;

   length = WideCharToMultiByte( CP_ACP, 0, srcW, -1, NULL, 0, NULL, NULL );
   dstA = ( char * ) hb_xgrab( length + 1 );
   WideCharToMultiByte( CP_ACP, 0, srcW, -1, dstA, length + 1, NULL, NULL );

   return dstA;
}
hbwince.c90
WCHAR_T hb_mbntowc( const char *srcA, unsigned long ulLen )
wchar_t *hb_mbntowc( const char *srcA, unsigned long ulLen )
{
   DWORD length;
   wchar_t *dstW;

   length = MultiByteToWideChar( CP_ACP, 0, srcA, ulLen, NULL, 0 );
   dstW = ( wchar_t * ) hb_xgrab( ( length + 1 ) * sizeof( wchar_t ) );
   MultiByteToWideChar( CP_ACP, 0, srcA, ulLen, dstW, length + 1 );

   return dstW;
}
hbwince.c102
CHAR hb_wcntomb( const wchar_t *srcW, unsigned long ulLen )
char *hb_wcntomb( const wchar_t *srcW, unsigned long ulLen )
{
   DWORD length;
   char *dstA;

   length = WideCharToMultiByte( CP_ACP, 0, srcW, ulLen, NULL, 0, NULL, NULL );
   dstA = ( char * ) hb_xgrab( length + 1 );
   WideCharToMultiByte( CP_ACP, 0, srcW, ulLen, dstA, length + 1, NULL, NULL );

   return dstA;
}
hbwince.c114
VOIDhb_wctombget( char *dstA, const wchar_t *srcW, unsigned long ulLen )
void hb_wctombget( char *dstA, const wchar_t *srcW, unsigned long ulLen )
{
   WideCharToMultiByte( CP_ACP, 0, srcW, ulLen, dstA, ulLen, NULL, NULL );
}
hbwince.c126
INTremove( const char *filename )
int remove( const char *filename )
{
   return DeleteFileA( filename ) ? 0 : -1;
}
hbwince.c133
INTaccess( const char *filename, int mode )
int access( const char *filename, int mode )
{
   WIN32_FIND_DATAW wdata;
   LPWSTR wfilename;
   HANDLE h;

   HB_SYMBOL_UNUSED( mode );

   wfilename = hb_mbtowc( filename );
   h = FindFirstFileW( wfilename, &wdata );
   hb_xfree( wfilename );

   return h != INVALID_HANDLE_VALUE;
}
hbwince.c138
INTsystem( const char *cmd )
int system( const char *cmd )
{
   LPWSTR wcmd;
   STARTUPINFOW si;
   PROCESS_INFORMATION pi;
   BOOL b;

   memset( &si, '\0', sizeof( si ) );
   si.cb = sizeof( si );
   memset( &pi, '\0', sizeof( pi ) );

   wcmd = hb_mbtowc( cmd );

   /* Start the child process. */
   b = CreateProcessW( NULL,     /* No module name (use command line) */
                       wcmd,     /* Command line */
                       NULL,     /* Process handle not inheritable */
                       NULL,     /* Thread handle not inheritable */
                       FALSE,    /* Set handle inheritance to FALSE */
                       0,        /* No creation flags */
                       NULL,     /* Use parent's environment block */
                       NULL,     /* Use parent's starting directory */
                       &si,      /* Pointer to STARTUPINFO structure */
                       &pi );    /* Pointer to PROCESS_INFORMATION structure */

   hb_xfree( wcmd );

   if( b )
   {
      /* Wait until child process exits. */
      WaitForSingleObject( pi.hProcess, INFINITE );

      /* Close process and thread handles. */
      CloseHandle( pi.hProcess );
      CloseHandle( pi.hThread );
   }

   return b ? 0 : -1;
}
hbwince.c153
CHAR *strerror( int errnum )
char * strerror( int errnum )
{
   HB_SYMBOL_UNUSED( errnum );

   return ( char * ) "";
}
hbwince.c193
DWORD WINAPIGetEnvironmentVariableA( LPCSTR name, LPSTR value, DWORD size )
DWORD WINAPI GetEnvironmentVariableA( LPCSTR name, LPSTR value, DWORD size )
{
   /* use registry instead of "environment valuable". */
   HKEY hk;
   LONG lret;
   LPBYTE lpData;
   DWORD dwType = REG_SZ, cbData;
   TCHAR buf[ MAX_PATH ] = { 0 };
   LPWSTR wname;
   LPSTR avalue;

   lret = RegOpenKeyEx( HKEY_LOCAL_MACHINE, TEXT( "Software\\harbour_mswince" ), 0, KEY_QUERY_VALUE, &hk );

   if( lret != ERROR_SUCCESS )
   {
      if( value && size )
         value[ 0 ] = '\0';
      return 0;
   }

   lpData = ( LPBYTE ) buf;
   cbData = MAX_PATH * sizeof( *buf );
   wname = hb_mbtowc( name );

   lret = RegQueryValueExW( hk, wname, NULL, &dwType, lpData, &cbData );
   RegCloseKey( hk );

   if( lret != ERROR_SUCCESS )
   {
      if( value && size )
         value[ 0 ] = '\0';
      hb_xfree( wname );
      return 0;
   }

   avalue = hb_wctomb( ( LPCWSTR ) lpData );
   if( value && size )
      hb_strncpy( value, avalue, size - 1 );
   size = strlen( avalue );

   hb_xfree( avalue );
   hb_xfree( wname );

   return size;
}
hbwince.c200
BOOL WINAPIGetProcessTimes( HANDLE hprocess, LPFILETIME lpCreationTime, LPFILETIME lpExitTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime )
BOOL WINAPI GetProcessTimes( HANDLE hprocess,
                             LPFILETIME lpCreationTime, LPFILETIME lpExitTime,
                             LPFILETIME lpKernelTime, LPFILETIME lpUserTime )
{

   HB_SYMBOL_UNUSED( hprocess );
   HB_SYMBOL_UNUSED( lpCreationTime );
   HB_SYMBOL_UNUSED( lpExitTime );
   HB_SYMBOL_UNUSED( lpKernelTime );
   HB_SYMBOL_UNUSED( lpUserTime );

   return 0;
}
hbwince.c246
BOOL WINAPIGetUserNameA( LPSTR buffer, LPDWORD len )
BOOL WINAPI GetUserNameA( LPSTR buffer, LPDWORD len )
{
   if( len && buffer )
      buffer[ 0 ] = '\0';

   return FALSE;
}
hbwince.c260
BOOL WINAPIGetComputerNameA( LPSTR buffer, LPDWORD len )
BOOL WINAPI GetComputerNameA( LPSTR buffer, LPDWORD len )
{
   if( len && buffer )
      buffer[ 0 ] = '\0';

   return FALSE;
}
hbwince.c268
DWORD WINAPIGetCurrentDirectoryA( DWORD len, LPSTR buffer )
DWORD WINAPI GetCurrentDirectoryA( DWORD len, LPSTR buffer )
{
   if( len && buffer )
      buffer[ 0 ] = '\0';

   return FALSE;
}
hbwince.c276
BOOL WINAPISetCurrentDirectoryA( LPCSTR dirname )
BOOL WINAPI SetCurrentDirectoryA( LPCSTR dirname )
{
   HB_SYMBOL_UNUSED( dirname );

   return FALSE;
}
hbwince.c284
BOOL WINAPILockFile( HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh, DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh )
BOOL WINAPI LockFile( HANDLE hFile,
                      DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh,
                      DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh )
{
   HB_SYMBOL_UNUSED( hFile );
   HB_SYMBOL_UNUSED( dwFileOffsetLow );
   HB_SYMBOL_UNUSED( dwFileOffsetHigh );
   HB_SYMBOL_UNUSED( nNumberOfBytesToLockLow );
   HB_SYMBOL_UNUSED( nNumberOfBytesToLockHigh );

   return TRUE;
}
hbwince.c291
BOOL WINAPILockFileEx( HANDLE hFile, DWORD dwFlags, DWORD dwReserved, DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh, LPOVERLAPPED lpOverlapped )
BOOL WINAPI LockFileEx( HANDLE hFile,
                        DWORD dwFlags, DWORD dwReserved,
                        DWORD nNumberOfBytesToLockLow,
                        DWORD nNumberOfBytesToLockHigh, LPOVERLAPPED lpOverlapped )
{
   HB_SYMBOL_UNUSED( hFile );
   HB_SYMBOL_UNUSED( dwFlags );
   HB_SYMBOL_UNUSED( dwReserved );
   HB_SYMBOL_UNUSED( nNumberOfBytesToLockLow );
   HB_SYMBOL_UNUSED( nNumberOfBytesToLockHigh );
   HB_SYMBOL_UNUSED( lpOverlapped );

   return TRUE;
}
hbwince.c304
BOOL WINAPIUnlockFile( HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh, DWORD nNumberOfBytesToUnlockLow, DWORD nNumberOfBytesToUnlockHigh )
BOOL WINAPI UnlockFile( HANDLE hFile,
                        DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh,
                        DWORD nNumberOfBytesToUnlockLow, DWORD nNumberOfBytesToUnlockHigh )
{
   HB_SYMBOL_UNUSED( hFile );
   HB_SYMBOL_UNUSED( dwFileOffsetLow );
   HB_SYMBOL_UNUSED( dwFileOffsetHigh );
   HB_SYMBOL_UNUSED( nNumberOfBytesToUnlockLow );
   HB_SYMBOL_UNUSED( nNumberOfBytesToUnlockHigh );

   return TRUE;
}
hbwince.c319
BOOL WINAPIUnlockFileEx( HANDLE hFile, DWORD dwReserved, DWORD nNumberOfBytesToUnlockLow, DWORD nNumberOfBytesToUnlockHigh, LPOVERLAPPED lpOverlapped )
BOOL WINAPI UnlockFileEx( HANDLE hFile, DWORD dwReserved,
                          DWORD nNumberOfBytesToUnlockLow,
                          DWORD nNumberOfBytesToUnlockHigh, LPOVERLAPPED lpOverlapped )
{
   HB_SYMBOL_UNUSED( hFile );
   HB_SYMBOL_UNUSED( dwReserved );
   HB_SYMBOL_UNUSED( nNumberOfBytesToUnlockLow );
   HB_SYMBOL_UNUSED( nNumberOfBytesToUnlockHigh );
   HB_SYMBOL_UNUSED( lpOverlapped );

   return TRUE;
}
hbwince.c332
BOOL WINAPIGetVolumeInformationA( LPCSTR p1, LPSTR p2, DWORD p3, PDWORD p4, PDWORD p5, PDWORD p6, LPSTR p7, DWORD p8 )
BOOL WINAPI GetVolumeInformationA( LPCSTR p1, LPSTR p2, DWORD p3, PDWORD p4,
                                   PDWORD p5, PDWORD p6, LPSTR p7, DWORD p8 )
{
   HB_SYMBOL_UNUSED( p1 );
   HB_SYMBOL_UNUSED( p2 );
   HB_SYMBOL_UNUSED( p3 );
   HB_SYMBOL_UNUSED( p4 );
   HB_SYMBOL_UNUSED( p5 );
   HB_SYMBOL_UNUSED( p6 );
   HB_SYMBOL_UNUSED( p7 );
   HB_SYMBOL_UNUSED( p8 );

   return FALSE;
}
hbwince.c345
UINT WINAPISetErrorMode( UINT mode )
UINT WINAPI SetErrorMode( UINT mode )
{
   HB_SYMBOL_UNUSED( mode );

   return 0;
}
hbwince.c360
HANDLE WINAPICreateFileA( LPCSTR filename, DWORD access, DWORD sharing, LPSECURITY_ATTRIBUTES sa, DWORD creation, DWORD attributes, HANDLE tmplt )
HANDLE WINAPI CreateFileA( LPCSTR filename, DWORD access,
                    DWORD sharing, LPSECURITY_ATTRIBUTES sa,
                    DWORD creation, DWORD attributes, HANDLE tmplt )
{
   LPWSTR wfilename;
   HANDLE h;

   wfilename = hb_mbtowc( filename );
   h = CreateFileW( wfilename, access, sharing, sa, creation, attributes, tmplt );
   hb_xfree( wfilename );

   return h;
}
hbwince.c367
BOOL WINAPIMoveFileA( LPCSTR fn1, LPCSTR fn2 )
BOOL WINAPI MoveFileA( LPCSTR fn1, LPCSTR fn2 )
{
   LPWSTR wfn1, wfn2;
   BOOL b;

   wfn1 = hb_mbtowc( fn1 );
   wfn2 = hb_mbtowc( fn2 );
   b = MoveFileW( wfn1, wfn2 );
   hb_xfree( wfn1 );
   hb_xfree( wfn2 );

   return b;
}
hbwince.c381
BOOL WINAPIDeleteFileA( LPCSTR path )
BOOL WINAPI DeleteFileA( LPCSTR path )
{
   LPWSTR wpath;
   BOOL b;

   wpath = hb_mbtowc( path );
   b = DeleteFileW( wpath );
   hb_xfree( wpath );

   return b;
}
hbwince.c395
BOOL WINAPIRemoveDirectoryA( LPCSTR path )
BOOL WINAPI RemoveDirectoryA( LPCSTR path )
{
   LPWSTR wpath;
   BOOL b;

   wpath = hb_mbtowc( path );
   b = RemoveDirectoryW( wpath );
   hb_xfree( wpath );

   return b;
}
hbwince.c407
BOOL WINAPICreateDirectoryA( LPCSTR path, LPSECURITY_ATTRIBUTES attr )
BOOL WINAPI CreateDirectoryA( LPCSTR path, LPSECURITY_ATTRIBUTES attr )
{
   LPWSTR wpath;
   BOOL b;

   wpath = hb_mbtowc( path );
   b = CreateDirectoryW( wpath, attr );
   hb_xfree( wpath );

   return b;
}
hbwince.c419
BOOL WINAPISetFileAttributesA( LPCSTR filename, DWORD attr )
BOOL WINAPI SetFileAttributesA( LPCSTR filename, DWORD attr )
{
   LPWSTR wfilename;
   BOOL b;

   wfilename = hb_mbtowc( filename );
   b = SetFileAttributesW( wfilename, attr );
   hb_xfree( wfilename );

   return b;
}
hbwince.c431
BOOL WINAPICharToOemBuffA( LPCSTR src, LPSTR dst, DWORD len )
BOOL WINAPI CharToOemBuffA( LPCSTR src, LPSTR dst, DWORD len )
{
   if( len )
      hb_strncpy( dst, src, len - 1 );
   return TRUE;
}
hbwince.c443
BOOL WINAPIOemToCharBuffA( LPCSTR src, LPSTR dst, DWORD len )
BOOL WINAPI OemToCharBuffA( LPCSTR src, LPSTR dst, DWORD len )
{
   if( len )
      hb_strncpy( dst, src, len - 1 );
   return TRUE;
}
hbwince.c450
HANDLE WINAPIFindFirstFileA( LPCSTR path, WIN32_FIND_DATAA * data )
HANDLE WINAPI FindFirstFileA( LPCSTR path, WIN32_FIND_DATAA * data )
{
   WIN32_FIND_DATAW wdata;
   LPWSTR wpath;
   LPSTR mb;
   HANDLE h;

   wpath = hb_mbtowc( path );
   h = FindFirstFileW( wpath, &wdata );
   hb_xfree( wpath );

   mb = hb_wctomb( wdata.cFileName );
   hb_strncpy( data->cFileName, mb, sizeof( data->cFileName ) - 1 );
   hb_xfree( mb );
   data->dwFileAttributes = wdata.dwFileAttributes;
   data->ftCreationTime = wdata.ftCreationTime;
   data->ftLastAccessTime = wdata.ftLastAccessTime;
   data->ftLastWriteTime = wdata.ftLastWriteTime;
   data->nFileSizeHigh = wdata.nFileSizeHigh;
   data->nFileSizeLow = wdata.nFileSizeLow;

   return h;
}
hbwince.c457
BOOL WINAPIFindNextFileA( HANDLE handle, WIN32_FIND_DATAA * data )
BOOL WINAPI FindNextFileA( HANDLE handle, WIN32_FIND_DATAA * data )
{
   WIN32_FIND_DATAW wdata;
   LPSTR mb;
   BOOL b;

   b = FindNextFileW( handle, &wdata );
   mb = hb_wctomb( wdata.cFileName );
   hb_strncpy( data->cFileName, mb, sizeof( data->cFileName ) - 1 );
   hb_xfree( mb );
   data->dwFileAttributes = wdata.dwFileAttributes;
   data->ftCreationTime = wdata.ftCreationTime;
   data->ftLastAccessTime = wdata.ftLastAccessTime;
   data->ftLastWriteTime = wdata.ftLastWriteTime;
   data->nFileSizeHigh = wdata.nFileSizeHigh;
   data->nFileSizeLow = wdata.nFileSizeLow;

   return b;
}
hbwince.c481
DWORD WINAPIGetFileAttributesA( LPCSTR path )
DWORD WINAPI GetFileAttributesA( LPCSTR path )
{
   LPWSTR wpath;
   DWORD dw;

   wpath = hb_mbtowc( path );
   dw = GetFileAttributesW( wpath );
   hb_xfree( wpath );

   return dw;
}
hbwince.c501
UINT WINAPIGetDriveTypeA( LPCSTR path )
UINT WINAPI GetDriveTypeA( LPCSTR path )
{
   /* temporary disabled - not all WinCE compilers support GetDriveTypeW() */
#if 0
   LPWSTR wpath;
   UINT ui;

   wpath = hb_mbtowc( path );
   ui = GetDriveTypeW( wpath );
   hb_xfree( wpath );

   return ui;
#else
   HB_SYMBOL_UNUSED( path );

   return DRIVE_UNKNOWN;
#endif /* 0 */
}
hbwince.c513
BOOL WINAPIGetVersionExA( OSVERSIONINFOA * v )
BOOL WINAPI GetVersionExA( OSVERSIONINFOA * v )
{
   OSVERSIONINFOW wv;
   LPSTR mb;
   BOOL b;

   b = GetVersionExW( &wv );
   mb = hb_wctomb( wv.szCSDVersion );
   hb_strncpy( v->szCSDVersion, mb, sizeof( v->szCSDVersion ) - 1 );
   hb_xfree( mb );
   v->dwOSVersionInfoSize = wv.dwOSVersionInfoSize;
   v->dwMajorVersion = wv.dwMajorVersion;
   v->dwMinorVersion = wv.dwMinorVersion;
   v->dwBuildNumber = wv.dwBuildNumber;
   v->dwPlatformId = wv.dwPlatformId;

   return b;
}
hbwince.c532
HANDLE WINAPIGetStdHandle( DWORD nStdHandle )
HANDLE WINAPI GetStdHandle( DWORD nStdHandle )
{
   HB_SYMBOL_UNUSED( nStdHandle );

   return NULL;
}
hbwince.c552
DWORD WINAPIGetFileType( HANDLE handle )
DWORD WINAPI GetFileType( HANDLE handle )
{
   HB_SYMBOL_UNUSED( handle );

   return 0;
}
hbwince.c559
HMODULE WINAPIGetModuleHandleA( LPCSTR modulename )
HMODULE WINAPI GetModuleHandleA( LPCSTR modulename )
{
   LPWSTR wmodulename;
   HMODULE h;

   wmodulename = hb_mbtowc( modulename );
   h = GetModuleHandleW( wmodulename );
   hb_xfree( wmodulename );

   return h;
}
hbwince.c566
HINSTANCE WINAPILoadLibraryA( LPCSTR libname )
HINSTANCE WINAPI LoadLibraryA( LPCSTR libname )
{
   LPWSTR wlibname;
   HINSTANCE h;

   wlibname = hb_mbtowc( libname );

   h = LoadLibraryW( wlibname );
   hb_xfree( wlibname );

   return h;
}
hbwince.c578
DWORD WINAPIGetTempPathA( DWORD size, LPSTR buffer )
DWORD WINAPI GetTempPathA( DWORD size, LPSTR buffer )
{
   WCHAR wbuffer[MAX_PATH] = { 0 };
   char *abuffer;
   DWORD dw;

   dw = GetTempPathW( MAX_PATH, wbuffer );
   abuffer = hb_wctomb( wbuffer );
   hb_strncpy( buffer, abuffer, size );
   hb_xfree( abuffer );

   return dw;
}
hbwince.c591
UINT WINAPIGetTempFileNameA( LPCSTR tmpdir, LPCSTR prefix, UINT unique, LPSTR filename )
UINT WINAPI GetTempFileNameA( LPCSTR tmpdir, LPCSTR prefix, UINT unique, LPSTR filename )
{
   LPWSTR wtmpdir, wprefix;
   WCHAR wfilename[ MAX_PATH ] = { 0 };
   UINT u;

   wtmpdir = hb_mbtowc( tmpdir );
   wprefix = hb_mbtowc( prefix );
   u = GetTempFileNameW( wtmpdir, wprefix, unique, wfilename );
   hb_xfree( wtmpdir );
   hb_xfree( wprefix );

   if( filename )
   {
      char *afilename = hb_wctomb( wfilename );

      hb_strncpy( filename, afilename, _POSIX_PATH_MAX );
      hb_xfree( afilename );
   }

   return u;
}
hbwince.c605
BOOL WINAPIBeep( DWORD dwFreq, DWORD dwDurat )
BOOL WINAPI Beep( DWORD dwFreq, DWORD dwDurat )
{
   HB_SYMBOL_UNUSED( dwFreq );
   HB_SYMBOL_UNUSED( dwDurat );

   return FALSE;
}
hbwince.c628
INT WINAPISetTextCharacterExtra( HDC hdc, int i )
int WINAPI SetTextCharacterExtra( HDC hdc, int i )
{
   HB_SYMBOL_UNUSED( hdc );
   HB_SYMBOL_UNUSED( i );

   return 0;
}
hbwince.c636
BOOL WINAPIGetKeyboardState( PBYTE p )
BOOL WINAPI GetKeyboardState( PBYTE p )
{
   HB_SYMBOL_UNUSED( p );

   return FALSE;
}
hbwince.c644
BOOL WINAPISetKeyboardState( PBYTE p )
BOOL WINAPI SetKeyboardState( PBYTE p )
{
   HB_SYMBOL_UNUSED( p );

   return FALSE;
}
hbwince.c651
PVOID WINAPILocalLock( HLOCAL h )
PVOID WINAPI LocalLock( HLOCAL h )
{
   return ( PVOID ) h;
}
hbwince.c661
BOOL WINAPILocalUnlock( HLOCAL h )
BOOL WINAPI LocalUnlock( HLOCAL h )
{
   HB_SYMBOL_UNUSED( h );

   return FALSE;
}
hbwince.c668
HLOCAL WINAPILocalHandle( LPCVOID p )
HLOCAL WINAPI LocalHandle( LPCVOID p )
{
   return ( HLOCAL ) p;
}
hbwince.c677
INT WINAPIMulDiv( int nNumber, int nNumerator, int nDenominator )
int WINAPI MulDiv( int nNumber, int nNumerator, int nDenominator )
{
   if( nDenominator )
   {
      HB_LONG llResult = ( HB_LONG ) nNumber * nNumerator / nDenominator;
      if( HB_LIM_INT32( llResult ) )
         return ( int ) llResult;
   }
   return -1;
}
hbwince.c686
BOOL WINAPIFreeResource( HGLOBAL h )
BOOL WINAPI FreeResource( HGLOBAL h )
{
   HB_SYMBOL_UNUSED( h );
   return FALSE;
}
hbwince.c698
BOOL WINAPIArc( HDC h, int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8 )
BOOL WINAPI Arc( HDC h, int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8 )
{
   HB_SYMBOL_UNUSED( h );
   HB_SYMBOL_UNUSED( p1 );
   HB_SYMBOL_UNUSED( p2 );
   HB_SYMBOL_UNUSED( p3 );
   HB_SYMBOL_UNUSED( p4 );
   HB_SYMBOL_UNUSED( p5 );
   HB_SYMBOL_UNUSED( p6 );
   HB_SYMBOL_UNUSED( p7 );
   HB_SYMBOL_UNUSED( p8 );
   return FALSE;
}
hbwince.c704
INT WINAPIFrameRect( HDC h, LPCRECT r, HBRUSH hb )
int WINAPI FrameRect( HDC h, LPCRECT r, HBRUSH hb )
{
   HB_SYMBOL_UNUSED( h );
   HB_SYMBOL_UNUSED( r );
   HB_SYMBOL_UNUSED( hb );
   return 0;
}
hbwince.c718
BOOL WINAPIFloodFill( HDC h, int x, int y, COLORREF c )
BOOL WINAPI FloodFill( HDC h, int x, int y, COLORREF c )
{
   HB_SYMBOL_UNUSED( h );
   HB_SYMBOL_UNUSED( x );
   HB_SYMBOL_UNUSED( y );
   HB_SYMBOL_UNUSED( c );
   return FALSE;
}
hbwince.c726
CLOCK_Tclock( void )
clock_t clock( void )
{
   SYSTEMTIME st;

   GetLocalTime( &st );

   return ( ( clock_t ) hb_dateEncode( st.wYear, st.wMonth, st.wDay ) - 2451545 ) * 86400000 +
      ( ( st.wHour * 60 + st.wMinute ) * 60 + st.wSecond ) * 1000 + st.wMilliseconds;
}
hbwince.c740
BOOL WINAPIGetDiskFreeSpaceA( LPCSTR path, PDWORD pdwSectorsPerCluster, PDWORD pdwBytesPerSector, PDWORD pdwNumberOfFreeClusters, PDWORD pdwTotalNumberOfClusters )
BOOL WINAPI GetDiskFreeSpaceA( LPCSTR path, PDWORD pdwSectorsPerCluster,
                               PDWORD pdwBytesPerSector,
                               PDWORD pdwNumberOfFreeClusters, PDWORD pdwTotalNumberOfClusters )
{
   HB_SYMBOL_UNUSED( path );
   HB_SYMBOL_UNUSED( pdwSectorsPerCluster );
   HB_SYMBOL_UNUSED( pdwBytesPerSector );
   HB_SYMBOL_UNUSED( pdwNumberOfFreeClusters );
   HB_SYMBOL_UNUSED( pdwTotalNumberOfClusters );

   return FALSE;
}
hbwince.c751
reserved.c
TypeFunctionSourceLine
CONST CHAR *hb_compReservedName( const char * szName )
const char * hb_compReservedName( const char * szName )
{
#if !defined( HB_RESERVED_OFF )
   unsigned int uiFirst = 0, uiLast = RESERVED_FUNCTIONS - 1, uiMiddle;
   int iLen = ( int ) strlen( szName ), iCmp;

   /* Respect 4 or more letters shortcuts
    * SECO() is not allowed because of Clipper function SECONDS()
    * however SECO32() is a valid name.
    */
   if( iLen < 4 )
      iLen = 4;
   do
   {
      uiMiddle = ( uiFirst + uiLast ) >> 1;
      iCmp = strncmp( szName, s_szReservedFun[ uiMiddle ], iLen );
      if( iCmp <= 0 )
         uiLast = uiMiddle;
      else
         uiFirst = uiMiddle + 1;
   }
   while( uiFirst < uiLast );

   if( uiFirst != uiMiddle )
      iCmp = strncmp( szName, s_szReservedFun[ uiFirst ], iLen );

   if( iCmp == 0 )
      return ( char * ) s_szReservedFun[ uiFirst ];
#else
   HB_SYMBOL_UNUSED( szName );
#endif

   return NULL;
}
reserved.c130

Page url: http://www.yourdomain.com/help/index.html?common.htm