[asterisk-bugs] [Asterisk 0010549]: "Set" application silently changed in trunk to no longer support multiple assignments

noreply at bugs.digium.com noreply at bugs.digium.com
Fri Sep 28 12:28:54 CDT 2007


A NOTE has been added to this issue. 
====================================================================== 
http://bugs.digium.com/view.php?id=10549 
====================================================================== 
Reported By:                stevedavies
Assigned To:                Corydon76
====================================================================== 
Project:                    Asterisk
Issue ID:                   10549
Category:                   Addons/General
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     feedback
Asterisk Version:            SVN 
SVN Branch (only for SVN checkouts, not tarball releases): N/A  
SVN Revision (number only!): 80453 
Disclaimer on File?:        N/A 
Request Review:              
====================================================================== 
Date Submitted:             08-24-2007 05:33 CDT
Last Modified:              09-28-2007 12:28 CDT
====================================================================== 
Summary:                    "Set" application silently changed in trunk to no
longer support multiple assignments
Description: 
On Jul 23rd, Tilghman merged the dialplan_aesthetics branch.  (pbx.c went
from rev 76555 to rev 76703.

His comment suggests this merge should be transparent except for no longer
supporting the App,arg|arg format.

In fact the merge also changes the Set application to no longer support
multiple assignments.

So code that looks like so "Set(var1=value1|var2=value2) now suddenly
assigns value1|var2=value2 into var1, whereas before it did the two
assignments.

Multiple assignments is still sort-of documented in the show application
output for Set in trunk.  And it certainly works and is documented in 1.4,
and has never been marked or documented as deprecated.

Looks like support for the "g" option is also removed.

Here is the relevant change:

@@ -5867,35 +5871,17 @@
 int pbx_builtin_setvar(struct ast_channel *chan, void *data)
 {
        char *name, *value, *mydata;
-       int argc;
-       char *argv[24];         /* this will only support a maximum of 24
variables being set in a single operation */
-       int global = 0;
-       int x;
 
        if (ast_strlen_zero(data)) {
-               ast_log(LOG_WARNING, "Set requires at least one variable
name/value pair.\n");
+               ast_log(LOG_WARNING, "Set requires one variable name/value
pair.\n");
                return 0;
        }
 
        mydata = ast_strdupa(data);
-       argc = ast_app_separate_args(mydata, '|', argv, sizeof(argv) /
sizeof(argv[0]));
+       name = strsep(&mydata, "=");
+       value = mydata;
 
-       /* check for a trailing flags argument */
-       if ((argc > 1) && !strchr(argv[argc-1], '=')) {
-               argc--;
-               if (strchr(argv[argc], 'g'))
-                       global = 1;
-       }
-
-       for (x = 0; x < argc; x++) {
-               name = argv[x];
-               if ((value = strchr(name, '='))) {
-                       *value++ = '\0';
-                       pbx_builtin_setvar_helper((global) ? NULL : chan,
name, value);
-               } else
-                       ast_log(LOG_WARNING, "Ignoring entry '%s' with no
= (and not last 'options' entry)\n", name);
-       }
-
+       pbx_builtin_setvar_helper(chan, name, value);
        return(0);
 }
 
====================================================================== 

---------------------------------------------------------------------- 
 chappell - 09-28-07 12:28  
---------------------------------------------------------------------- 
Wouldn't it be better to leave Set() as it was (accepting multiple values)
and introduce a new function for setting values which may contain commas? 
Switching the behavior of Set() will cause lots of subtle bugs in dialplans
which work now.

I believe we really need a way to set multiple values at one priority.  I
was able to greatly simplify my dialplan and reduce the potential for silly
errors by merging all blocks of calls to Set() into a single call which set
multiple values at once.  This is particularly helpful when a phone number
must be recognized and several variables set, such as the caller ID name
and channel language. 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
09-28-07 12:28  chappell       Note Added: 0071183                          
======================================================================




More information about the asterisk-bugs mailing list