summaryrefslogtreecommitdiff
path: root/pbx.c
diff options
context:
space:
mode:
authorMark Spencer <markster@digium.com>2005-10-18 16:51:28 +0000
committerMark Spencer <markster@digium.com>2005-10-18 16:51:28 +0000
commit68c2c01b1ca70e63ca3d6c4e1639af1a33ecdcea (patch)
tree971d80f9f8287e3972b74a998f1526674e196750 /pbx.c
parent50d20994f8657928753cbe7bb1b3346f0bcd5209 (diff)
Fix truth of strings
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6817 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'pbx.c')
-rwxr-xr-xpbx.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/pbx.c b/pbx.c
index 51b337018..d8747d572 100755
--- a/pbx.c
+++ b/pbx.c
@@ -6029,7 +6029,21 @@ void pbx_builtin_clear_globals(void)
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)