[svn-commits] mmichelson: branch 11 r416501 - in /branches/11: ./ funcs/func_strings.c

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


Author: mmichelson
Date: Tue Jun 17 13:40:35 2014
New Revision: 416501

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

Merged revisions 416500 from http://svn.asterisk.org/svn/asterisk/branches/1.8

Modified:
    branches/11/   (props changed)
    branches/11/funcs/func_strings.c

Propchange: branches/11/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: branches/11/funcs/func_strings.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/funcs/func_strings.c?view=diff&rev=416501&r1=416500&r2=416501
==============================================================================
--- branches/11/funcs/func_strings.c (original)
+++ branches/11/funcs/func_strings.c Tue Jun 17 13:40:35 2014
@@ -1610,6 +1610,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))) {
@@ -1627,8 +1628,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