svn commit: samba r9600 - in branches/SAMBA_4_0/source/lib/appweb/ejs: .

tridge at samba.org tridge at samba.org
Thu Aug 25 00:57:22 GMT 2005


Author: tridge
Date: 2005-08-25 00:57:21 +0000 (Thu, 25 Aug 2005)
New Revision: 9600

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=9600

Log:

fixed the intermittent failures we were getting with ejs in the build
farm.


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-25 00:38:09 UTC (rev 9599)
+++ branches/SAMBA_4_0/source/lib/appweb/ejs/ejsParser.c	2005-08-25 00:57:21 UTC (rev 9600)
@@ -1485,6 +1485,23 @@
 	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 @@
 		/* 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 @@
 	 */
 	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);



More information about the samba-cvs mailing list