aboutsummaryrefslogtreecommitdiffstats
path: root/main/ast_expr2.fl
diff options
context:
space:
mode:
authormurf <murf@f38db490-d61c-443f-a65b-d21fe96a405b>2007-07-05 18:15:22 +0000
committermurf <murf@f38db490-d61c-443f-a65b-d21fe96a405b>2007-07-05 18:15:22 +0000
commitc66181df6174ec0fe12727a20d343eb908cbad0c (patch)
treee547079acc9ff3f5fd41827b21146c28d72030c8 /main/ast_expr2.fl
parent3d7a0fea3e3c0b971b63d23184db06196dd1a771 (diff)
In regards to changes for 9508, expr2 system choking on floating point numbers, I'm adding this update to round out (no pun intended) and make this FP-capable version of the Expr2 stuff interoperate better with previous integer-only usage, by providing Functions syntax, with 20 builtin functions for floating pt to integer conversions, and some general floating point math routines that might commonly be used also. Along with this, I made it so if a function was not a builtin, it will try and find it in the ast_custom_function list, and if found, execute it and collect the results. Thus, you can call system functions like CDR(), CHANNEL(), etc, from within $\[..\] exprs, without having to wrap them in $\{...\} (curly brace) notation. Did a valgrind on the standalone and made sure there's no mem leaks. Looks good. Updated the docs, too.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@73449 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/ast_expr2.fl')
-rw-r--r--main/ast_expr2.fl16
1 files changed, 12 insertions, 4 deletions
diff --git a/main/ast_expr2.fl b/main/ast_expr2.fl
index 49c051bd9..725205304 100644
--- a/main/ast_expr2.fl
+++ b/main/ast_expr2.fl
@@ -36,12 +36,12 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#endif
#ifdef __USE_ISOC99
-#define FP___PRINTF "%.16Lg"
+#define FP___PRINTF "%.18Lg"
#define FP___FMOD fmodl
#define FP___STRTOD strtold
#define FP___TYPE long double
#else
-#define FP___PRINTF "%.8g"
+#define FP___PRINTF "%.16g"
#define FP___FMOD fmod
#define FP___STRTOD strtod
#define FP___TYPE double
@@ -62,7 +62,10 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/ast_expr.h"
#include "asterisk/logger.h"
+#ifndef STANDALONE
#include "asterisk/strings.h"
+#include "asterisk/channel.h"
+#endif
enum valtype {
AST_EXPR_number, AST_EXPR_numeric_string, AST_EXPR_string
@@ -101,6 +104,7 @@ struct parse_io
char *string;
struct val *val;
yyscan_t scanner;
+ struct ast_channel *chan;
};
void ast_yyset_column(int column_no, yyscan_t yyscanner);
@@ -133,6 +137,7 @@ static char *expr2_token_subst(char *mess);
\<\= { SET_COLUMNS; SET_STRING; return TOK_LE;}
\!\= { SET_COLUMNS; SET_STRING; return TOK_NE;}
\+ { SET_COLUMNS; SET_STRING; return TOK_PLUS;}
+\, { SET_COLUMNS; SET_STRING; return TOK_COMMA;}
\- { SET_COLUMNS; SET_STRING; return TOK_MINUS;}
\* { SET_COLUMNS; SET_STRING; return TOK_MULT;}
\/ { SET_COLUMNS; SET_STRING; return TOK_DIV;}
@@ -166,7 +171,7 @@ static char *expr2_token_subst(char *mess);
return TOKEN;
}
-[a-zA-Z0-9,.';\\_^$#@]+ {
+[a-zA-Z0-9\.';\\_^$#@]+ {
SET_COLUMNS;
SET_STRING;
return TOKEN;
@@ -230,13 +235,14 @@ static char *expr2_token_subst(char *mess);
int ast_yyparse(void *); /* need to/should define this prototype for the call to yyparse */
int ast_yyerror(const char *, YYLTYPE *, struct parse_io *); /* likewise */
-int ast_expr(char *expr, char *buf, int length)
+int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan)
{
struct parse_io io;
int return_value = 0;
memset(&io, 0, sizeof(io));
io.string = expr; /* to pass to the error routine */
+ io.chan = chan;
ast_yylex_init(&io.scanner);
@@ -310,6 +316,7 @@ static char *expr2_token_equivs1[] =
"TOK_COMPL",
"TOK_COLON",
"TOK_EQTILDE",
+ "TOK_COMMA",
"TOK_RP",
"TOK_LP"
};
@@ -335,6 +342,7 @@ static char *expr2_token_equivs2[] =
"!",
":",
"=~",
+ ",",
")",
"("
};