summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2008-05-25 14:31:29 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2008-05-25 14:31:29 +0000
commit316e334751f0c455b2e236a1acf716a12ce4f728 (patch)
tree7812c5de051df6b4d86de2879292f04ef5a98107
parent3c6eb6100829acd5bcbd9a05185531eca40673a1 (diff)
Change space-zero to now evaluate to false, as is expected by a great many.
(Inspired by a post on the -users list) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@118223 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--UPGRADE.txt6
-rw-r--r--main/pbx.c10
2 files changed, 12 insertions, 4 deletions
diff --git a/UPGRADE.txt b/UPGRADE.txt
index ff3ca921b..e2184ceca 100644
--- a/UPGRADE.txt
+++ b/UPGRADE.txt
@@ -59,6 +59,12 @@ Core:
* 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:
* The voicemail configuration values 'maxmessage' and 'minmessage' have
diff --git a/main/pbx.c b/main/pbx.c
index cc14ba2eb..a18d29e9a 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -7959,12 +7959,14 @@ void pbx_builtin_clear_globals(void)
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)