2017-09-08 16:00 UTC Viktor Szakats (vszakats users.noreply.github.com)
* *
* partial sync with the 3.4 fork codebase. These are the things
synces for the most part:
- copyright headers
- grammar/typos in comments and some readmes
- comment/whitespace/decorations
- variable scoping in C files
- DO CASE/SWITCH and some other alternate syntax usage
- minimal amount of human readable text in strings
- minor code updates
- HB_TRACE() void * casts for pointers and few other changes to
avoid C compiler warnings
- various other, minor code cleanups
- only Harbour/C code/headers were touched in src, utils, contrib,
include. No 3rd party code, no make files, and with just a few
exceptions, no 'tests' code was touched.
- certain components were not touched were 3.4 diverged too much
already, like f.e. hbmk2, hbssl, hbcurl, hbexpat
- the goal was that no actual program logic should be altered by
these changes. Except some possible minor exceptions, any such
change is probably a bug in this patch.
It's a massive patch, if you find anything broken after it, please
open an Issue with the details. Build test was done on macOS.
The goal is make it easier to see what actual code/logic was changed
in 3.4 compared to 3.2 and to make patches easier to apply in both
ways.
This commit is contained in:
@@ -84,7 +84,7 @@ static const char * s_OperTable[ HB_EXPR_COUNT ] = {
|
||||
"", /* variable */
|
||||
"++", /* post-operators -> lowest precedence */
|
||||
"--",
|
||||
":=", /* assigments */
|
||||
":=", /* assignments */
|
||||
"+=",
|
||||
"-=",
|
||||
"*=",
|
||||
@@ -150,7 +150,7 @@ static const HB_BYTE s_PrecedTable[ HB_EXPR_COUNT ] = {
|
||||
HB_ET_NIL, /* HB_ET_VARIABLE, */
|
||||
HB_ET_NIL, /* HB_EO_POSTINC, post-operators */
|
||||
HB_ET_NIL, /* HB_EO_POSTDEC, */
|
||||
HB_ET_NONE, /* HB_EO_ASSIGN, assigments */
|
||||
HB_ET_NONE, /* HB_EO_ASSIGN, assignments */
|
||||
HB_ET_NONE, /* HB_EO_PLUSEQ, Invalid syntax */
|
||||
HB_ET_NONE, /* HB_EO_MINUSEQ, */
|
||||
HB_ET_NONE, /* HB_EO_MULTEQ, */
|
||||
@@ -295,7 +295,7 @@ PHB_EXPR hb_compExprNewDouble( double dValue, HB_BYTE ucWidth, HB_BYTE ucDec,
|
||||
{
|
||||
PHB_EXPR pExpr;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewDouble(%f, %i, %p)", dValue, ucDec, HB_COMP_PARAM ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewDouble(%f, %i, %p)", dValue, ucDec, ( void * ) HB_COMP_PARAM ) );
|
||||
|
||||
pExpr = HB_COMP_EXPR_NEW( HB_ET_NUMERIC );
|
||||
|
||||
@@ -312,7 +312,7 @@ PHB_EXPR hb_compExprNewLong( HB_MAXINT nValue, HB_COMP_DECL )
|
||||
{
|
||||
PHB_EXPR pExpr;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewLong(%" PFHL "d, %p)", nValue, HB_COMP_PARAM ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewLong(%" PFHL "d, %p)", nValue, ( void * ) HB_COMP_PARAM ) );
|
||||
|
||||
pExpr = HB_COMP_EXPR_NEW( HB_ET_NUMERIC );
|
||||
|
||||
@@ -329,7 +329,7 @@ PHB_EXPR hb_compExprNewDate( long lDate, HB_COMP_DECL )
|
||||
{
|
||||
PHB_EXPR pExpr;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewDate(%ld, %p)", lDate, HB_COMP_PARAM ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewDate(%ld, %p)", lDate, ( void * ) HB_COMP_PARAM ) );
|
||||
|
||||
pExpr = HB_COMP_EXPR_NEW( HB_ET_DATE );
|
||||
|
||||
@@ -344,7 +344,7 @@ PHB_EXPR hb_compExprNewTimeStamp( long lDate, long lTime, HB_COMP_DECL )
|
||||
{
|
||||
PHB_EXPR pExpr;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewTimeStamp(%ld, %ld, %p)", lDate, lTime, HB_COMP_PARAM ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewTimeStamp(%ld, %ld, %p)", lDate, lTime, ( void * ) HB_COMP_PARAM ) );
|
||||
|
||||
pExpr = HB_COMP_EXPR_NEW( HB_ET_TIMESTAMP );
|
||||
|
||||
@@ -454,7 +454,7 @@ PHB_EXPR hb_compExprNewCodeBlock( char * string, HB_SIZE nLen, int iFlags, HB_CO
|
||||
{
|
||||
PHB_EXPR pExpr;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewCodeBlock(%s,%" HB_PFS "u,%d,%p)", string, nLen, iFlags, HB_COMP_PARAM ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewCodeBlock(%s,%" HB_PFS "u,%d,%p)", string, nLen, iFlags, ( void * ) HB_COMP_PARAM ) );
|
||||
|
||||
pExpr = HB_COMP_EXPR_NEW( HB_ET_CODEBLOCK );
|
||||
|
||||
@@ -489,7 +489,7 @@ PHB_EXPR hb_compExprNewLogical( int iValue, HB_COMP_DECL )
|
||||
{
|
||||
PHB_EXPR pExpr;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewLogical(%i,%p)", iValue, HB_COMP_PARAM ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewLogical(%i,%p)", iValue, ( void * ) HB_COMP_PARAM ) );
|
||||
|
||||
pExpr = HB_COMP_EXPR_NEW( HB_ET_LOGICAL );
|
||||
|
||||
@@ -504,7 +504,7 @@ PHB_EXPR hb_compExprNewNil( HB_COMP_DECL )
|
||||
{
|
||||
PHB_EXPR pExpr;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewNil(%p)", HB_COMP_PARAM ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewNil(%p)", ( void * ) HB_COMP_PARAM ) );
|
||||
|
||||
pExpr = HB_COMP_EXPR_NEW( HB_ET_NIL );
|
||||
|
||||
@@ -516,7 +516,7 @@ PHB_EXPR hb_compExprNewSelf( HB_COMP_DECL )
|
||||
{
|
||||
PHB_EXPR pExpr;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewSelf(%p)", HB_COMP_PARAM ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewSelf(%p)", ( void * ) HB_COMP_PARAM ) );
|
||||
|
||||
pExpr = HB_COMP_EXPR_NEW( HB_ET_SELF );
|
||||
|
||||
@@ -528,7 +528,7 @@ PHB_EXPR hb_compExprNewVarRef( const char * szVarName, HB_COMP_DECL )
|
||||
{
|
||||
PHB_EXPR pExpr;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewVarRef(%s,%p)", szVarName, HB_COMP_PARAM ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewVarRef(%s,%p)", szVarName, ( void * ) HB_COMP_PARAM ) );
|
||||
|
||||
pExpr = HB_COMP_EXPR_NEW( HB_ET_VARREF );
|
||||
|
||||
@@ -541,7 +541,7 @@ PHB_EXPR hb_compExprNewFunRef( const char * szFunName, HB_COMP_DECL )
|
||||
{
|
||||
PHB_EXPR pExpr;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewFunRef(%s,%p)", szFunName, HB_COMP_PARAM ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewFunRef(%s,%p)", szFunName, ( void * ) HB_COMP_PARAM ) );
|
||||
|
||||
pExpr = HB_COMP_EXPR_NEW( HB_ET_FUNREF );
|
||||
|
||||
@@ -556,7 +556,7 @@ PHB_EXPR hb_compExprNewRef( PHB_EXPR pRefer, HB_COMP_DECL )
|
||||
{
|
||||
PHB_EXPR pExpr;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewRef(%p,%p)", pRefer, HB_COMP_PARAM ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewRef(%p,%p)", ( void * ) pRefer, ( void * ) HB_COMP_PARAM ) );
|
||||
|
||||
pExpr = HB_COMP_EXPR_NEW( HB_ET_REFERENCE );
|
||||
|
||||
@@ -669,7 +669,7 @@ PHB_EXPR hb_compExprNewSend( const char * szMessage, HB_COMP_DECL )
|
||||
{
|
||||
PHB_EXPR pExpr;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewSend(%s,%p)", szMessage, HB_COMP_PARAM ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewSend(%s,%p)", szMessage, ( void * ) HB_COMP_PARAM ) );
|
||||
|
||||
pExpr = HB_COMP_EXPR_NEW( HB_ET_SEND );
|
||||
pExpr->value.asMessage.pObject = NULL;
|
||||
@@ -690,7 +690,7 @@ PHB_EXPR hb_compExprNewMacroSend( PHB_EXPR pMessage, HB_COMP_DECL )
|
||||
{
|
||||
PHB_EXPR pExpr;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewMacroSend(%p,%p)", pMessage, HB_COMP_PARAM ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewMacroSend(%p,%p)", ( void * ) pMessage, ( void * ) HB_COMP_PARAM ) );
|
||||
|
||||
pExpr = HB_COMP_EXPR_NEW( HB_ET_SEND );
|
||||
pExpr->value.asMessage.pObject = NULL;
|
||||
@@ -715,12 +715,12 @@ PHB_EXPR hb_compExprNewMacroSend( PHB_EXPR pMessage, HB_COMP_DECL )
|
||||
/* Set object in send expression
|
||||
* pObject : pExpr
|
||||
*
|
||||
* pExpr = is an expression returned by hb_compExprNewSend
|
||||
* pExpr = is an expression returned by hb_compExprNewSend()
|
||||
* pObject = is an object
|
||||
*/
|
||||
PHB_EXPR hb_compExprNewMethodObject( PHB_EXPR pExpr, PHB_EXPR pObject )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewMethodObject(%p,%p)", pExpr, pObject ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewMethodObject(%p,%p)", ( void * ) pExpr, ( void * ) pObject ) );
|
||||
|
||||
pExpr->value.asMessage.pObject = pObject;
|
||||
|
||||
@@ -730,7 +730,7 @@ PHB_EXPR hb_compExprNewMethodObject( PHB_EXPR pExpr, PHB_EXPR pObject )
|
||||
/* Creates new method call
|
||||
* pObject : identifier ( pArgList )
|
||||
*
|
||||
* pObject = is an expression returned by hb_compExprNewSend
|
||||
* pObject = is an expression returned by hb_compExprNewSend()
|
||||
* pArgList = list of passed arguments - it will be HB_ET_NONE if no arguments
|
||||
* are passed
|
||||
*/
|
||||
@@ -741,7 +741,7 @@ PHB_EXPR hb_compExprNewMethodCall( PHB_EXPR pObject, PHB_EXPR pArgList )
|
||||
return pObject;
|
||||
}
|
||||
|
||||
/* Create a new IIF() expression
|
||||
/* Create a new iif() expression
|
||||
* pExpr is a list of three expressions
|
||||
*/
|
||||
PHB_EXPR hb_compExprNewIIF( PHB_EXPR pExpr )
|
||||
@@ -818,7 +818,7 @@ PHB_EXPR hb_compExprNewVar( const char * szName, HB_COMP_DECL )
|
||||
{
|
||||
PHB_EXPR pExpr;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewVar(%s,%p)", szName, HB_COMP_PARAM ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewVar(%s,%p)", szName, ( void * ) HB_COMP_PARAM ) );
|
||||
|
||||
pExpr = HB_COMP_EXPR_NEW( HB_ET_VARIABLE );
|
||||
pExpr->value.asSymbol.name = szName;
|
||||
@@ -835,7 +835,7 @@ PHB_EXPR hb_compExprNewRTVar( const char * szName, PHB_EXPR pMacroVar,
|
||||
{
|
||||
PHB_EXPR pExpr;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewRTVar(%s, %p, %p)", szName, pMacroVar, HB_COMP_PARAM ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewRTVar(%s, %p, %p)", szName, ( void * ) pMacroVar, ( void * ) HB_COMP_PARAM ) );
|
||||
|
||||
pExpr = HB_COMP_EXPR_NEW( HB_ET_RTVAR );
|
||||
pExpr->value.asRTVar.szName = szName;
|
||||
@@ -851,7 +851,7 @@ PHB_EXPR hb_compExprNewFunName( const char * szName, HB_COMP_DECL )
|
||||
{
|
||||
PHB_EXPR pExpr;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewFunName(%s,%p)", szName, HB_COMP_PARAM ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewFunName(%s,%p)", szName, ( void * ) HB_COMP_PARAM ) );
|
||||
|
||||
pExpr = HB_COMP_EXPR_NEW( HB_ET_FUNNAME );
|
||||
pExpr->value.asSymbol.name = hb_compGetFuncID( szName,
|
||||
@@ -866,7 +866,7 @@ PHB_EXPR hb_compExprNewAlias( const char * szName, HB_COMP_DECL )
|
||||
{
|
||||
PHB_EXPR pExpr;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewAlias(%s,%p)", szName, HB_COMP_PARAM ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewAlias(%s,%p)", szName, ( void * ) HB_COMP_PARAM ) );
|
||||
|
||||
pExpr = HB_COMP_EXPR_NEW( HB_ET_ALIAS );
|
||||
pExpr->value.asSymbol.name = szName;
|
||||
@@ -1251,7 +1251,7 @@ PHB_EXPR hb_compExprSetOperand( PHB_EXPR pExpr, PHB_EXPR pItem, HB_COMP_DECL )
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Left operator has the same or higer precedence then the right one
|
||||
/* Left operator has the same or higher precedence then the right one
|
||||
* e.g. a * b + c
|
||||
* pItem -> b + c -> L=b R=c O=+
|
||||
* pExpr -> a * -> l=a r= o=*
|
||||
@@ -1355,10 +1355,11 @@ HB_BOOL hb_compExprIsArrayToParams( PHB_EXPR pExpr )
|
||||
|
||||
HB_SIZE hb_compExprParamListCheck( HB_COMP_DECL, PHB_EXPR pExpr )
|
||||
{
|
||||
HB_SIZE nLen = 0, nItems = 0;
|
||||
HB_SIZE nLen = 0;
|
||||
|
||||
if( pExpr )
|
||||
{
|
||||
HB_SIZE nItems = 0;
|
||||
PHB_EXPR pElem;
|
||||
|
||||
pElem = pExpr->value.asList.pExprList;
|
||||
@@ -1466,11 +1467,9 @@ PHB_EXPR hb_compExprCBVarAdd( PHB_EXPR pCB, const char * szVarName, HB_BYTE bTyp
|
||||
*/
|
||||
void hb_compExprCBVarDel( PHB_CBVAR pVars )
|
||||
{
|
||||
PHB_CBVAR pDel;
|
||||
|
||||
while( pVars )
|
||||
{
|
||||
pDel = pVars;
|
||||
PHB_CBVAR pDel = pVars;
|
||||
pVars = pVars->pNext;
|
||||
hb_xfree( pDel );
|
||||
}
|
||||
@@ -1478,7 +1477,7 @@ void hb_compExprCBVarDel( PHB_CBVAR pVars )
|
||||
|
||||
/* Creates a set/get codeblock for passed expression used in __GET
|
||||
*
|
||||
* {| ~1 | IIF( ~1 == NIL, <pExpr>, <pExpr> := ~1 ) }
|
||||
* {| ~1 | iif( ~1 == NIL, <pExpr>, <pExpr> := ~1 ) }
|
||||
*
|
||||
* NOTE: "~1" is not a valid variable name so there will be no collisions
|
||||
*/
|
||||
|
||||
@@ -158,16 +158,14 @@ PHB_EXPR hb_compExprReduceMod( PHB_EXPR pSelf, HB_COMP_DECL )
|
||||
default:
|
||||
if( HB_SUPPORT_HARBOUR )
|
||||
{
|
||||
double dValue, dDivisor;
|
||||
|
||||
dDivisor = pRight->value.asNum.NumType == HB_ET_LONG ?
|
||||
( double ) pRight->value.asNum.val.l :
|
||||
pRight->value.asNum.val.d;
|
||||
double dDivisor = pRight->value.asNum.NumType == HB_ET_LONG ?
|
||||
( double ) pRight->value.asNum.val.l :
|
||||
pRight->value.asNum.val.d;
|
||||
if( dDivisor )
|
||||
{
|
||||
dValue = pLeft->value.asNum.NumType == HB_ET_LONG ?
|
||||
( double ) pLeft->value.asNum.val.l :
|
||||
pLeft->value.asNum.val.d;
|
||||
double dValue = pLeft->value.asNum.NumType == HB_ET_LONG ?
|
||||
( double ) 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;
|
||||
@@ -986,7 +984,7 @@ PHB_EXPR hb_compExprReduceIN( PHB_EXPR pSelf, HB_COMP_DECL )
|
||||
/* Both arguments are literal strings
|
||||
*/
|
||||
|
||||
/* NOTE: If macro substitiution is not didabled (-kM compiler
|
||||
/* NOTE: If macro substitution is not disabled (-kM compiler
|
||||
* switch) then we cannot reduce also strings which
|
||||
* have macro operator '&'
|
||||
*/
|
||||
@@ -1004,7 +1002,7 @@ PHB_EXPR hb_compExprReduceIN( PHB_EXPR pSelf, HB_COMP_DECL )
|
||||
* 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)
|
||||
* not enabled f.e. in strict Clipper compatible mode (-kc)
|
||||
* [druzus]
|
||||
*/
|
||||
if( pLeft->nLength == 0 )
|
||||
@@ -1055,7 +1053,7 @@ PHB_EXPR hb_compExprReduceNE( PHB_EXPR pSelf, HB_COMP_DECL )
|
||||
|
||||
case HB_ET_STRING:
|
||||
/* NOTE: the result depends on SET EXACT setting then it
|
||||
* cannot be optimized except the case when NULL string are
|
||||
* cannot be optimized except the case when null strings are
|
||||
* compared - "" != "" is always HB_FALSE regardless of EXACT
|
||||
* setting
|
||||
*/
|
||||
@@ -1575,10 +1573,10 @@ PHB_EXPR hb_compExprReduceEQ( PHB_EXPR pSelf, HB_COMP_DECL )
|
||||
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
|
||||
* cannot be optimized except the case when null strings are
|
||||
* compared - "" = "" is always TRUE regardless of EXACT
|
||||
* setting.
|
||||
* If macro substitiution is not didabled (-kM compiler
|
||||
* If macro substitution is not disabled (-kM compiler
|
||||
* switch) then we cannot reduce also strings which
|
||||
* have macro operator '&'
|
||||
*/
|
||||
@@ -1899,8 +1897,8 @@ PHB_EXPR hb_compExprReduceIIF( PHB_EXPR pSelf, HB_COMP_DECL )
|
||||
/* store the TRUE expression as a result of reduction
|
||||
*/
|
||||
pSelf = pExpr;
|
||||
pExpr = pExpr->pNext; /* skip to HB_FALSE expression */
|
||||
HB_COMP_EXPR_FREE( pExpr ); /* delete HB_FALSE expr */
|
||||
pExpr = pExpr->pNext; /* skip to FALSE expression */
|
||||
HB_COMP_EXPR_FREE( pExpr ); /* delete FALSE expression */
|
||||
pSelf->pNext = NULL;
|
||||
}
|
||||
else
|
||||
@@ -1917,10 +1915,10 @@ PHB_EXPR hb_compExprReduceIIF( PHB_EXPR pSelf, HB_COMP_DECL )
|
||||
*/
|
||||
pSelf->value.asList.pExprList = NULL;
|
||||
HB_COMP_EXPR_FREE( pSelf );
|
||||
/* store the HB_FALSE expression as a result of reduction
|
||||
/* store the FALSE expression as a result of reduction
|
||||
*/
|
||||
pSelf = pExpr->pNext;
|
||||
HB_COMP_EXPR_FREE( pExpr ); /* delete TRUE expr */
|
||||
HB_COMP_EXPR_FREE( pExpr ); /* delete TRUE expression */
|
||||
pSelf->pNext = NULL;
|
||||
}
|
||||
|
||||
@@ -1981,17 +1979,18 @@ HB_BOOL hb_compExprReduceAT( PHB_EXPR pSelf, HB_COMP_DECL )
|
||||
PHB_EXPR pParms = pSelf->value.asFunCall.pParms;
|
||||
PHB_EXPR pSub = pParms->value.asList.pExprList;
|
||||
PHB_EXPR pText = pSub->pNext;
|
||||
PHB_EXPR pReduced;
|
||||
|
||||
if( pSub->ExprType == HB_ET_STRING && pText->ExprType == HB_ET_STRING &&
|
||||
! HB_SUPPORT_USERCP )
|
||||
{
|
||||
PHB_EXPR pReduced;
|
||||
|
||||
/* NOTE: CA-Cl*pper has a bug in At( "", cText ) compile time
|
||||
* optimization and always set 1 as result in such cses.
|
||||
* optimization and always set 1 as result in such cases.
|
||||
* 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)
|
||||
* not enabled f.e. in strict Clipper compatible mode (-kc)
|
||||
* [druzus]
|
||||
*/
|
||||
if( pSub->nLength == 0 )
|
||||
@@ -2042,12 +2041,12 @@ HB_BOOL hb_compExprReduceCHR( PHB_EXPR pSelf, HB_COMP_DECL )
|
||||
/* 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]
|
||||
* 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)
|
||||
* not enabled f.e. in strict Clipper compatible mode (-kc)
|
||||
* [druzus]
|
||||
*/
|
||||
|
||||
@@ -2121,7 +2120,7 @@ HB_BOOL hb_compExprReduceLEN( PHB_EXPR pSelf, HB_COMP_DECL )
|
||||
PHB_EXPR pParms = pSelf->value.asFunCall.pParms;
|
||||
PHB_EXPR pArg = pParms->value.asList.pExprList;
|
||||
|
||||
/* TOFIX: do not optimize when array/hash args have user expressions */
|
||||
/* FIXME: do not optimize when array/hash args have user expressions */
|
||||
if( ( pArg->ExprType == HB_ET_STRING && ! HB_SUPPORT_USERCP ) ||
|
||||
pArg->ExprType == HB_ET_ARRAY ||
|
||||
pArg->ExprType == HB_ET_HASH )
|
||||
@@ -2152,7 +2151,7 @@ HB_BOOL hb_compExprReduceEMPTY( PHB_EXPR pSelf, HB_COMP_DECL )
|
||||
|
||||
case HB_ET_ARRAY:
|
||||
case HB_ET_HASH:
|
||||
/* TOFIX: do not optimize when array/hash args have user expressions */
|
||||
/* FIXME: do not optimize when array/hash args have user expressions */
|
||||
fResult = pArg->nLength == 0;
|
||||
break;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* get function identifier
|
||||
* Get function identifier
|
||||
*
|
||||
* Copyright 2010 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
*
|
||||
|
||||
@@ -68,12 +68,11 @@
|
||||
void hb_put_ieee754( HB_BYTE * ptr, double d )
|
||||
{
|
||||
int iExp, iSig;
|
||||
double df;
|
||||
|
||||
#if defined( HB_LONG_LONG_OFF )
|
||||
HB_U32 l1, l2;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_put_ieee754(%p, %f)", ptr, d ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_put_ieee754(%p, %f)", ( void * ) ptr, d ) );
|
||||
|
||||
iSig = d < 0 ? 1 : 0;
|
||||
if( d == 0.0 )
|
||||
@@ -82,7 +81,7 @@ void hb_put_ieee754( HB_BYTE * ptr, double d )
|
||||
}
|
||||
else
|
||||
{
|
||||
df = frexp( iSig ? -d : d, &iExp );
|
||||
double df = frexp( iSig ? -d : d, &iExp );
|
||||
l1 = ( HB_U32 ) ldexp( df, HB_MANTISSA_BITS + 1 );
|
||||
l2 = ( HB_U32 ) ldexp( df, HB_MANTISSA_BITS + 1 - 32 ) &
|
||||
( ( ( HB_U32 ) 1 << ( HB_MANTISSA_BITS - 32 ) ) - 1 );
|
||||
@@ -95,7 +94,7 @@ void hb_put_ieee754( HB_BYTE * ptr, double d )
|
||||
#else
|
||||
HB_U64 ll;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_put_ieee754(%p, %f)", ptr, d ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_put_ieee754(%p, %f)", ( void * ) ptr, d ) );
|
||||
|
||||
iSig = d < 0 ? 1 : 0;
|
||||
if( d == 0.0 )
|
||||
@@ -104,7 +103,7 @@ void hb_put_ieee754( HB_BYTE * ptr, double d )
|
||||
}
|
||||
else
|
||||
{
|
||||
df = frexp( iSig ? -d : d, &iExp );
|
||||
double df = frexp( iSig ? -d : d, &iExp );
|
||||
ll = ( HB_U64 ) ldexp( df, HB_MANTISSA_BITS + 1 ) & HB_MANTISSA_MASK;
|
||||
ll |= ( HB_U64 ) ( ( iExp + HB_EXPONENT_ADD - 1 ) & HB_EXPONENT_MASK ) <<
|
||||
HB_MANTISSA_BITS;
|
||||
@@ -122,7 +121,7 @@ double hb_get_ieee754( const HB_BYTE * ptr )
|
||||
HB_U32 l1, l2;
|
||||
double d;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_get_ieee754(%p)", ptr ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_get_ieee754(%p)", ( const void * ) ptr ) );
|
||||
|
||||
l1 = HB_GET_LE_UINT32( ptr );
|
||||
l2 = HB_GET_LE_UINT32( ptr + 4 );
|
||||
@@ -138,7 +137,7 @@ double hb_get_ieee754( const HB_BYTE * ptr )
|
||||
#else
|
||||
HB_U64 ll;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_get_ieee754(%p)", ptr ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_get_ieee754(%p)", ( const void * ) ptr ) );
|
||||
|
||||
ll = HB_GET_LE_UINT64( ptr );
|
||||
iSig = ( int ) ( ll >> ( HB_MANTISSA_BITS + HB_EXPONENT_BITS ) ) & 1;
|
||||
@@ -158,10 +157,9 @@ double hb_get_ieee754( const HB_BYTE * ptr )
|
||||
void hb_put_ord_ieee754( HB_BYTE * ptr, double d )
|
||||
{
|
||||
int iExp, iSig;
|
||||
double df;
|
||||
HB_U32 l1, l2;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_put_ord_ieee754(%p, %f)", ptr, d ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_put_ord_ieee754(%p, %f)", ( void * ) ptr, d ) );
|
||||
|
||||
iSig = d < 0 ? 1 : 0;
|
||||
if( d == 0.0 )
|
||||
@@ -170,7 +168,7 @@ void hb_put_ord_ieee754( HB_BYTE * ptr, double d )
|
||||
}
|
||||
else
|
||||
{
|
||||
df = frexp( iSig ? -d : d, &iExp );
|
||||
double df = frexp( iSig ? -d : d, &iExp );
|
||||
l1 = ( HB_U32 ) ldexp( df, HB_MANTISSA_BITS + 1 );
|
||||
l2 = ( HB_U32 ) ldexp( df, HB_MANTISSA_BITS + 1 - 32 ) &
|
||||
( ( ( HB_U32 ) 1 << ( HB_MANTISSA_BITS - 32 ) ) - 1 );
|
||||
@@ -196,7 +194,7 @@ double hb_get_ord_ieee754( const HB_BYTE * ptr )
|
||||
HB_U32 l1, l2;
|
||||
double d;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_get_ord_ieee754(%p)", ptr ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_get_ord_ieee754(%p)", ( const void * ) ptr ) );
|
||||
|
||||
l1 = HB_GET_BE_UINT32( ptr + 4 );
|
||||
l2 = HB_GET_BE_UINT32( ptr );
|
||||
@@ -218,12 +216,12 @@ double hb_get_ord_ieee754( const HB_BYTE * ptr )
|
||||
|
||||
/*
|
||||
* I added function hb_get_rev_double() and hb_get_std_double() because
|
||||
* some compilers does not like constraction used by in HB_GET_LE_DOUBLE
|
||||
* some compilers does not like construction used by in HB_GET_LE_DOUBLE()
|
||||
* macro => d = { ... }
|
||||
*/
|
||||
double hb_get_rev_double( const HB_BYTE * ptr )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_get_rev_double(%p)", ptr ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_get_rev_double(%p)", ( const void * ) ptr ) );
|
||||
|
||||
{
|
||||
#if defined( __GNUC__ )
|
||||
@@ -251,7 +249,7 @@ double hb_get_rev_double( const HB_BYTE * ptr )
|
||||
|
||||
double hb_get_std_double( const HB_BYTE * ptr )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_get_std_double(%p)", ptr ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_get_std_double(%p)", ( const void * ) ptr ) );
|
||||
|
||||
{
|
||||
#if defined( __GNUC__ )
|
||||
@@ -289,7 +287,7 @@ double hb_get_le_uint64( const HB_BYTE * ptr )
|
||||
{
|
||||
HB_U32 l1, l2;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_get_le_uint64(%p)", ptr ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_get_le_uint64(%p)", ( const void * ) ptr ) );
|
||||
|
||||
l1 = HB_GET_LE_UINT32( ptr );
|
||||
l2 = HB_GET_LE_UINT32( ptr + 4 );
|
||||
@@ -301,7 +299,7 @@ double hb_get_le_int64( const HB_BYTE * ptr )
|
||||
HB_U32 l1;
|
||||
HB_I32 l2;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_get_le_int64(%p)", ptr ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_get_le_int64(%p)", ( const void * ) ptr ) );
|
||||
|
||||
l1 = HB_GET_LE_UINT32( ptr );
|
||||
l2 = HB_GET_LE_INT32( ptr + 4 );
|
||||
@@ -312,7 +310,7 @@ void hb_put_le_uint64( const HB_BYTE * ptr, double d )
|
||||
{
|
||||
HB_U32 l1, l2;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_put_le_uint64(%p)", ptr ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_put_le_uint64(%p)", ( const void * ) ptr ) );
|
||||
|
||||
l1 = ( HB_U32 ) ( d );
|
||||
l2 = ( HB_U32 ) ( d / 4294967296.0 );
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
* The Date conversion module
|
||||
*
|
||||
* Copyright 1999 Antonio Linares <alinares@fivetech.com>
|
||||
* Copyright 1999-2001 Viktor Szakats (vszakats.net/harbour)
|
||||
* (hb_dateEncStr(), hb_dateDecStr(), hb_dateStrPut(), hb_dateStrGet())
|
||||
* Copyright 1999 Jose Lalin <dezac@corevia.com> (hb_dateDOW())
|
||||
* Copyright 2009 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* (time/timestamp functions)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -44,25 +49,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* The following parts are Copyright of the individual authors.
|
||||
*
|
||||
* Copyright 1999-2001 Viktor Szakats (vszakats.net/harbour)
|
||||
* hb_dateEncStr()
|
||||
* hb_dateDecStr()
|
||||
* hb_dateStrPut()
|
||||
* hb_dateStrGet()
|
||||
*
|
||||
* Copyright 1999 Jose Lalin <dezac@corevia.com>
|
||||
* hb_dateDOW()
|
||||
*
|
||||
* Copyright 2009 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* time/timestamp functions
|
||||
*
|
||||
* See COPYING.txt for licensing terms.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbdate.h"
|
||||
#if defined( HB_LONG_LONG_OFF )
|
||||
@@ -104,7 +90,7 @@ void hb_timeStampGetLocal( int * piYear, int * piMonth, int * piDay,
|
||||
int * piHour, int * piMinutes,
|
||||
int * piSeconds, int * piMSec )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStampGetLocal(%p,%p,%p,%p,%p,%p,%p)", piYear, piMonth, piDay, piHour, piMinutes, piSeconds, piMSec ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStampGetLocal(%p,%p,%p,%p,%p,%p,%p)", ( void * ) piYear, ( void * ) piMonth, ( void * ) piDay, ( void * ) piHour, ( void * ) piMinutes, ( void * ) piSeconds, ( void * ) piMSec ) );
|
||||
|
||||
#if defined( HB_OS_WIN )
|
||||
{
|
||||
@@ -154,7 +140,7 @@ void hb_timeStampGetLocal( int * piYear, int * piMonth, int * piDay,
|
||||
#endif
|
||||
}
|
||||
|
||||
/* return UTC julian timestamp in milliseconds */
|
||||
/* return UTC Julian timestamp in milliseconds */
|
||||
HB_MAXUINT hb_dateMilliSeconds( void )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_dateMilliSeconds()" ) );
|
||||
@@ -191,7 +177,7 @@ void hb_timeStampGet( long * plJulian, long * plMilliSec )
|
||||
{
|
||||
int iYear, iMonth, iDay, iHour, iMinute, iSeconds, iMillisec;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStampGet(%p,%p)", plJulian, plMilliSec ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStampGet(%p,%p)", ( void * ) plJulian, ( void * ) plMilliSec ) );
|
||||
|
||||
hb_timeStampGetLocal( &iYear, &iMonth, &iDay,
|
||||
&iHour, &iMinute, &iSeconds, &iMillisec );
|
||||
@@ -241,7 +227,7 @@ long hb_dateEncode( int iYear, int iMonth, int iDay )
|
||||
|
||||
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 ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_dateDecode(%ld, %p, %p, %p)", lJulian, ( void * ) piYear, ( void * ) piMonth, ( void * ) piDay ) );
|
||||
|
||||
if( lJulian >= HB_STR_DATE_BASE )
|
||||
{
|
||||
@@ -270,7 +256,7 @@ void hb_dateDecode( long lJulian, int * piYear, int * piMonth, int * piDay )
|
||||
|
||||
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 ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_dateStrPut(%p, %d, %d, %d)", ( void * ) szDate, iYear, iMonth, iDay ) );
|
||||
|
||||
if( iYear >= 0 && iMonth > 0 && iDay > 0 )
|
||||
{
|
||||
@@ -293,7 +279,7 @@ void hb_dateStrPut( char * szDate, int iYear, int iMonth, int iDay )
|
||||
|
||||
void hb_dateStrGet( const char * szDate, int * piYear, int * piMonth, int * piDay )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_dateStrGet(%.8s, %p, %p, %p)", szDate, piYear, piMonth, piDay ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_dateStrGet(%.8s, %p, %p, %p)", szDate, ( void * ) piYear, ( void * ) piMonth, ( void * ) piDay ) );
|
||||
|
||||
#if defined( HB_CLP_STRICT ) || 1
|
||||
if( szDate )
|
||||
@@ -333,7 +319,7 @@ char * hb_dateDecStr( char * szDate, long lJulian )
|
||||
{
|
||||
int iYear, iMonth, iDay;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_dateDecStr(%p, %ld)", szDate, lJulian ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_dateDecStr(%p, %ld)", ( void * ) szDate, lJulian ) );
|
||||
|
||||
if( lJulian <= 0 )
|
||||
{
|
||||
@@ -372,7 +358,7 @@ int hb_dateJulianDOW( long lJulian )
|
||||
|
||||
HB_BOOL hb_dateDecWeek( long lJulian, int * piYear, int * piWeek, int * piDay )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_dateDecWeek(%ld,%p,%p,%p)", lJulian, piYear, piWeek, piDay ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_dateDecWeek(%ld,%p,%p,%p)", lJulian, ( void * ) piYear, ( void * ) piWeek, ( void * ) piDay ) );
|
||||
|
||||
if( lJulian >= HB_STR_DATE_BASE )
|
||||
{
|
||||
@@ -426,7 +412,7 @@ void hb_dateToday( int * piYear, int * piMonth, int * piDay )
|
||||
{
|
||||
int iHour, iMinute, iSeconds, iMillisec;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_dateToday(%p,%p,%p)", piYear, piMonth, piDay ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_dateToday(%p,%p,%p)", ( void * ) piYear, ( void * ) piMonth, ( void * ) piDay ) );
|
||||
|
||||
hb_timeStampGetLocal( piYear, piMonth, piDay,
|
||||
&iHour, &iMinute, &iSeconds, &iMillisec );
|
||||
@@ -438,7 +424,7 @@ void hb_dateTimeStr( char * pszTime )
|
||||
{
|
||||
int iYear, iMonth, iDay, iHour, iMinute, iSeconds, iMillisec;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_dateTimeStr(%p)", pszTime ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_dateTimeStr(%p)", ( void * ) pszTime ) );
|
||||
|
||||
hb_timeStampGetLocal( &iYear, &iMonth, &iDay,
|
||||
&iHour, &iMinute, &iSeconds, &iMillisec );
|
||||
@@ -470,7 +456,7 @@ long hb_timeEncode( int iHour, int iMinutes, int iSeconds, int iMSec )
|
||||
void hb_timeDecode( long lMilliSec, int * piHour, int * piMinutes,
|
||||
int * piSeconds, int * piMSec )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeDecode(%ld, %p, %p, %p, %p)", lMilliSec, piHour, piMinutes, piSeconds, piMSec ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeDecode(%ld, %p, %p, %p, %p)", lMilliSec, ( void * ) piHour, ( void * ) piMinutes, ( void * ) piSeconds, ( void * ) piMSec ) );
|
||||
|
||||
if( lMilliSec <= 0 )
|
||||
{
|
||||
@@ -498,7 +484,7 @@ char * hb_timeStr( char * szTime, long lMilliSec )
|
||||
{
|
||||
int iHour, iMinutes, iSeconds, iMSec;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStr(%p, %ld)", szTime, lMilliSec ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStr(%p, %ld)", ( void * ) szTime, lMilliSec ) );
|
||||
|
||||
hb_timeDecode( lMilliSec, &iHour, &iMinutes, &iSeconds, &iMSec );
|
||||
hb_snprintf( szTime, 13, "%02d:%02d:%02d.%03d",
|
||||
@@ -514,7 +500,7 @@ HB_BOOL hb_timeStrGet( const char * szTime,
|
||||
int iHour, iMinutes, iSeconds, iMSec, iBlocks;
|
||||
HB_BOOL fValid;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStrGet(%s, %p, %p, %p, %p)", szTime, piHour, piMinutes, piSeconds, piMSec ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStrGet(%s, %p, %p, %p, %p)", szTime, ( void * ) piHour, ( void * ) piMinutes, ( void * ) piSeconds, ( void * ) piMSec ) );
|
||||
|
||||
iHour = iMinutes = iSeconds = iMSec = iBlocks = 0;
|
||||
fValid = HB_FALSE;
|
||||
@@ -607,7 +593,7 @@ void hb_timeStrRawGet( const char * szTime,
|
||||
int * piHour, int * piMinutes,
|
||||
int * piSeconds, int * piMSec )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStrRawGet(%.10s, %p, %p, %p, %p)", szTime, piHour, piMinutes, piSeconds, piMSec ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStrRawGet(%.10s, %p, %p, %p, %p)", szTime, ( void * ) piHour, ( void * ) piMinutes, ( void * ) piSeconds, ( void * ) piMSec ) );
|
||||
|
||||
*piHour = *piMinutes = *piSeconds = *piMSec = 0;
|
||||
|
||||
@@ -664,7 +650,7 @@ char * hb_timeStampStrRawPut( char * szDateTime, long lJulian, long lMilliSec )
|
||||
{
|
||||
int iYear, iMonth, iDay, iHour, iMinutes, iSeconds, iMSec;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStampStrRawPut(%p, %ld, %ld)", szDateTime, lJulian, lMilliSec ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStampStrRawPut(%p, %ld, %ld)", ( void * ) szDateTime, lJulian, lMilliSec ) );
|
||||
|
||||
hb_dateDecode( lJulian, &iYear, &iMonth, &iDay );
|
||||
hb_dateStrPut( szDateTime, iYear, iMonth, iDay );
|
||||
@@ -679,7 +665,7 @@ void hb_timeStampStrRawGet( const char * szDateTime, long * plJulian, long * plM
|
||||
{
|
||||
int iYear, iMonth, iDay, iHour, iMinutes, iSeconds, iMSec, iLen;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStampStrRawGet(%s, %p, %p)", szDateTime, plJulian, plMilliSec ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStampStrRawGet(%s, %p, %p)", szDateTime, ( void * ) plJulian, ( void * ) plMilliSec ) );
|
||||
|
||||
*plJulian = *plMilliSec = 0;
|
||||
|
||||
@@ -710,7 +696,7 @@ char * hb_timeStampStr( char * szDateTime, long lJulian, long lMilliSec )
|
||||
{
|
||||
int iYear, iMonth, iDay, iHour, iMinutes, iSeconds, iMSec;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStampStr(%p, %ld, %ld)", szDateTime, lJulian, lMilliSec ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStampStr(%p, %ld, %ld)", ( void * ) szDateTime, lJulian, lMilliSec ) );
|
||||
|
||||
hb_dateDecode( lJulian, &iYear, &iMonth, &iDay );
|
||||
hb_timeDecode( lMilliSec, &iHour, &iMinutes, &iSeconds, &iMSec );
|
||||
@@ -729,7 +715,7 @@ HB_BOOL hb_timeStampStrGet( const char * szDateTime,
|
||||
int iYear, iMonth, iDay;
|
||||
HB_BOOL fValid;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStampStrGet(%s, %p, %p, %p, %p, %p, %p, %p)", szDateTime, piYear, piMonth, piDay, piHour, piMinutes, piSeconds, piMSec ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStampStrGet(%s, %p, %p, %p, %p, %p, %p, %p)", szDateTime, ( void * ) piYear, ( void * ) piMonth, ( void * ) piDay, ( void * ) piHour, ( void * ) piMinutes, ( void * ) piSeconds, ( void * ) piMSec ) );
|
||||
|
||||
iYear = iMonth = iDay = 0;
|
||||
fValid = HB_FALSE;
|
||||
@@ -854,7 +840,7 @@ HB_BOOL hb_timeStampStrGetDT( const char * szDateTime,
|
||||
int iYear, iMonth, iDay, iHour, iMinutes, iSeconds, iMSec;
|
||||
HB_BOOL fValid;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStampStrGetDT(%s, %p, %p)", szDateTime, plJulian, plMilliSec ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStampStrGetDT(%s, %p, %p)", szDateTime, ( void * ) plJulian, ( void * ) plMilliSec ) );
|
||||
|
||||
fValid = hb_timeStampStrGet( szDateTime, &iYear, &iMonth, &iDay,
|
||||
&iHour, &iMinutes, &iSeconds, &iMSec );
|
||||
@@ -877,7 +863,7 @@ double hb_timeStampPackDT( long lJulian, long lMilliSec )
|
||||
void hb_timeStampUnpackDT( double dTimeStamp,
|
||||
long * plJulian, long * plMilliSec )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStampUnpackDT(%f, %p, %p)", dTimeStamp, plJulian, plMilliSec ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStampUnpackDT(%f, %p, %p)", dTimeStamp, ( void * ) plJulian, ( void * ) plMilliSec ) );
|
||||
|
||||
{
|
||||
#if defined( HB_LONG_LONG_OFF )
|
||||
@@ -930,7 +916,7 @@ void hb_timeStampUnpack( double dTimeStamp,
|
||||
{
|
||||
long lJulian, lMilliSec;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStampUnpack(%f, %p, %p, %p, %p, %p, %p, %p)", dTimeStamp, piYear, piMonth, piDay, piHour, piMinutes, piSeconds, piMSec ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStampUnpack(%f, %p, %p, %p, %p, %p, %p, %p)", dTimeStamp, ( void * ) piYear, ( void * ) piMonth, ( void * ) piDay, ( void * ) piHour, ( void * ) piMinutes, ( void * ) piSeconds, ( void * ) piMSec ) );
|
||||
|
||||
hb_timeStampUnpackDT( dTimeStamp, &lJulian, &lMilliSec );
|
||||
hb_dateDecode( lJulian, piYear, piMonth, piDay );
|
||||
@@ -967,7 +953,7 @@ void hb_timeStampUnpackD( double dTimeStamp,
|
||||
long lJulian, lMilliSec;
|
||||
int iSeconds, iMSec;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStampUnpackD(%f, %p, %p, %p, %p, %p, %p)", dTimeStamp, piYear, piMonth, piDay, piHour, piMinutes, pdSeconds ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timeStampUnpackD(%f, %p, %p, %p, %p, %p, %p)", dTimeStamp, ( void * ) piYear, ( void * ) piMonth, ( void * ) piDay, ( void * ) piHour, ( void * ) piMinutes, ( void * ) pdSeconds ) );
|
||||
|
||||
hb_timeStampUnpackDT( dTimeStamp, &lJulian, &lMilliSec );
|
||||
hb_dateDecode( lJulian, piYear, piMonth, piDay );
|
||||
@@ -1187,7 +1173,7 @@ HB_MAXUINT hb_timerInit( HB_MAXINT nTimeOut )
|
||||
|
||||
HB_MAXINT hb_timerTest( HB_MAXINT nTimeOut, HB_MAXUINT * pnTimer )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timerTest(%" PFHL "d, %p)", nTimeOut, pnTimer ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_timerTest(%" PFHL "d, %p)", nTimeOut, ( void * ) pnTimer ) );
|
||||
|
||||
if( nTimeOut > 0 )
|
||||
{
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
#include "hbdate.h"
|
||||
#include "hb_io.h"
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
/* --- */
|
||||
|
||||
#if defined( HB_OS_DOS )
|
||||
|
||||
@@ -178,8 +178,8 @@
|
||||
#if defined( __USE_LARGEFILE64 )
|
||||
/*
|
||||
* The macro: __USE_LARGEFILE64 is set when _LARGEFILE64_SOURCE is
|
||||
* defined and effectively enables lseek64/flock64/ftruncate64 functions
|
||||
* on 32bit machines.
|
||||
* defined and effectively enables lseek64()/flock64()/ftruncate64()
|
||||
* functions on 32-bit machines.
|
||||
*/
|
||||
#define HB_USE_LARGEFILE64
|
||||
#elif defined( HB_OS_UNIX ) && defined( O_LARGEFILE )
|
||||
@@ -187,7 +187,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
/* --- */
|
||||
|
||||
HB_FATTR hb_fsAttrFromRaw( HB_FATTR raw_attr )
|
||||
{
|
||||
@@ -344,7 +344,7 @@ HB_FATTR hb_fsAttrToRaw( HB_FATTR nAttr )
|
||||
}
|
||||
|
||||
/* Converts a CA-Cl*pper compatible file attribute string
|
||||
to the internal reprensentation. */
|
||||
to the internal representation. */
|
||||
|
||||
HB_FATTR hb_fsAttrEncode( const char * szAttr )
|
||||
{
|
||||
@@ -352,7 +352,7 @@ HB_FATTR hb_fsAttrEncode( const char * szAttr )
|
||||
char ch;
|
||||
HB_FATTR nAttr = 0;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_fsAttrEncode(%p)", szAttr ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_fsAttrEncode(%p)", ( const void * ) szAttr ) );
|
||||
|
||||
while( ( ch = ( char ) HB_TOUPPER( *pos ) ) != '\0' )
|
||||
{
|
||||
@@ -382,7 +382,7 @@ char * hb_fsAttrDecode( HB_FATTR nAttr, char * szAttr )
|
||||
{
|
||||
char * ptr = szAttr;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_fsAttrDecode(%u, %p)", nAttr, szAttr ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_fsAttrDecode(%u, %p)", nAttr, ( void * ) szAttr ) );
|
||||
|
||||
/* Using the same order as CA-Cl*pper did: RHSVDA. */
|
||||
if( nAttr & HB_FA_READONLY ) *ptr++ = 'R';
|
||||
@@ -423,7 +423,7 @@ static HB_BOOL hb_fsFindNextLow( PHB_FFIND ffind )
|
||||
ffind->szName[ 0 ] = '\0';
|
||||
ffind->size = 0;
|
||||
|
||||
/* Do platform dependant first/next search */
|
||||
/* Do platform dependent first/next search */
|
||||
|
||||
hb_vmUnlock();
|
||||
|
||||
@@ -686,7 +686,7 @@ static HB_BOOL hb_fsFindNextLow( PHB_FFIND ffind )
|
||||
else
|
||||
{
|
||||
#if defined( __XCC__ ) || ( defined( __POCC__ ) && __POCC__ >= 500 )
|
||||
/* NOTE: PellesC 5.00.1 will go into an infinite loop if we don't
|
||||
/* NOTE: Pelles C 5.00.1 will go into an infinite loop if we don't
|
||||
split this into two operations. [vszakats] */
|
||||
ffind->size = ( HB_FOFFSET ) info->pFindFileData.nFileSizeLow;
|
||||
ffind->size += ( HB_FOFFSET ) info->pFindFileData.nFileSizeHigh << 32;
|
||||
@@ -964,7 +964,7 @@ void hb_fsFindClose( PHB_FFIND ffind )
|
||||
if( ffind->pszFree )
|
||||
hb_xfree( ffind->pszFree );
|
||||
|
||||
/* Do platform dependant cleanup */
|
||||
/* Do platform dependent cleanup */
|
||||
|
||||
if( ffind->info )
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
*
|
||||
* hb_fopen() function
|
||||
*
|
||||
* Copyright 2007 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
*
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
/*
|
||||
* The macro: __USE_LARGEFILE64 is set when _LARGEFILE64_SOURCE is
|
||||
* defined and effectively enables lseek64/flock64/ftruncate64 functions
|
||||
* on 32bit machines.
|
||||
* on 32-bit machines.
|
||||
*/
|
||||
#define HB_USE_LARGEFILE64
|
||||
#elif defined( HB_OS_UNIX ) && defined( O_LARGEFILE )
|
||||
@@ -235,7 +235,7 @@ PHB_FNAME hb_fsFNameSplit( const char * pszFileName )
|
||||
}
|
||||
|
||||
/* NOTE: szFileName buffer must be at least HB_PATH_MAX long.
|
||||
* Because some freign code may not be updated yet then
|
||||
* Because some foreign code may not be updated yet then
|
||||
* hb_fsFNameMerge() effectively uses only HB_PATH_MAX buffer
|
||||
* but it will be changed in the future.
|
||||
*/
|
||||
@@ -243,7 +243,7 @@ PHB_FNAME hb_fsFNameSplit( const char * pszFileName )
|
||||
/* This function joins path, name and extension into a string with a filename */
|
||||
char * hb_fsFNameMerge( char * pszFileName, PHB_FNAME pFileName )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_fsFNameMerge(%p, %p)", pszFileName, pFileName ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_fsFNameMerge(%p, %p)", ( void * ) pszFileName, ( void * ) pFileName ) );
|
||||
|
||||
if( pszFileName && pFileName )
|
||||
{
|
||||
@@ -569,7 +569,7 @@ HB_BOOL hb_fsNameExists( const char * pszFileName )
|
||||
{
|
||||
HB_BOOL fExist = HB_FALSE;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_fsNameExists(%p)", pszFileName ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_fsNameExists(%p)", ( const void * ) pszFileName ) );
|
||||
|
||||
if( pszFileName != NULL )
|
||||
{
|
||||
@@ -621,7 +621,7 @@ HB_BOOL hb_fsFileExists( const char * pszFileName )
|
||||
{
|
||||
HB_BOOL fExist = HB_FALSE;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_fsFileExists(%p)", pszFileName ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_fsFileExists(%p)", ( const void * ) pszFileName ) );
|
||||
|
||||
if( pszFileName != NULL )
|
||||
{
|
||||
@@ -683,7 +683,7 @@ HB_BOOL hb_fsDirExists( const char * pszDirName )
|
||||
{
|
||||
HB_BOOL fExist = HB_FALSE;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_fsDirExists(%p)", pszDirName ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_fsDirExists(%p)", ( const void * ) pszDirName ) );
|
||||
|
||||
if( pszDirName != NULL )
|
||||
{
|
||||
|
||||
@@ -66,7 +66,7 @@ static void hb_hashItemDelete( PHB_HASH_TABLE pTable, PHB_HASH_ITEM pItem )
|
||||
}
|
||||
|
||||
/* create a new hash table
|
||||
* nSize = initial numer of items in the table
|
||||
* nSize = initial number of items in the table
|
||||
* pHashTable = a function that calculates a hash key value
|
||||
* (first parameter is a value to add)
|
||||
* pDelete = a function that clears item's value before item's releasing
|
||||
@@ -103,11 +103,10 @@ void hb_hashTableKill( PHB_HASH_TABLE pTable )
|
||||
{
|
||||
if( pTable->pItems[ nSize ] )
|
||||
{
|
||||
PHB_HASH_ITEM pItem, pFree;
|
||||
pItem = pTable->pItems[ nSize ];
|
||||
PHB_HASH_ITEM pItem = pTable->pItems[ nSize ];
|
||||
while( pItem )
|
||||
{
|
||||
pFree = pItem;
|
||||
PHB_HASH_ITEM pFree = pItem;
|
||||
pItem = pItem->next;
|
||||
hb_hashItemDelete( pTable, pFree );
|
||||
}
|
||||
@@ -171,7 +170,7 @@ PHB_HASH_TABLE hb_hashTableResize( PHB_HASH_TABLE pTable, HB_SIZE nNewSize )
|
||||
return pNew;
|
||||
}
|
||||
|
||||
/* add a new value into th ehash table */
|
||||
/* add a new value into the hash table */
|
||||
HB_BOOL hb_hashTableAdd( PHB_HASH_TABLE pTable, const void * pKey, const void * pValue )
|
||||
{
|
||||
HB_SIZE nKey;
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
/* hb_xmemcpy() and hb_xmemset() are only needed when
|
||||
unsigned int and unsigned long differ in length */
|
||||
|
||||
/* unfortunately it's not true - on 64bit platforms int is 32 bit
|
||||
/* unfortunately it's not true - on 64-bit platforms int is 32 bits
|
||||
and long is 64.
|
||||
we need these functions only when max(size_t) < max(long)
|
||||
what could be detected and set in header files. Here check
|
||||
|
||||
@@ -45,13 +45,13 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
patterm format:
|
||||
pattern format:
|
||||
'%' [<flags>*] [<field width>] [.<precision>] [<length modifier>]
|
||||
<conversion specifier>
|
||||
*/
|
||||
|
||||
/*
|
||||
The folowwing conversions are not explicitly supported:
|
||||
The following conversions are not explicitly supported:
|
||||
A, a
|
||||
E, e
|
||||
G, g
|
||||
@@ -62,7 +62,7 @@
|
||||
S (or Ls)
|
||||
These are wide character conversions and needs locale settings.
|
||||
|
||||
double conversion if not necessary can be disabled to not create unnencessary
|
||||
double conversion if not necessary can be disabled to not create unnecessary
|
||||
overhead and/or references to math library by
|
||||
#define __NO_DOUBLE__
|
||||
It can be also greatly optimized anyhow it will increase dependences list and
|
||||
@@ -109,7 +109,7 @@
|
||||
|
||||
/* few macros for some platform dependent floating point functions/macros */
|
||||
|
||||
#if ( defined( __BORLANDC__ ) && __BORLANDC__ < 0x582 ) || \
|
||||
#if ( defined( __BORLANDC__ ) && __BORLANDC__ < 0x0582 ) || \
|
||||
( defined( __WATCOMC__ ) && __WATCOMC__ < 1270 ) || \
|
||||
defined( HB_OS_QNX ) || defined( HB_OS_SYMBIAN ) || \
|
||||
defined( __DCC__ ) || defined( __TINYC__ ) || \
|
||||
@@ -411,8 +411,7 @@ static size_t put_octal( char *buffer, size_t bufsize, size_t size,
|
||||
uintmax_t value, int flags, int width, int precision )
|
||||
{
|
||||
uintmax_t v = value;
|
||||
int nums = 0, n;
|
||||
char c;
|
||||
int nums = 0;
|
||||
|
||||
while( v )
|
||||
{
|
||||
@@ -439,10 +438,10 @@ static size_t put_octal( char *buffer, size_t bufsize, size_t size,
|
||||
}
|
||||
if( nums )
|
||||
{
|
||||
n = nums;
|
||||
int n = nums;
|
||||
do
|
||||
{
|
||||
c = ( char ) ( value & 0x7 ) + '0';
|
||||
char c = ( char ) ( value & 0x7 ) + '0';
|
||||
value >>= 3;
|
||||
--n;
|
||||
if( size + n < bufsize )
|
||||
@@ -467,8 +466,7 @@ static size_t put_dec( char *buffer, size_t bufsize, size_t size,
|
||||
int sign )
|
||||
{
|
||||
uintmax_t v = value;
|
||||
int nums = 0, n;
|
||||
char c;
|
||||
int nums = 0;
|
||||
|
||||
while( v )
|
||||
{
|
||||
@@ -499,15 +497,15 @@ static size_t put_dec( char *buffer, size_t bufsize, size_t size,
|
||||
if( ( flags & ( _F_SPACE | _F_SIGN ) ) || sign )
|
||||
{
|
||||
if( size < bufsize )
|
||||
buffer[ size ] = sign ? '-' : ( flags & _F_SIGN ? '+' : ' ' );
|
||||
buffer[ size ] = sign ? '-' : ( ( flags & _F_SIGN ) ? '+' : ' ' );
|
||||
++size;
|
||||
}
|
||||
if( nums )
|
||||
{
|
||||
n = nums;
|
||||
int n = nums;
|
||||
do
|
||||
{
|
||||
c = ( char ) ( value % 10 ) + '0';
|
||||
char c = ( char ) ( value % 10 ) + '0';
|
||||
value /= 10;
|
||||
--n;
|
||||
if( size + n < bufsize )
|
||||
@@ -571,7 +569,7 @@ static size_t put_dbl( char *buffer, size_t bufsize, size_t size,
|
||||
while( value >= 1 );
|
||||
width -= nums;
|
||||
c = ( ( flags & ( _F_SPACE | _F_SIGN ) ) || sign ) ?
|
||||
( buffer[ size ] = sign ? '-' : ( flags & _F_SIGN ? '+' : ' ' ) ) : 0;
|
||||
( buffer[ size ] = sign ? '-' : ( ( flags & _F_SIGN ) ? '+' : ' ' ) ) : 0;
|
||||
if( ( flags & _F_LEFTADJUSTED ) == 0 && width > 0 )
|
||||
{
|
||||
if( c && ( flags & _F_ZEROPADED ) )
|
||||
@@ -592,7 +590,7 @@ static size_t put_dbl( char *buffer, size_t bufsize, size_t size,
|
||||
if( c )
|
||||
{
|
||||
if( size < bufsize )
|
||||
buffer[ size ] = sign ? '-' : ( flags & _F_SIGN ? '+' : ' ' );
|
||||
buffer[ size ] = sign ? '-' : ( ( flags & _F_SIGN ) ? '+' : ' ' );
|
||||
++size;
|
||||
}
|
||||
|
||||
@@ -640,8 +638,7 @@ static size_t put_hex( char *buffer, size_t bufsize, size_t size,
|
||||
int upper )
|
||||
{
|
||||
uintmax_t v = value;
|
||||
int nums = 0, n;
|
||||
char c;
|
||||
int nums = 0;
|
||||
|
||||
while( v )
|
||||
{
|
||||
@@ -687,10 +684,10 @@ static size_t put_hex( char *buffer, size_t bufsize, size_t size,
|
||||
}
|
||||
if( nums )
|
||||
{
|
||||
n = nums;
|
||||
int n = nums;
|
||||
do
|
||||
{
|
||||
c = ( char ) ( value & 0x0f ) + '0';
|
||||
char c = ( char ) ( value & 0x0f ) + '0';
|
||||
if( c > '9' )
|
||||
c += upper ? 'A' - '9' - 1 : 'a' - '9' - 1;
|
||||
value >>= 4;
|
||||
@@ -1233,14 +1230,14 @@ int hb_vsnprintf( char * buffer, size_t bufsize, const char * format, va_list ap
|
||||
if( value & _HB_NUM_NAN )
|
||||
size = put_str( buffer, bufsize, size,
|
||||
c == 'f' ?
|
||||
( flags & _F_SIGN ? "+nan": "nan" ) :
|
||||
( flags & _F_SIGN ? "+NAN": "NAN" ) ,
|
||||
( ( flags & _F_SIGN ) ? "+nan": "nan" ) :
|
||||
( ( flags & _F_SIGN ) ? "+NAN": "NAN" ) ,
|
||||
flags, width, -1 );
|
||||
else if( value & _HB_NUM_PINF )
|
||||
size = put_str( buffer, bufsize, size,
|
||||
c == 'f' ?
|
||||
( flags & _F_SIGN ? "+inf": "inf" ) :
|
||||
( flags & _F_SIGN ? "+INF": "INF" ),
|
||||
( ( flags & _F_SIGN ) ? "+inf": "inf" ) :
|
||||
( ( flags & _F_SIGN ) ? "+INF": "INF" ),
|
||||
flags, width, -1 );
|
||||
else if( value & _HB_NUM_NINF )
|
||||
size = put_str( buffer, bufsize, size,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* Harbour common string functions (accessed from standalone utilities and the RTL)
|
||||
*
|
||||
* Copyright 1999-2001 Viktor Szakats (vszakats.net/harbour)
|
||||
* Copyright 1999 David G. Holm <dholm@jsd-llc.com> (hb_stricmp())
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -44,16 +45,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* The following parts are Copyright of the individual authors.
|
||||
*
|
||||
* Copyright 1999 David G. Holm <dholm@jsd-llc.com>
|
||||
* hb_stricmp()
|
||||
*
|
||||
* See COPYING.txt for licensing terms.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbmath.h"
|
||||
|
||||
@@ -255,12 +246,14 @@ HB_SIZE hb_strlentrim( const char * pszText )
|
||||
|
||||
int hb_stricmp( const char * s1, const char * s2 )
|
||||
{
|
||||
int rc = 0, c1, c2;
|
||||
int rc = 0, c1;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_stricmp(%s, %s)", s1, s2 ) );
|
||||
|
||||
do
|
||||
{
|
||||
int c2;
|
||||
|
||||
c1 = HB_TOUPPER( ( unsigned char ) *s1 );
|
||||
c2 = HB_TOUPPER( ( unsigned char ) *s2 );
|
||||
|
||||
@@ -278,7 +271,7 @@ int hb_stricmp( const char * s1, const char * s2 )
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* warning: It is not case sensitive */
|
||||
/* Warning: It is not case sensitive */
|
||||
int hb_strnicmp( const char * s1, const char * s2, HB_SIZE count )
|
||||
{
|
||||
HB_SIZE nCount;
|
||||
@@ -306,14 +299,14 @@ int hb_strnicmp( const char * s1, const char * s2, HB_SIZE count )
|
||||
/*
|
||||
AJ: 2004-02-23
|
||||
Concatenates multiple strings into a single result.
|
||||
Eg. hb_xstrcat (buffer, "A", "B", NULL) stores "AB" in buffer.
|
||||
Eg. hb_xstrcat( buffer, "A", "B", NULL ) stores "AB" in buffer.
|
||||
*/
|
||||
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 ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_xstrcat(%p, %p, ...)", ( void * ) szDest, ( const void * ) szSrc ) );
|
||||
|
||||
while( *szDest )
|
||||
szDest++;
|
||||
@@ -346,7 +339,7 @@ char * hb_xstrcpy( char * szDest, const char * szSrc, ... )
|
||||
char * szResult;
|
||||
va_list va;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_xstrcpy(%p, %p, ...)", szDest, szSrc ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_xstrcpy(%p, %p, ...)", ( void * ) szDest, ( const void * ) szSrc ) );
|
||||
|
||||
if( szDest == NULL )
|
||||
{
|
||||
@@ -438,7 +431,7 @@ double hb_numRound( double dNum, int iDec )
|
||||
* 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
|
||||
* and will try to convert big matrix or something 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.
|
||||
@@ -569,7 +562,7 @@ static HB_BOOL hb_str2number( HB_BOOL fPCode, const char * szNum, HB_SIZE nLen,
|
||||
int iLen, iPos = 0;
|
||||
int c, iWidth, iDec = 0, iDecR = 0;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_str2number(%d, %p, %" HB_PFS "u, %p, %p, %p, %p)", ( int ) fPCode, szNum, nLen, lVal, dVal, piDec, piWidth ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_str2number(%d, %p, %" HB_PFS "u, %p, %p, %p, %p)", ( int ) fPCode, ( const void * ) szNum, nLen, ( void * ) lVal, ( void * ) dVal, ( void * ) piDec, ( void * ) piWidth ) );
|
||||
|
||||
iLen = ( int ) nLen;
|
||||
|
||||
@@ -733,25 +726,25 @@ static HB_BOOL hb_str2number( HB_BOOL fPCode, const char * szNum, HB_SIZE nLen,
|
||||
|
||||
HB_BOOL hb_compStrToNum( const char * szNum, HB_SIZE nLen, HB_MAXINT * plVal, double * pdVal, int * piDec, int * piWidth )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compStrToNum( %s, %" HB_PFS "u, %p, %p, %p, %p)", szNum, nLen, plVal, pdVal, piDec, piWidth ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compStrToNum( %s, %" HB_PFS "u, %p, %p, %p, %p)", szNum, nLen, ( void * ) plVal, ( void * ) pdVal, ( void * ) piDec, ( void * ) piWidth ) );
|
||||
return hb_str2number( HB_TRUE, szNum, nLen, plVal, pdVal, piDec, piWidth );
|
||||
}
|
||||
|
||||
HB_BOOL hb_valStrnToNum( const char * szNum, HB_SIZE nLen, HB_MAXINT * plVal, double * pdVal, int * piDec, int * piWidth )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_valStrnToNum( %s, %" HB_PFS "u, %p, %p, %p, %p)", szNum, nLen, plVal, pdVal, piDec, piWidth ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_valStrnToNum( %s, %" HB_PFS "u, %p, %p, %p, %p)", szNum, nLen, ( void * ) plVal, ( void * ) pdVal, ( void * ) piDec, ( void * ) piWidth ) );
|
||||
return hb_str2number( HB_FALSE, szNum, nLen, plVal, pdVal, piDec, piWidth );
|
||||
}
|
||||
|
||||
HB_BOOL hb_strToNum( const char * szNum, HB_MAXINT * plVal, double * pdVal )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_strToNum(%s, %p, %p)", szNum, plVal, pdVal ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_strToNum(%s, %p, %p)", szNum, ( void * ) plVal, ( void * ) pdVal ) );
|
||||
return hb_str2number( HB_FALSE, szNum, strlen( szNum ), plVal, pdVal, NULL, NULL );
|
||||
}
|
||||
|
||||
HB_BOOL hb_strnToNum( const char * szNum, HB_SIZE nLen, HB_MAXINT * plVal, double * pdVal )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_strnToNum(%.*s, %" HB_PFS "u, %p, %p)", ( int ) nLen, szNum, nLen, plVal, pdVal ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_strnToNum(%.*s, %" HB_PFS "u, %p, %p)", ( int ) nLen, szNum, nLen, ( void * ) plVal, ( void * ) pdVal ) );
|
||||
return hb_str2number( HB_FALSE, szNum, nLen, plVal, pdVal, NULL, NULL );
|
||||
}
|
||||
|
||||
@@ -789,7 +782,7 @@ char * hb_numToStr( char * szBuf, HB_SIZE nSize, HB_MAXINT lNumber )
|
||||
int iPos = ( int ) nSize;
|
||||
HB_BOOL fNeg = HB_FALSE;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_numToStr(%p, %" HB_PFS "u, %" PFHL "i)", szBuf, nSize, lNumber ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_numToStr(%p, %" HB_PFS "u, %" PFHL "i)", ( void * ) szBuf, nSize, lNumber ) );
|
||||
|
||||
szBuf[ --iPos ] = '\0';
|
||||
if( lNumber < 0 )
|
||||
@@ -830,7 +823,7 @@ char * hb_dblToStr( char * szBuf, HB_SIZE nSize, double dNumber, int iMaxDec )
|
||||
char * szResult;
|
||||
HB_BOOL fFirst;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_dblToStr(%p, %" HB_PFS "u, %f, %d)", szBuf, nSize, dNumber, iMaxDec ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_dblToStr(%p, %" HB_PFS "u, %f, %d)", ( void * ) szBuf, nSize, dNumber, iMaxDec ) );
|
||||
|
||||
iLen = ( int ) ( nSize - 1 );
|
||||
if( iLen <= 0 )
|
||||
@@ -955,8 +948,7 @@ char * hb_dblToStr( char * szBuf, HB_SIZE nSize, double dNumber, int iMaxDec )
|
||||
return iPos == 1 && *szResult == '-' && *szBuf == '0' ? szBuf : szResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function copies szText to destination buffer.
|
||||
/* This function copies szText to destination buffer.
|
||||
* NOTE: Unlike the documentation for strncpy, this routine will always append
|
||||
* a null and the nLen param is pDest size not pSource limit
|
||||
*/
|
||||
@@ -964,7 +956,7 @@ char * hb_strncpy( char * pDest, const char * pSource, HB_SIZE nLen )
|
||||
{
|
||||
char * pBuf = pDest;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_strncpy(%p, %.*s, %" HB_PFS "u)", pDest, ( int ) nLen, pSource, nLen ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_strncpy(%p, %.*s, %" HB_PFS "u)", ( void * ) pDest, ( int ) nLen, pSource, nLen ) );
|
||||
|
||||
pDest[ nLen ] = '\0';
|
||||
|
||||
@@ -974,8 +966,7 @@ char * hb_strncpy( char * pDest, const char * pSource, HB_SIZE nLen )
|
||||
return pBuf;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function copies szText to destination buffer.
|
||||
/* This function copies szText to destination buffer.
|
||||
* NOTE: Unlike the documentation for strncat, this routine will always append
|
||||
* a null and the nLen param is pDest size not pSource limit
|
||||
*/
|
||||
@@ -983,7 +974,7 @@ char * hb_strncat( char * pDest, const char * pSource, HB_SIZE nLen )
|
||||
{
|
||||
char * pBuf = pDest;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_strncat(%p, %.*s, %" HB_PFS "u)", pDest, ( int ) nLen, pSource, nLen ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_strncat(%p, %.*s, %" HB_PFS "u)", ( void * ) pDest, ( int ) nLen, pSource, nLen ) );
|
||||
|
||||
pDest[ nLen ] = '\0';
|
||||
|
||||
@@ -999,18 +990,16 @@ char * hb_strncat( char * pDest, const char * pSource, HB_SIZE nLen )
|
||||
return pBuf;
|
||||
}
|
||||
|
||||
/* This function copies and converts szText to lower case.
|
||||
*/
|
||||
/*
|
||||
* NOTE: Unlike the documentation for strncpy, this routine will always append
|
||||
* a null
|
||||
* pt
|
||||
/* This function copies and converts szText to lower case. */
|
||||
|
||||
/* NOTE: Unlike the documentation for strncpy, this routine will always append
|
||||
* a null [pt]
|
||||
*/
|
||||
char * hb_strncpyLower( char * pDest, const char * pSource, HB_SIZE nLen )
|
||||
{
|
||||
char * pBuf = pDest;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_strncpyLower(%p, %.*s, %" HB_PFS "u)", pDest, ( int ) nLen, pSource, nLen ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_strncpyLower(%p, %.*s, %" HB_PFS "u)", ( void * ) pDest, ( int ) nLen, pSource, nLen ) );
|
||||
|
||||
pDest[ nLen ] = '\0';
|
||||
|
||||
@@ -1023,18 +1012,16 @@ char * hb_strncpyLower( char * pDest, const char * pSource, HB_SIZE nLen )
|
||||
return pBuf;
|
||||
}
|
||||
|
||||
/* This function copies and converts szText to upper case.
|
||||
*/
|
||||
/*
|
||||
* NOTE: Unlike the documentation for strncpy, this routine will always append
|
||||
* a null
|
||||
* pt
|
||||
/* This function copies and converts szText to upper case. */
|
||||
|
||||
/* NOTE: Unlike the documentation for strncpy, this routine will always append
|
||||
* a null [pt]
|
||||
*/
|
||||
char * hb_strncpyUpper( char * pDest, const char * pSource, HB_SIZE nLen )
|
||||
{
|
||||
char * pBuf = pDest;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_strncpyUpper(%p, %.*s, %" HB_PFS "u)", pDest, ( int ) nLen, pSource, nLen ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_strncpyUpper(%p, %.*s, %" HB_PFS "u)", ( void * ) pDest, ( int ) nLen, pSource, nLen ) );
|
||||
|
||||
pDest[ nLen ] = '\0';
|
||||
|
||||
@@ -1047,19 +1034,17 @@ char * hb_strncpyUpper( char * pDest, const char * pSource, HB_SIZE nLen )
|
||||
return pBuf;
|
||||
}
|
||||
|
||||
/* This function copies and converts szText to upper case AND Trims it
|
||||
*/
|
||||
/*
|
||||
* NOTE: Unlike the documentation for strncpy, this routine will always append
|
||||
* a null
|
||||
* pt
|
||||
/* This function copies and converts szText to upper case AND Trims it */
|
||||
|
||||
/* NOTE: Unlike the documentation for strncpy, this routine will always append
|
||||
* a null [pt]
|
||||
*/
|
||||
char * hb_strncpyUpperTrim( char * pDest, const char * pSource, HB_SIZE nLen )
|
||||
{
|
||||
char * pBuf = pDest;
|
||||
HB_SIZE nSLen;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_strncpyUpperTrim(%p, %.*s, %" HB_PFS "u)", pDest, ( int ) nLen, pSource, nLen ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_strncpyUpperTrim(%p, %.*s, %" HB_PFS "u)", ( void * ) pDest, ( int ) nLen, pSource, nLen ) );
|
||||
|
||||
nSLen = 0;
|
||||
while( nSLen < nLen && pSource[ nSLen ] )
|
||||
@@ -1081,9 +1066,9 @@ char * hb_strncpyUpperTrim( char * pDest, const char * pSource, HB_SIZE nLen )
|
||||
return pBuf;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function copies trimed szText to destination buffer.
|
||||
* NOTE: Unlike the documentation for strncpy, this routine will always append
|
||||
/* This function copies trimed szText to destination buffer. */
|
||||
|
||||
/* NOTE: Unlike the documentation for strncpy, this routine will always append
|
||||
* a null
|
||||
*/
|
||||
char * hb_strncpyTrim( char * pDest, const char * pSource, HB_SIZE nLen )
|
||||
@@ -1091,7 +1076,7 @@ char * hb_strncpyTrim( char * pDest, const char * pSource, HB_SIZE nLen )
|
||||
char * pBuf = pDest;
|
||||
HB_SIZE nSLen;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_strncpyTrim(%p, %.*s, %" HB_PFS "u)", pDest, ( int ) nLen, pSource, nLen ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_strncpyTrim(%p, %.*s, %" HB_PFS "u)", ( void * ) pDest, ( int ) nLen, pSource, nLen ) );
|
||||
|
||||
nSLen = 0;
|
||||
while( nSLen < nLen && pSource[ nSLen ] )
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Turbo Boyer-Moore (Crochemore) string search
|
||||
* Based on this code:
|
||||
* http://www-igm.univ-mlv.fr/~lecroq/string/node15.html
|
||||
* https://web.archive.org/web/www-igm.univ-mlv.fr/~lecroq/string/node15.html
|
||||
* Authors:
|
||||
* Christian Charras, Thierry Lecroq
|
||||
*
|
||||
@@ -112,7 +112,7 @@ static void preBmGs( const char * needle, HB_ISIZ m, HB_ISIZ bmGs[] )
|
||||
HB_ISIZ hb_strAtTBM( const char * needle, HB_ISIZ m, const char * haystack, HB_ISIZ n )
|
||||
{
|
||||
HB_ISIZ r = 0;
|
||||
HB_ISIZ bcShift, i, j, shift, u, v, turboShift;
|
||||
HB_ISIZ bcShift, j, shift, u, v, turboShift;
|
||||
HB_ISIZ bmBc[ ASIZE ];
|
||||
HB_ISIZ * bmGs;
|
||||
|
||||
@@ -127,7 +127,7 @@ HB_ISIZ hb_strAtTBM( const char * needle, HB_ISIZ m, const char * haystack, HB_I
|
||||
shift = m;
|
||||
while( j <= n - m )
|
||||
{
|
||||
i = m - 1;
|
||||
HB_ISIZ i = m - 1;
|
||||
while( i >= 0 && needle[ i ] == haystack[ i + j ] )
|
||||
{
|
||||
--i;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Tracing functions.
|
||||
* Tracing functions
|
||||
*
|
||||
* Copyright 2009 Viktor Szakats (vszakats.net/harbour)
|
||||
* Copyright 1999 Gonzalo Diethelm <gonzalo.diethelm@iname.com>
|
||||
@@ -386,7 +386,7 @@ void hb_tr_trace( const char * fmt, ... )
|
||||
pTrace->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 src/vm/fm.c
|
||||
* See hb_xalloc()/hb_xgrab() in src/vm/fm.c
|
||||
*/
|
||||
if( hb_tr_level() < HB_TR_DEBUG )
|
||||
{
|
||||
|
||||
@@ -265,7 +265,7 @@ const char * hb_verPlatformMacro( void )
|
||||
}
|
||||
|
||||
/* NOTE: Must be larger than 128, which is the maximum size of
|
||||
osVer.szCSDVersion (Windows). [vszakats] */
|
||||
osvi.szCSDVersion (Windows). [vszakats] */
|
||||
#define PLATFORM_BUF_SIZE 255
|
||||
|
||||
char * hb_verPlatform( void )
|
||||
@@ -339,19 +339,15 @@ char * hb_verPlatform( void )
|
||||
|
||||
{
|
||||
unsigned long aulQSV[ QSV_MAX ] = { 0 };
|
||||
APIRET rc;
|
||||
|
||||
rc = DosQuerySysInfo( 1L, QSV_MAX, ( void * ) aulQSV, sizeof( ULONG ) * QSV_MAX );
|
||||
APIRET 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 )
|
||||
{
|
||||
hb_snprintf( pszPlatform, PLATFORM_BUF_SIZE + 1, "OS/2 %ld.%02ld",
|
||||
aulQSV[ QSV_VERSION_MAJOR - 1 ] / 10,
|
||||
aulQSV[ QSV_VERSION_MINOR - 1 ] );
|
||||
}
|
||||
else
|
||||
hb_snprintf( pszPlatform, PLATFORM_BUF_SIZE + 1, "OS/2 %2.2f",
|
||||
( float ) aulQSV[ QSV_VERSION_MINOR - 1 ] / 10 );
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* wildcards / file match functions
|
||||
* Wildcards / file match functions
|
||||
*
|
||||
* Copyright 2009 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user