mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 03:50:31 +00:00
Merged revisions 179807 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 I had some work to do to port these changes to trunk; the check_expr stuff hasn't been updated here for quite some time, it appears. I added some more tests to the check_expr2 suite. I had to play around with the makefile a bit, etc. I added STANDALONE2 #ifdefs to ast_expr2.y so as not to conflict structure with aelparse. ........ r179807 | murf | 2009-03-03 11:11:34 -0700 (Tue, 03 Mar 2009) | 19 lines These changes allow AEL to better check ${} constructs within $[...], that are concatenated with text. I modified and added rules in ast_expr2.fl to better handle the concatenations. I added some default routines to ast_expr2.y so the standalone would compile. It also looks like I haven't run this thru bison since 2.1, so it's good to get this updated. The Makefile has comments added now for check_expr2 and check_expr to explain what they are for, and how to run them. The testexpr2s stuff has been removed, in favor of check_expr2. expr2.testinput has been updated to include the two expressions that inspired these changes (from mcnobody on #asterisk this morning) The regression has been run and all looks well. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@179973 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -17,7 +17,8 @@
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if !defined(STANDALONE)
|
||||
#if !defined(STANDALONE) && !defined(STANDALONE2) \
|
||||
|
||||
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
#else
|
||||
#ifndef __USE_ISOC99
|
||||
@@ -212,7 +213,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
|
||||
#include "asterisk/ast_expr.h"
|
||||
#include "asterisk/logger.h"
|
||||
#ifndef STANDALONE
|
||||
#if !defined(STANDALONE) && !defined(STANDALONE2)
|
||||
#include "asterisk/pbx.h"
|
||||
#endif
|
||||
|
||||
@@ -240,7 +241,7 @@ enum valtype {
|
||||
AST_EXPR_number, AST_EXPR_numeric_string, AST_EXPR_string
|
||||
} ;
|
||||
|
||||
#ifdef STANDALONE
|
||||
#if defined(STANDALONE) || defined(STANDALONE2)
|
||||
void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) __attribute__ ((format (printf,5,6)));
|
||||
#endif
|
||||
|
||||
@@ -656,6 +657,62 @@ is_zero_or_null (struct val *vp)
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
#ifdef STANDALONE2
|
||||
|
||||
void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...)
|
||||
{
|
||||
va_list vars;
|
||||
va_start(vars,fmt);
|
||||
|
||||
printf("LOG: lev:%d file:%s line:%d func: %s ",
|
||||
level, file, line, function);
|
||||
vprintf(fmt, vars);
|
||||
fflush(stdout);
|
||||
va_end(vars);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc,char **argv) {
|
||||
char s[4096];
|
||||
char out[4096];
|
||||
FILE *infile;
|
||||
|
||||
if( !argv[1] )
|
||||
exit(20);
|
||||
|
||||
if( access(argv[1],F_OK)== 0 )
|
||||
{
|
||||
int ret;
|
||||
|
||||
infile = fopen(argv[1],"r");
|
||||
if( !infile )
|
||||
{
|
||||
printf("Sorry, couldn't open %s for reading!\n", argv[1]);
|
||||
exit(10);
|
||||
}
|
||||
while( fgets(s,sizeof(s),infile) )
|
||||
{
|
||||
if( s[strlen(s)-1] == '\n' )
|
||||
s[strlen(s)-1] = 0;
|
||||
|
||||
ret = ast_expr(s, out, sizeof(out), NULL);
|
||||
printf("Expression: %s Result: [%d] '%s'\n",
|
||||
s, ret, out);
|
||||
}
|
||||
fclose(infile);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ast_expr(argv[1], s, sizeof(s), NULL))
|
||||
printf("=====%s======\n",s);
|
||||
else
|
||||
printf("No result\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#undef ast_yyerror
|
||||
#define ast_yyerror(x) ast_yyerror(x, YYLTYPE *yylloc, struct parse_io *parseio)
|
||||
|
||||
@@ -680,7 +737,7 @@ static void destroy_arglist(struct expr_node *arglist)
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(STANDALONE)
|
||||
#if !defined(STANDALONE) && !defined(STANDALONE2)
|
||||
static char *compose_func_args(struct expr_node *arglist)
|
||||
{
|
||||
struct expr_node *t = arglist;
|
||||
@@ -974,7 +1031,7 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
|
||||
#endif
|
||||
} else {
|
||||
/* is this a custom function we should execute and collect the results of? */
|
||||
#ifndef STANDALONE
|
||||
#if !defined(STANDALONE) && !defined(STANDALONE2)
|
||||
struct ast_custom_function *f = ast_custom_function_find(funcname->u.s);
|
||||
if (!chan)
|
||||
ast_log(LOG_WARNING,"Hey! chan is NULL.\n");
|
||||
|
Reference in New Issue
Block a user