[asterisk-commits] file: trunk r98714 - /trunk/main/pbx.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 14 09:07:31 CST 2008


Author: file
Date: Mon Jan 14 09:07:30 2008
New Revision: 98714

URL: http://svn.digium.com/view/asterisk?view=rev&rev=98714
Log:
Print out a warning when spaces are used in the variable name in Set and MSet. It is extremely hard to debug this issue so this should make it easier.
(closes issue #11759)
Reported by: caio1982
Patches:
      setvar_space_warning1.diff uploaded by caio1982 (license 22)

Modified:
    trunk/main/pbx.c

Modified: trunk/main/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/main/pbx.c?view=diff&rev=98714&r1=98713&r2=98714
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Mon Jan 14 09:07:30 2008
@@ -7298,6 +7298,8 @@
 	mydata = ast_strdupa(data);
 	name = strsep(&mydata, "=");
 	value = mydata;
+	if (strchr(name, ' '))
+		ast_log(LOG_WARNING, "Please avoid unnecessary spaces on variables as it may lead to unexpected results ('%s' set to '%s').\n", name, mydata);
 
 	pbx_builtin_setvar_helper(chan, name, value);
 	return(0);
@@ -7325,10 +7327,13 @@
 
 	for (x = 0; x < args.argc; x++) {
 		AST_NONSTANDARD_APP_ARGS(pair, args.pair[x], '=');
-		if (pair.argc == 2)
+		if (pair.argc == 2) {
 			pbx_builtin_setvar_helper(chan, pair.name, pair.value);
-		else
+			if (strchr(pair.name, ' '))
+				ast_log(LOG_WARNING, "Please avoid unnecessary spaces on variables as it may lead to unexpected results ('%s' set to '%s').\n", pair.name, pair.value);
+		} else {
 			ast_log(LOG_WARNING, "MSet: ignoring entry '%s' with no '=' (in %s@%s:%d\n", pair.name, chan->exten, chan->context, chan->priority);
+		}
 	}
 
 	return 0;




More information about the asterisk-commits mailing list