[asterisk-commits] mmichelson: branch 12 r416502 - in /branches/12: ./ funcs/func_strings.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 17 13:43:59 CDT 2014


Author: mmichelson
Date: Tue Jun 17 13:43:56 2014
New Revision: 416502

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=416502
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
........

Merged revisions 416501 from http://svn.asterisk.org/svn/asterisk/branches/11

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

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

Modified: branches/12/funcs/func_strings.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/funcs/func_strings.c?view=diff&rev=416502&r1=416501&r2=416502
==============================================================================
--- branches/12/funcs/func_strings.c (original)
+++ branches/12/funcs/func_strings.c Tue Jun 17 13:43:56 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 asterisk-commits mailing list