diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-08-25 00:57:21 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:34:33 -0500 |
commit | 2dc45bd4841a0b7ea640d9a41e381f4601809262 (patch) | |
tree | 7efc339f124d942c64d176e968ababa12699a498 | |
parent | 030087c4498db2be48abeba01e3917adc520a899 (diff) | |
download | samba-2dc45bd4841a0b7ea640d9a41e381f4601809262.tar.gz samba-2dc45bd4841a0b7ea640d9a41e381f4601809262.tar.bz2 samba-2dc45bd4841a0b7ea640d9a41e381f4601809262.zip |
r9600: fixed the intermittent failures we were getting with ejs in the build
farm.
(This used to be commit b23bffcba62df954c7fb439c78b962fbd262cc5e)
-rw-r--r-- | source4/lib/appweb/ejs/ejsParser.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/source4/lib/appweb/ejs/ejsParser.c b/source4/lib/appweb/ejs/ejsParser.c index 871907dd10..da7b544c90 100644 --- a/source4/lib/appweb/ejs/ejsParser.c +++ b/source4/lib/appweb/ejs/ejsParser.c @@ -1485,6 +1485,23 @@ static int evalCond(Ejs *ep, MprVar *lhs, int rel, MprVar *rhs) return 0; } + +/* + return true if this string is a valid number +*/ +static int string_is_number(const char *s) +{ + char *endptr = NULL; + if (s == NULL || *s == 0) { + return 0; + } + strtod(s, &endptr); + if (endptr != NULL && *endptr == 0) { + return 1; + } + return 0; +} + /******************************************************************************/ /* * Evaluate an operation. Returns with the result in ep->result. Returns -1 @@ -1533,6 +1550,24 @@ static int evalExpr(Ejs *ep, MprVar *lhs, int rel, MprVar *rhs) /* Nothing more can be done */ } + /* undefined and null are special, in that they don't get promoted when + comparing */ + if (rel == EJS_EXPR_EQ || rel == EJS_EXPR_NOTEQ) { + if (lhs->type == MPR_TYPE_UNDEFINED || rhs->type == MPR_TYPE_UNDEFINED) { + return evalBoolExpr(ep, + lhs->type == MPR_TYPE_UNDEFINED, + rel, + rhs->type == MPR_TYPE_UNDEFINED); + } + + if (lhs->type == MPR_TYPE_NULL || rhs->type == MPR_TYPE_NULL) { + return evalBoolExpr(ep, + lhs->type == MPR_TYPE_NULL, + rel, + rhs->type == MPR_TYPE_NULL); + } + } + /* * From here on, lhs and rhs may contain allocated data (strings), so * we must always destroy before overwriting. @@ -1556,7 +1591,7 @@ static int evalExpr(Ejs *ep, MprVar *lhs, int rel, MprVar *rhs) */ if (lhs->type != rhs->type) { if (lhs->type == MPR_TYPE_STRING) { - if (isdigit((int) lhs->string[0])) { + if (string_is_number(lhs->string)) { num = mprVarToNumber(lhs); lhs->allocatedVar = 0; mprDestroyVar(lhs); |