1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-28 07:21:54 +03:00

r9299: fixed the evaluation of pointer expressions that evaluate to boolean

(This used to be commit 17679676d4)
This commit is contained in:
Andrew Tridgell 2005-08-13 03:16:03 +00:00 committed by Gerald (Jerry) Carter
parent e5de09860c
commit 1774019fc2

View File

@ -48,6 +48,7 @@ static int evalExpr(Ejs *ep, MprVar *lhs, int rel, MprVar *rhs);
static int evalFloatExpr(Ejs *ep, double l, int rel, double r);
#endif
static int evalBoolExpr(Ejs *ep, bool l, int rel, bool r);
static int evalPtrExpr(Ejs *ep, void *l, int rel, void *r);
static int evalNumericExpr(Ejs *ep, MprNum l, int rel, MprNum r);
static int evalStringExpr(Ejs *ep, MprVar *lhs, int rel, MprVar *rhs);
static int evalFunction(Ejs *ep, MprVar *obj, int flags);
@ -1670,8 +1671,8 @@ static int evalExpr(Ejs *ep, MprVar *lhs, int rel, MprVar *rhs)
return 0;
case MPR_TYPE_PTR:
mprCopyVarValue(&ep->result, mprCreateBoolVar(lhs->ptr == rhs->ptr), 0);
return 0;
rc = evalPtrExpr(ep, lhs->ptr, rel, rhs->ptr);
break;
case MPR_TYPE_BOOL:
rc = evalBoolExpr(ep, lhs->boolean, rel, rhs->boolean);
@ -1806,6 +1807,28 @@ static int evalBoolExpr(Ejs *ep, bool l, int rel, bool r)
return 0;
}
static int evalPtrExpr(Ejs *ep, void *l, int rel, void *r)
{
bool lval;
switch (rel) {
case EJS_EXPR_EQ:
lval = l == r;
break;
case EJS_EXPR_NOTEQ:
lval = l != r;
break;
case EJS_EXPR_BOOL_COMP:
lval = (r == NULL) ? 1 : 0;
break;
default:
ejsError(ep, "Bad operator %d", rel);
return -1;
}
mprCopyVarValue(&ep->result, mprCreateBoolVar(lval), 0);
return 0;
}
/******************************************************************************/
/*
* Expressions with numeric operands