Merged revisions 53075 via svnmerge from
[asterisk/asterisk.git] / funcs / func_strings.c
index c7fc485..ff3e577 100644 (file)
@@ -48,8 +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)
 {
-       const char *varval;
-       char *varval2 = NULL;
+       char *varname, *varsubst, varval[8192] = "", *varval2 = varval;
        int fieldcount = 0;
        AST_DECLARE_APP_ARGS(args,
                             AST_APP_ARG(varname);
@@ -68,9 +67,10 @@ static int function_fieldqty(struct ast_channel *chan, const char *cmd,
                        else
                                ast_copy_string(args.delim, "-", 2);
                }
-               varval = pbx_builtin_getvar_helper(chan, args.varname);
-               if (varval)
-                       varval2 = ast_strdupa(varval);
+               varsubst = alloca(strlen(varname) + 4);
+
+               sprintf(varsubst, "${%s}", varname);
+               pbx_substitute_variables_helper(chan, varsubst, varval, sizeof(varval) - 1);
                while (strsep(&varval2, args.delim))
                        fieldcount++;
        } else {