[asterisk-commits] tilghman: trunk r118223 - in /trunk: UPGRADE.txt main/pbx.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun May 25 09:31:38 CDT 2008


Author: tilghman
Date: Sun May 25 09:31:29 2008
New Revision: 118223

URL: http://svn.digium.com/view/asterisk?view=rev&rev=118223
Log:
Change space-zero to now evaluate to false, as is expected by a great many.
(Inspired by a post on the -users list)

Modified:
    trunk/UPGRADE.txt
    trunk/main/pbx.c

Modified: trunk/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/trunk/UPGRADE.txt?view=diff&rev=118223&r1=118222&r2=118223
==============================================================================
--- trunk/UPGRADE.txt (original)
+++ trunk/UPGRADE.txt Sun May 25 09:31:29 2008
@@ -58,6 +58,12 @@
 
 * The silencethreshold used for various applications is now settable via a
   centralized config option in dsp.conf.
+
+* The logical value of spaces immediately preceding a standalone 0 previously
+  evaluated to true.  It now evaluates to false.  This has confused a good
+  many people in the past (typically because they failed to realize the space
+  had any significance).  Since this violates the Principle of Least Surprise,
+  it has been changed.
 
 Voicemail:
 

Modified: trunk/main/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/main/pbx.c?view=diff&rev=118223&r1=118222&r2=118223
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Sun May 25 09:31:29 2008
@@ -7959,12 +7959,14 @@
 
 int pbx_checkcondition(const char *condition)
 {
-	if (ast_strlen_zero(condition))	/* NULL or empty strings are false */
+	int res;
+	if (ast_strlen_zero(condition)) {                /* NULL or empty strings are false */
 		return 0;
-	else if (*condition >= '0' && *condition <= '9')	/* Numbers are evaluated for truth */
-		return atoi(condition);
-	else	/* Strings are true */
+	} else if (sscanf(condition, "%d", &res) == 1) { /* Numbers are evaluated for truth */
+		return res;
+	} else {                                         /* Strings are true */
 		return 1;
+	}
 }
 
 static int pbx_builtin_gotoif(struct ast_channel *chan, void *data)




More information about the asterisk-commits mailing list