summaryrefslogtreecommitdiff
path: root/main/ast_expr2.fl
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2010-01-13 18:16:13 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2010-01-13 18:16:13 +0000
commit6d1086ec86f22fc2aa0cda069f2044a0ae01c344 (patch)
treef22c18a3856a506f7545778140b98106f87813b0 /main/ast_expr2.fl
parent2c1c3a2cab7f09fe04f9de8917546d882bccc919 (diff)
Code previously added to ast_expr2f.c warranted a change in the source file ast_expr2.fl.
Also, made a Makefile change to ensure that the expression parser C source files get regenerated correctly, when we need that to happen. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@239797 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/ast_expr2.fl')
-rw-r--r--main/ast_expr2.fl41
1 files changed, 32 insertions, 9 deletions
diff --git a/main/ast_expr2.fl b/main/ast_expr2.fl
index c47bdced9..ab3ae8dd5 100644
--- a/main/ast_expr2.fl
+++ b/main/ast_expr2.fl
@@ -251,17 +251,13 @@ void ast_yyfree(void *ptr, yyscan_t yyscanner)
int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan)
{
- struct parse_io io;
+ struct parse_io io = { .string = expr, .chan = chan };
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);
-
+
ast_yy_scan_string(expr, io.scanner);
-
+
ast_yyparse ((void *) &io);
ast_yylex_destroy(io.scanner);
@@ -294,6 +290,32 @@ int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan)
return return_value;
}
+#ifndef STANDALONE
+int ast_str_expr(struct ast_str **str, ssize_t maxlen, struct ast_channel *chan, char *expr)
+{
+ struct parse_io io = { .string = expr, .chan = chan };
+
+ ast_yylex_init(&io.scanner);
+ ast_yy_scan_string(expr, io.scanner);
+ ast_yyparse ((void *) &io);
+ ast_yylex_destroy(io.scanner);
+
+ if (!io.val) {
+ ast_str_set(str, maxlen, "0");
+ } else {
+ if (io.val->type == AST_EXPR_number) {
+ int res_length;
+ ast_str_set(str, maxlen, FP___PRINTF, io.val->u.i);
+ } else if (io.val->u.s) {
+ ast_str_set(str, maxlen, "%s", io.val->u.s);
+ free(io.val->u.s);
+ }
+ free(io.val);
+ }
+ return ast_str_strlen(*str);
+}
+#endif
+
char extra_error_message[4095];
int extra_error_message_supplied = 0;
@@ -370,7 +392,8 @@ static char *expr2_token_subst(const char *mess)
/* calc a length, malloc, fill, and return; yyerror had better free it! */
int len=0,i;
const char *p;
- char *res, *s,*t;
+ char *res, *s;
+ const char *t;
int expr2_token_equivs_entries = sizeof(expr2_token_equivs1)/sizeof(char*);
for (p=mess; *p; p++) {