summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-08-13 03:16:03 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:33:22 -0500
commit1774019fc27869f01808ad8b0f8f85d03492d4b0 (patch)
tree04502df54bd2cc3822374b6486f949d7b01af8cb /source4
parente5de09860ce20b8a62e5e0828874f0bb51460cea (diff)
downloadsamba-1774019fc27869f01808ad8b0f8f85d03492d4b0.tar.gz
samba-1774019fc27869f01808ad8b0f8f85d03492d4b0.tar.bz2
samba-1774019fc27869f01808ad8b0f8f85d03492d4b0.zip
r9299: fixed the evaluation of pointer expressions that evaluate to boolean
(This used to be commit 17679676d4629ac81116ae1b102f1a311b5d4eed)
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/appweb/ejs/ejsParser.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/source4/lib/appweb/ejs/ejsParser.c b/source4/lib/appweb/ejs/ejsParser.c
index 5b8b84f7b3..871907dd10 100644
--- a/source4/lib/appweb/ejs/ejsParser.c
+++ b/source4/lib/appweb/ejs/ejsParser.c
@@ -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