diff options
author | murf <murf@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-08-25 20:43:51 +0000 |
---|---|---|
committer | murf <murf@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-08-25 20:43:51 +0000 |
commit | 5c397dd961a90d25cbc91f99895db258769b296b (patch) | |
tree | 25fd0c92bb7447c5a6951056b0d2ae97b6c89782 /pbx | |
parent | 4d8047ba7c7500cd0873c0cfa42882956bf82416 (diff) |
Changes to fix all problems reported in 7804 are included here.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@41150 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'pbx')
-rw-r--r-- | pbx/ael/ael-test/ael-test14/extensions.ael | 20 | ||||
-rw-r--r-- | pbx/ael/ael-test/ref.ael-test14 | 11 | ||||
-rw-r--r-- | pbx/pbx_ael.c | 73 |
3 files changed, 95 insertions, 9 deletions
diff --git a/pbx/ael/ael-test/ael-test14/extensions.ael b/pbx/ael/ael-test/ael-test14/extensions.ael new file mode 100644 index 000000000..20d69134f --- /dev/null +++ b/pbx/ael/ael-test/ael-test14/extensions.ael @@ -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; + } + +} diff --git a/pbx/ael/ael-test/ref.ael-test14 b/pbx/ael/ael-test/ref.ael-test14 new file mode 100644 index 000000000..842648228 --- /dev/null +++ b/pbx/ael/ael-test/ref.ael-test14 @@ -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 diff --git a/pbx/pbx_ael.c b/pbx/pbx_ael.c index 0110c5e37..c45f73601 100644 --- a/pbx/pbx_ael.c +++ b/pbx/pbx_ael.c @@ -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 ============================================================================ */ |