svn commit: samba r9299 - in
branches/SAMBA_4_0/source/lib/appweb/ejs: .
tridge at samba.org
tridge at samba.org
Sat Aug 13 03:16:04 GMT 2005
Author: tridge
Date: 2005-08-13 03:16:03 +0000 (Sat, 13 Aug 2005)
New Revision: 9299
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=9299
Log:
fixed the evaluation of pointer expressions that evaluate to boolean
Modified:
branches/SAMBA_4_0/source/lib/appweb/ejs/ejsParser.c
Changeset:
Modified: branches/SAMBA_4_0/source/lib/appweb/ejs/ejsParser.c
===================================================================
--- branches/SAMBA_4_0/source/lib/appweb/ejs/ejsParser.c 2005-08-13 03:14:47 UTC (rev 9298)
+++ branches/SAMBA_4_0/source/lib/appweb/ejs/ejsParser.c 2005-08-13 03:16:03 UTC (rev 9299)
@@ -48,6 +48,7 @@
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 @@
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 @@
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
More information about the samba-cvs
mailing list