Blocked revisions 53878 via svnmerge
[asterisk/asterisk.git] / funcs / func_strings.c
index 8088f4d..af330e6 100644 (file)
@@ -48,7 +48,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 static int function_fieldqty(struct ast_channel *chan, const char *cmd,
                             char *parse, char *buf, size_t len)
 {
-       char *varval;
+       char *varsubst, varval[8192] = "", *varval2 = varval;
        int fieldcount = 0;
        AST_DECLARE_APP_ARGS(args,
                             AST_APP_ARG(varname);
@@ -57,7 +57,6 @@ static int function_fieldqty(struct ast_channel *chan, const char *cmd,
 
        AST_STANDARD_APP_ARGS(args, parse);
        if (args.delim) {
-               pbx_retrieve_variable(chan, args.varname, &varval, buf, len, NULL);
                if (args.delim[0] == '\\') {
                        if (args.delim[1] == 'n')
                                ast_copy_string(args.delim, "\n", 2);
@@ -68,7 +67,11 @@ static int function_fieldqty(struct ast_channel *chan, const char *cmd,
                        else
                                ast_copy_string(args.delim, "-", 2);
                }
-               while (strsep(&varval, args.delim))
+               varsubst = alloca(strlen(args.varname) + 4);
+
+               sprintf(varsubst, "${%s}", args.varname);
+               pbx_substitute_variables_helper(chan, varsubst, varval, sizeof(varval) - 1);
+               while (strsep(&varval2, args.delim))
                        fieldcount++;
        } else {
                fieldcount = 1;