From: Marc Olivier Chouinard Date: Thu, 16 Sep 2010 15:03:59 +0000 (-0400) Subject: mod_commands: Allow cond API to allow returning empty false value X-Git-Tag: v1.2-rc1~327 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c8a897b90c5d64a08a758dfca3c2b2f56f163465;p=thirdparty%2Ffreeswitch.git mod_commands: Allow cond API to allow returning empty false value --- diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index e308a0004f..0865b2b511 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -1387,7 +1387,7 @@ SWITCH_STANDARD_API(cond_function) argc = switch_separate_string(mydata, ':', argv, (sizeof(argv) / sizeof(argv[0]))); - if (argc != 3) { + if (! (argc >= 2 && argc <= 3)) { goto error; } @@ -1464,7 +1464,12 @@ SWITCH_STANDARD_API(cond_function) } switch_safe_free(s_a); switch_safe_free(s_b); - stream->write_function(stream, "%s", is_true ? argv[1] : argv[2]); + + if ((argc == 2 && !is_true)) { + stream->write_function(stream, ""); + } else { + stream->write_function(stream, "%s", is_true ? argv[1] : argv[2]); + } goto ok; }