[asterisk-commits] murf: trunk r42423 - /trunk/funcs/func_strings.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Sep 8 09:44:39 MST 2006


Author: murf
Date: Fri Sep  8 11:44:38 2006
New Revision: 42423

URL: http://svn.digium.com/view/asterisk?rev=42423&view=rev
Log:
As per discussion on bug 7862, the problem wasn't the fact that the documentation differed from behavior, but rather that users are used to REGEX having that space after the double quote in 1.2.x. So, in keeping with history, I investigated a little deeper, and discovered that the change in behavior was due to the modification of the function to use the AST_DECLARE_APP_ARGS and AST_NONSTANDARD_APP_ARGS() to parse the args. The code to skip the blank was left out. So, what I did was add code to throw out the first blank (space or tab) after the double quote, IF IT IS THERE. If not, nothing is done.Verbage is added to the function description saying that the space is optional, and skipped if it is there. If a space is desired, then the documentation advises putting two spaces there. This should make it compatible for 1.2 users, and not mess up new users who are used to using it with no space. It WILL mess up new users who WANT a space. Hopefully, they will double check the doc strings for this func and add the extra space. Hopefully, this class of new user is very small.

Modified:
    trunk/funcs/func_strings.c

Modified: trunk/funcs/func_strings.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_strings.c?rev=42423&r1=42422&r2=42423&view=diff
==============================================================================
--- trunk/funcs/func_strings.c (original)
+++ trunk/funcs/func_strings.c Fri Sep  8 11:44:38 2006
@@ -123,6 +123,8 @@
 		ast_log(LOG_ERROR, "Unexpected arguments: should have been in the form '\"<regex>\" <string>'\n");
 		return -1;
 	}
+	if ((*args.str == ' ') || (*args.str == '\t'))
+		args.str++;
 
 	ast_log(LOG_DEBUG, "FUNCTION REGEX (%s)(%s)\n", args.reg, args.str);
 
@@ -144,10 +146,10 @@
 	.synopsis = "Regular Expression",
 	.desc =  
 		"Returns 1 if data matches regular expression, or 0 otherwise.\n"
-		"Please note that the double quotes separating the expression from the data\n"
-		"should not have any neighboring spaces, either before or after, unless you\n"
-	        "intend them to be in either the expression or the data!\n",
-	.syntax = "REGEX(\"<regular expression>\"<data>)",
+		"Please note that the space following the double quotes separating the regex from the data\n"
+		"is optional and if present, is skipped. If a space is desired at the beginning of the data,\n"
+	        "then put two spaces there; the second will not be skipped.\n",
+	.syntax = "REGEX(\"<regular expression>\" <data>)",
 	.read = regex,
 };
 



More information about the asterisk-commits mailing list