Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv6791

Modified Files:
        pbx.c 
Log Message:
Fix truth of strings 


Index: pbx.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx.c,v
retrieving revision 1.284
retrieving revision 1.285
diff -u -d -r1.284 -r1.285
--- pbx.c       13 Oct 2005 23:35:57 -0000      1.284
+++ pbx.c       18 Oct 2005 16:51:28 -0000      1.285
@@ -6029,7 +6029,21 @@
 
 static int pbx_checkcondition(char *condition) 
 {
-       return condition ? atoi(condition) : 0;
+       if (condition) {
+               if (*condition == '\0') {
+                       /* Empty strings are false */
+                       return 0;
+               } else if (*condition >= '0' && *condition <= '9') {
+                       /* Numbers are evaluated for truth */
+                       return atoi(condition);
+               } else {
+                       /* Strings are true */
+                       return 1;
+               }
+       } else {
+               /* NULL is also false */
+               return 0;
+       }
 }
 
 static int pbx_builtin_gotoif(struct ast_channel *chan, void *data)

_______________________________________________
Asterisk-Cvs mailing list
[email protected]
http://lists.digium.com/mailman/listinfo/asterisk-cvs

Reply via email to