mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-20 03:59:01 +00:00
If the value of a variable passed to FIELDQTY is blank, then FIELDQTY should return 0, not 1.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@66537 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -51,7 +51,9 @@ static char *function_fieldqty(struct ast_channel *chan, char *cmd, char *data,
|
|||||||
|
|
||||||
sprintf(varsubst, "${%s}", varname);
|
sprintf(varsubst, "${%s}", varname);
|
||||||
pbx_substitute_variables_helper(chan, varsubst, varval, sizeof(varval) - 1);
|
pbx_substitute_variables_helper(chan, varsubst, varval, sizeof(varval) - 1);
|
||||||
if (delim) {
|
if (ast_strlen_zero(varval))
|
||||||
|
fieldcount = 0;
|
||||||
|
else if (delim) {
|
||||||
while (strsep(&varval2, delim))
|
while (strsep(&varval2, delim))
|
||||||
fieldcount++;
|
fieldcount++;
|
||||||
} else if (!ast_strlen_zero(varval)) {
|
} else if (!ast_strlen_zero(varval)) {
|
||||||
@@ -60,7 +62,7 @@ static char *function_fieldqty(struct ast_channel *chan, char *cmd, char *data,
|
|||||||
snprintf(buf, len, "%d", fieldcount);
|
snprintf(buf, len, "%d", fieldcount);
|
||||||
} else {
|
} else {
|
||||||
ast_log(LOG_ERROR, "Out of memory\n");
|
ast_log(LOG_ERROR, "Out of memory\n");
|
||||||
strncpy(buf, "1", len);
|
ast_copy_string(buf, "1", len);
|
||||||
}
|
}
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user