[asterisk-commits] tilghman: branch 1.4 r123710 - /branches/1.4/pbx/pbx_spool.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jun 18 15:22:43 CDT 2008


Author: tilghman
Date: Wed Jun 18 15:22:42 2008
New Revision: 123710

URL: http://svn.digium.com/view/asterisk?view=rev&rev=123710
Log:
Set the variables top-down, so that if a script sets a variable more than once,
the last one will take precedence.
(closes issue #12673)
 Reported by: phber
 Patches: 
       20080519__bug12673.diff.txt uploaded by Corydon76 (license 14)

Modified:
    branches/1.4/pbx/pbx_spool.c

Modified: branches/1.4/pbx/pbx_spool.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/pbx/pbx_spool.c?view=diff&rev=123710&r1=123709&r2=123710
==============================================================================
--- branches/1.4/pbx/pbx_spool.c (original)
+++ branches/1.4/pbx/pbx_spool.c Wed Jun 18 15:22:42 2008
@@ -128,7 +128,11 @@
 	char buf[256];
 	char *c, *c2;
 	int lineno = 0;
-	struct ast_variable *var;
+	struct ast_variable *var, *last = o->vars;
+
+	while (last && last->next) {
+		last = last->next;
+	}
 
 	while(fgets(buf, sizeof(buf), f)) {
 		lineno++;
@@ -222,8 +226,13 @@
 					if (c2) {
 						var = ast_variable_new(c, c2);
 						if (var) {
-							var->next = o->vars;
-							o->vars = var;
+							/* Always insert at the end, because some people want to treat the spool file as a script */
+							if (last) {
+								last->next = var;
+							} else {
+								o->vars = var;
+							}
+							last = var;
 						}
 					} else
 						ast_log(LOG_WARNING, "Malformed \"%s\" argument.  Should be \"%s: variable=value\"\n", buf, buf);




More information about the asterisk-commits mailing list