mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 12:16:00 +00:00
Changes to fix all problems reported in 7804 are included here.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@41150 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
20
pbx/ael/ael-test/ael-test14/extensions.ael
Normal file
20
pbx/ael/ael-test/ael-test14/extensions.ael
Normal file
@@ -0,0 +1,20 @@
|
||||
context test1
|
||||
{
|
||||
10 => {
|
||||
// nothing but a comment!
|
||||
}
|
||||
|
||||
11 => {
|
||||
switch(${somevar})
|
||||
{
|
||||
case somecase:
|
||||
// nothing but a comment!
|
||||
break;
|
||||
case somecase:
|
||||
// nothing but a comment!
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
11
pbx/ael/ael-test/ref.ael-test14
Normal file
11
pbx/ael/ael-test/ref.ael-test14
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
(If you find progress and other non-error messages irritating, you can use -q to suppress them)
|
||||
|
||||
(You can use the -w option to dump extensions.conf format to extensions.conf.aeldump)
|
||||
LOG: lev:2 file:../pbx/pbx_ael.c line:3801 func: pbx_load_module Starting AEL load process.
|
||||
LOG: lev:2 file:../pbx/pbx_ael.c line:3808 func: pbx_load_module AEL load process: calculated config file name './extensions.ael'.
|
||||
LOG: lev:2 file:../pbx/pbx_ael.c line:3811 func: pbx_load_module AEL load process: parsed config file name './extensions.ael'.
|
||||
LOG: lev:4 file:../pbx/pbx_ael.c line:1045 func: check_continue Error: file ./extensions.ael, line 15-15: 'continue' not in 'for' or 'while' statement!
|
||||
LOG: lev:4 file:../pbx/pbx_ael.c line:1026 func: check_break Error: file ./extensions.ael, line 17-17: 'break' not in switch, for, or while statement!
|
||||
LOG: lev:4 file:../pbx/pbx_ael.c line:3824 func: pbx_load_module Sorry, but 0 syntax errors and 2 semantic errors were detected. It doesn't make sense to compile.
|
||||
LOG: lev:4 file:ael2_parse line:479 func: main 0 contexts, 0 extensions, 0 priorities
|
@@ -58,11 +58,10 @@ static char expr_output[2096];
|
||||
|
||||
static char *config = "extensions.ael";
|
||||
static char *registrar = "pbx_ael";
|
||||
static int pbx_load_module(void);
|
||||
|
||||
static int errs, warns;
|
||||
#ifndef STANDALONE_AEL
|
||||
static int notes;
|
||||
#endif
|
||||
|
||||
#ifndef AAL_ARGCHECK
|
||||
/* for the time being, short circuit all the AAL related structures
|
||||
@@ -1009,6 +1008,46 @@ static void check_month(pval *MON)
|
||||
e = s;
|
||||
}
|
||||
|
||||
static int check_break(pval *item)
|
||||
{
|
||||
pval *p = item;
|
||||
|
||||
while( p && p->type != PV_MACRO && p->type != PV_CONTEXT ) /* early cutout, sort of */ {
|
||||
/* a break is allowed in WHILE, FOR, CASE, DEFAULT, PATTERN; otherwise, it don't make
|
||||
no sense */
|
||||
if( p->type == PV_CASE || p->type == PV_DEFAULT || p->type == PV_PATTERN
|
||||
|| p->type == PV_WHILE || p->type == PV_FOR ) {
|
||||
return 1;
|
||||
}
|
||||
p = p->dad;
|
||||
}
|
||||
ast_log(LOG_ERROR,"Error: file %s, line %d-%d: 'break' not in switch, for, or while statement!\n",
|
||||
item->filename, item->startline, item->endline);
|
||||
errs++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int check_continue(pval *item)
|
||||
{
|
||||
pval *p = item;
|
||||
|
||||
while( p && p->type != PV_MACRO && p->type != PV_CONTEXT ) /* early cutout, sort of */ {
|
||||
/* a break is allowed in WHILE, FOR, CASE, DEFAULT, PATTERN; otherwise, it don't make
|
||||
no sense */
|
||||
if( p->type == PV_WHILE || p->type == PV_FOR ) {
|
||||
return 1;
|
||||
}
|
||||
p = p->dad;
|
||||
}
|
||||
ast_log(LOG_ERROR,"Error: file %s, line %d-%d: 'continue' not in 'for' or 'while' statement!\n",
|
||||
item->filename, item->startline, item->endline);
|
||||
errs++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* general purpose goto finder */
|
||||
|
||||
static void check_label(pval *item)
|
||||
@@ -2092,7 +2131,6 @@ void check_switch_expr(pval *item, struct argapp *apps)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef STANDALONE_AEL
|
||||
static void check_context_names(void)
|
||||
{
|
||||
pval *i,*j;
|
||||
@@ -2111,7 +2149,6 @@ static void check_context_names(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void check_abstract_reference(pval *abstract_context)
|
||||
{
|
||||
@@ -2438,6 +2475,7 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals)
|
||||
case PV_BREAK:
|
||||
/* fields: none
|
||||
*/
|
||||
check_break(item);
|
||||
break;
|
||||
|
||||
case PV_RETURN:
|
||||
@@ -2448,6 +2486,7 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals)
|
||||
case PV_CONTINUE:
|
||||
/* fields: none
|
||||
*/
|
||||
check_continue(item);
|
||||
break;
|
||||
|
||||
case PV_RANDOM:
|
||||
@@ -2576,7 +2615,6 @@ void check_pval(pval *item, struct argapp *apps, int in_globals)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef STANDALONE_AEL
|
||||
static void ael2_semantic_check(pval *item, int *arg_errs, int *arg_warns, int *arg_notes)
|
||||
{
|
||||
|
||||
@@ -2607,7 +2645,6 @@ static void ael2_semantic_check(pval *item, int *arg_errs, int *arg_warns, int *
|
||||
*arg_warns = warns;
|
||||
*arg_notes = notes;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* =============================================================================================== */
|
||||
/* "CODE" GENERATOR -- Convert the AEL representation to asterisk extension language */
|
||||
@@ -3658,7 +3695,13 @@ void ast_compile_ael2(struct ast_context **local_contexts, struct pval *root)
|
||||
exten-> return_target = np2;
|
||||
}
|
||||
/* is the last priority in the extension a label? Then add a trailing no-op */
|
||||
if ( exten->plist_last->type == AEL_LABEL ) {
|
||||
if( !exten->plist_last )
|
||||
{
|
||||
ast_log(LOG_WARNING, "Warning: file %s, line %d-%d: Empty Extension!\n",
|
||||
p2->filename, p2->startline, p2->endline);
|
||||
}
|
||||
|
||||
if ( exten->plist_last && exten->plist_last->type == AEL_LABEL ) {
|
||||
struct ael_priority *np2 = new_prio();
|
||||
np2->type = AEL_APPCALL;
|
||||
np2->app = strdup("NoOp");
|
||||
@@ -3737,11 +3780,13 @@ void ast_compile_ael2(struct ast_context **local_contexts, struct pval *root)
|
||||
|
||||
}
|
||||
|
||||
#ifndef STANDALONE_AEL
|
||||
|
||||
static int aeldebug = 0;
|
||||
|
||||
/* interface stuff */
|
||||
|
||||
/* if all the below are static, who cares if they are present? */
|
||||
|
||||
static int pbx_load_module(void)
|
||||
{
|
||||
int errs, sem_err, sem_warn, sem_note;
|
||||
@@ -3844,12 +3889,22 @@ static int reload(void)
|
||||
return pbx_load_module();
|
||||
}
|
||||
|
||||
#ifdef STANDALONE_AEL
|
||||
#define AST_MODULE "ael"
|
||||
int ael_external_load_module(void);
|
||||
int ael_external_load_module(void)
|
||||
{
|
||||
pbx_load_module();
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Asterisk Extension Language Compiler",
|
||||
.load = load_module,
|
||||
.unload = unload_module,
|
||||
.reload = reload,
|
||||
);
|
||||
#endif
|
||||
|
||||
|
||||
/* DESTROY the PVAL tree ============================================================================ */
|
||||
|
||||
|
@@ -68,12 +68,12 @@ stereorize: LIBS+=-lm
|
||||
$(eval $(call ast_make_o_c,ast_expr2.o,../main/ast_expr2.c))
|
||||
|
||||
$(eval $(call ast_make_o_c,ast_expr2f.o,../main/ast_expr2f.c))
|
||||
ast_expr2f.o: CFLAGS+=-DSTANDALONE
|
||||
ast_expr2f.o: CFLAGS+=-DSTANDALONE_AEL
|
||||
|
||||
$(eval $(call ast_make_final,check_expr,check_expr.c ast_expr2.o ast_expr2f.o))
|
||||
|
||||
$(eval $(call ast_make_o_c,aelflex.o,../pbx/ael/ael_lex.c ../include/asterisk/ael_structs.h ../pbx/ael/ael.tab.h))
|
||||
aelflex.o: CFLAGS+=-I../pbx -DSTANDALONE
|
||||
aelflex.o: CFLAGS+=-I../pbx -DSTANDALONE_AEL
|
||||
|
||||
$(eval $(call ast_make_o_c,aelbison.o,../pbx/ael/ael.tab.c ../pbx/ael/ael.tab.h ../include/asterisk/ael_structs.h))
|
||||
aelbison.o: CFLAGS+=-I../pbx
|
||||
@@ -86,8 +86,8 @@ $(eval $(call ast_make_final,aelparse,aelflex.o aelbison.o pbx_ael.o ael_main.o
|
||||
$(eval $(call ast_make_o_c,ael_main.o,ael_main.c ../include/asterisk/ael_structs.h))
|
||||
|
||||
testexpr2s: ../main/ast_expr2f.c ../main/ast_expr2.c ../main/ast_expr2.h
|
||||
$(CC) -g -c -I../include -DSTANDALONE ../main/ast_expr2f.c -o ast_expr2f.o
|
||||
$(CC) -g -c -I../include -DSTANDALONE ../main/ast_expr2.c -o ast_expr2.o
|
||||
$(CC) -g -c -I../include -DSTANDALONE_AEL ../main/ast_expr2f.c -o ast_expr2f.o
|
||||
$(CC) -g -c -I../include -DSTANDALONE_AEL ../main/ast_expr2.c -o ast_expr2.o
|
||||
$(CC) -g -o testexpr2s ast_expr2f.o ast_expr2.o
|
||||
rm ast_expr2.o ast_expr2f.o
|
||||
./testexpr2s expr2.testinput
|
||||
|
@@ -119,6 +119,24 @@ void ast_add_profile(void)
|
||||
printf("Executed ast_add_profile();\n");
|
||||
}
|
||||
|
||||
int ast_loader_register(int (*updater)(void))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ast_loader_unregister(int (*updater)(void))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
void ast_module_register(const struct ast_module_info *x)
|
||||
{
|
||||
}
|
||||
|
||||
void ast_module_unregister(const struct ast_module_info *x)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ast_cli_register_multiple(void)
|
||||
{
|
||||
if(!no_comp)
|
||||
@@ -406,6 +424,7 @@ void filter_newlines(char *str)
|
||||
|
||||
|
||||
extern struct module_symbols mod_data;
|
||||
extern ael_external_load_module(void);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
@@ -455,7 +474,7 @@ int main(int argc, char **argv)
|
||||
|
||||
FIRST_TIME = 1;
|
||||
|
||||
ast_module_info->load();
|
||||
ael_external_load_module();
|
||||
|
||||
ast_log(4, "ael2_parse", __LINE__, "main", "%d contexts, %d extensions, %d priorities\n", conts, extens, priors);
|
||||
|
||||
|
Reference in New Issue
Block a user