[svn-commits] mmichelson: branch 1.8 r416500 - /branches/1.8/funcs/func_strings.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jun 17 13:22:37 CDT 2014


Author: mmichelson
Date: Tue Jun 17 13:22:31 2014
New Revision: 416500

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=416500
Log:
Allow the PUSH and UNSHIFT functions to set inheritable channel variables.


Modified:
    branches/1.8/funcs/func_strings.c

Modified: branches/1.8/funcs/func_strings.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/funcs/func_strings.c?view=diff&rev=416500&r1=416499&r2=416500
==============================================================================
--- branches/1.8/funcs/func_strings.c (original)
+++ branches/1.8/funcs/func_strings.c Tue Jun 17 13:22:31 2014
@@ -1503,6 +1503,7 @@
 		AST_APP_ARG(var);
 		AST_APP_ARG(delimiter);
 	);
+	const char *stripped_var;
 
 	if (!(buf = ast_str_thread_get(&result_buf, 16)) ||
 		!(previous_value = ast_str_thread_get(&tmp_buf, 16))) {
@@ -1520,8 +1521,15 @@
 		ast_get_encoded_char(args.delimiter, delimiter, &unused);
 	}
 
-	varsubst = ast_alloca(strlen(args.var) + 4);
-	sprintf(varsubst, "${%s}", args.var);
+	/* UNSHIFT and PUSH act as ways of setting a variable, so we need to be
+	 * sure to skip leading underscores if they appear. However, we only want
+	 * to skip up to two since that is the maximum number that can be used to
+	 * indicate variable inheritance. Any further underscores are part of the
+	 * variable name.
+	 */
+	stripped_var = args.var + MIN(strspn(args.var, "_"), 2);
+	varsubst = ast_alloca(strlen(stripped_var) + 4);
+	sprintf(varsubst, "${%s}", stripped_var);
 	ast_str_substitute_variables(&previous_value, 0, chan, varsubst);
 
 	if (!ast_str_strlen(previous_value)) {




More information about the svn-commits mailing list