[asterisk-commits] russell: trunk r41544 -
/trunk/funcs/func_strings.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed Aug 30 21:07:36 MST 2006
Author: russell
Date: Wed Aug 30 23:07:35 2006
New Revision: 41544
URL: http://svn.digium.com/view/asterisk?rev=41544&view=rev
Log:
The behavior of REGEX when it did not match was not defined by the docs, so
define it to provide a result of "0" and change the code appropriately.
(issue #7805)
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=41544&r1=41543&r2=41544&view=diff
==============================================================================
--- trunk/funcs/func_strings.c (original)
+++ trunk/funcs/func_strings.c Wed Aug 30 23:07:35 2006
@@ -115,7 +115,7 @@
int errcode;
regex_t regexbuf;
- buf[0] = '\0';
+ buf[0] = '0';
AST_NONSTANDARD_APP_ARGS(args, parse, '"');
@@ -130,10 +130,10 @@
regerror(errcode, ®exbuf, buf, len);
ast_log(LOG_WARNING, "Malformed input %s(%s): %s\n", cmd, parse, buf);
return -1;
- } else {
- if (!regexec(®exbuf, args.str, 0, NULL, 0))
- strcpy(buf, "1");
- }
+ }
+
+ strcpy(buf, regexec(®exbuf, args.str, 0, NULL, 0) ? "0" : "1");
+
regfree(®exbuf);
return 0;
@@ -141,8 +141,8 @@
static struct ast_custom_function regex_function = {
.name = "REGEX",
- .synopsis =
- "Regular Expression: Returns 1 if data matches regular expression.",
+ .synopsis = "Regular Expression",
+ .desc = "Returns 1 if data matches regular expression, or 0 otherwise.",
.syntax = "REGEX(\"<regular expression>\" <data>)",
.read = regex,
};
More information about the asterisk-commits
mailing list