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
This commit is contained in:
Tilghman Lesher
2010-01-13 18:16:13 +00:00
parent 2c1c3a2cab
commit 6d1086ec86
3 changed files with 63 additions and 29 deletions

View File

@@ -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++) {