diff options
-rw-r--r-- | include/asterisk/extconf.h | 4 | ||||
-rw-r--r-- | pbx/ael/ael-test/ael-ntest23/extensions.ael | 7 | ||||
-rw-r--r-- | pbx/ael/ael-test/ael-ntest23/qq.ael | 6 | ||||
-rw-r--r-- | pbx/ael/ael-test/ael-ntest23/t1/a.ael | 4 | ||||
-rw-r--r-- | pbx/ael/ael-test/ael-ntest23/t1/b.ael | 6 | ||||
-rw-r--r-- | pbx/ael/ael-test/ael-ntest23/t1/c.ael | 13 | ||||
-rw-r--r-- | pbx/ael/ael-test/ael-ntest23/t2/d.ael | 4 | ||||
-rw-r--r-- | pbx/ael/ael-test/ael-ntest23/t2/e.ael | 6 | ||||
-rw-r--r-- | pbx/ael/ael-test/ael-ntest23/t2/f.ael | 9 | ||||
-rw-r--r-- | pbx/ael/ael-test/ael-ntest23/t3/g.ael | 4 | ||||
-rw-r--r-- | pbx/ael/ael-test/ael-ntest23/t3/h.ael | 6 | ||||
-rw-r--r-- | pbx/ael/ael-test/ael-ntest23/t3/i.ael | 4 | ||||
-rw-r--r-- | pbx/ael/ael-test/ael-ntest23/t3/j.ael | 6 | ||||
-rw-r--r-- | pbx/ael/ael-test/ref.ael-ntest23 | 24 | ||||
-rw-r--r-- | res/ael/ael.flex | 20 | ||||
-rw-r--r-- | res/ael/ael_lex.c | 27 | ||||
-rw-r--r-- | utils/ael_main.c | 4 | ||||
-rw-r--r-- | utils/conf2ael.c | 4 | ||||
-rw-r--r-- | utils/extconf.c | 12 |
19 files changed, 136 insertions, 34 deletions
diff --git a/include/asterisk/extconf.h b/include/asterisk/extconf.h index 7f248d912..086271ce5 100644 --- a/include/asterisk/extconf.h +++ b/include/asterisk/extconf.h @@ -174,7 +174,7 @@ struct ast_sw *localized_walk_context_switches(struct ast_context *con, void localized_context_destroy(struct ast_context *con, const char *registrar); int localized_pbx_load_module(void); -struct ast_context *localized_context_create(struct ast_context **extcontexts, const char *name, const char *registrar); +struct ast_context *localized_context_find_or_create(struct ast_context **extcontexts, void *tab, const char *name, const char *registrar); int localized_pbx_builtin_setvar(struct ast_channel *chan, void *data); int localized_context_add_ignorepat2(struct ast_context *con, const char *value, const char *registrar); int localized_context_add_switch2(struct ast_context *con, const char *value, @@ -185,7 +185,7 @@ int localized_add_extension2(struct ast_context *con, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void (*datad)(void *), const char *registrar); -void localized_merge_contexts_and_delete(struct ast_context **extcontexts, const char *registrar); +void localized_merge_contexts_and_delete(struct ast_context **extcontexts, void *tab, const char *registrar); int localized_context_verify_includes(struct ast_context *con); void localized_use_conf_dir(void); void localized_use_local_dir(void); diff --git a/pbx/ael/ael-test/ael-ntest23/extensions.ael b/pbx/ael/ael-test/ael-ntest23/extensions.ael new file mode 100644 index 000000000..7128258ed --- /dev/null +++ b/pbx/ael/ael-test/ael-ntest23/extensions.ael @@ -0,0 +1,7 @@ +#include "t1/*.ael" + +context z () +{ + 123 => NoOp(hi there, z); + 124 => NoOp(hi there, z); +} diff --git a/pbx/ael/ael-test/ael-ntest23/qq.ael b/pbx/ael/ael-test/ael-ntest23/qq.ael new file mode 100644 index 000000000..c446f53fc --- /dev/null +++ b/pbx/ael/ael-test/ael-ntest23/qq.ael @@ -0,0 +1,6 @@ + + +context qq +{ + 567 => NoOp(hi there, qq); +} diff --git a/pbx/ael/ael-test/ael-ntest23/t1/a.ael b/pbx/ael/ael-test/ael-ntest23/t1/a.ael new file mode 100644 index 000000000..62e3fc588 --- /dev/null +++ b/pbx/ael/ael-test/ael-ntest23/t1/a.ael @@ -0,0 +1,4 @@ +context a +{ + 134 => NoOp(hi there, a); +} diff --git a/pbx/ael/ael-test/ael-ntest23/t1/b.ael b/pbx/ael/ael-test/ael-ntest23/t1/b.ael new file mode 100644 index 000000000..29d8d1ff4 --- /dev/null +++ b/pbx/ael/ael-test/ael-ntest23/t1/b.ael @@ -0,0 +1,6 @@ + + +context b +{ + 456 => NoOp(hithere, b); +} diff --git a/pbx/ael/ael-test/ael-ntest23/t1/c.ael b/pbx/ael/ael-test/ael-ntest23/t1/c.ael new file mode 100644 index 000000000..d18eb7677 --- /dev/null +++ b/pbx/ael/ael-test/ael-ntest23/t1/c.ael @@ -0,0 +1,13 @@ + + +context c() +{ + 567 => NoOp(hi there, c); +} + +#include "t2/*.ael" + +context w() +{ + 890 => NoOp(hi there, w); +} diff --git a/pbx/ael/ael-test/ael-ntest23/t2/d.ael b/pbx/ael/ael-test/ael-ntest23/t2/d.ael new file mode 100644 index 000000000..6362278f7 --- /dev/null +++ b/pbx/ael/ael-test/ael-ntest23/t2/d.ael @@ -0,0 +1,4 @@ +context d +{ + 134 => NoOp(hi there, d); +} diff --git a/pbx/ael/ael-test/ael-ntest23/t2/e.ael b/pbx/ael/ael-test/ael-ntest23/t2/e.ael new file mode 100644 index 000000000..9465c8b4e --- /dev/null +++ b/pbx/ael/ael-test/ael-ntest23/t2/e.ael @@ -0,0 +1,6 @@ + + +context e +{ + 456 => NoOp(hithere, e); +} diff --git a/pbx/ael/ael-test/ael-ntest23/t2/f.ael b/pbx/ael/ael-test/ael-ntest23/t2/f.ael new file mode 100644 index 000000000..ba15a6389 --- /dev/null +++ b/pbx/ael/ael-test/ael-ntest23/t2/f.ael @@ -0,0 +1,9 @@ +#include "qq.ael" + +context f +{ + 567 => NoOp(hi there, f); +} + +#include "t3/*.ael" + diff --git a/pbx/ael/ael-test/ael-ntest23/t3/g.ael b/pbx/ael/ael-test/ael-ntest23/t3/g.ael new file mode 100644 index 000000000..0f1ecc805 --- /dev/null +++ b/pbx/ael/ael-test/ael-ntest23/t3/g.ael @@ -0,0 +1,4 @@ +context g +{ + 134 => NoOp(hi there, g); +} diff --git a/pbx/ael/ael-test/ael-ntest23/t3/h.ael b/pbx/ael/ael-test/ael-ntest23/t3/h.ael new file mode 100644 index 000000000..f9e3ca89f --- /dev/null +++ b/pbx/ael/ael-test/ael-ntest23/t3/h.ael @@ -0,0 +1,6 @@ + + +context h +{ + 456 => NoOp(hithere, h); +} diff --git a/pbx/ael/ael-test/ael-ntest23/t3/i.ael b/pbx/ael/ael-test/ael-ntest23/t3/i.ael new file mode 100644 index 000000000..5639a1e98 --- /dev/null +++ b/pbx/ael/ael-test/ael-ntest23/t3/i.ael @@ -0,0 +1,4 @@ +context i +{ + 134 => NoOp(hi there, i); +} diff --git a/pbx/ael/ael-test/ael-ntest23/t3/j.ael b/pbx/ael/ael-test/ael-ntest23/t3/j.ael new file mode 100644 index 000000000..8dfc6c05f --- /dev/null +++ b/pbx/ael/ael-test/ael-ntest23/t3/j.ael @@ -0,0 +1,6 @@ + + +context j +{ + 567 => NoOp(hi there, j); +} diff --git a/pbx/ael/ael-test/ref.ael-ntest23 b/pbx/ael/ael-test/ref.ael-ntest23 new file mode 100644 index 000000000..b7b4852ec --- /dev/null +++ b/pbx/ael/ael-test/ref.ael-ntest23 @@ -0,0 +1,24 @@ + +(If you find progress and other non-error messages irritating, you can use -q to suppress them) + +(You can use the -n option if you aren't interested in seeing all the instructions generated by the compiler) + + +(You can use the -w option to dump extensions.conf format to extensions.conf.aeldump) +LOG: lev:2 file:pbx_ael.c line:116 func: pbx_load_module Starting AEL load process. +LOG: lev:2 file:ael.flex line:672 func: setup_filestack --Read in included file ././t1/a.ael, 41 chars +LOG: lev:2 file:ael.flex line:672 func: setup_filestack --Read in included file ././t1/b.ael, 42 chars +LOG: lev:2 file:ael.flex line:672 func: setup_filestack --Read in included file ././t1/c.ael, 110 chars +LOG: lev:4 file:ael.y line:774 func: ael_yyerror ==== File: ././t1/c.ael, Line 3, Cols: 10-10: Error: syntax error, unexpected '(', expecting '{' +LOG: lev:2 file:ael.flex line:672 func: setup_filestack --Read in included file ././t2/d.ael, 41 chars +LOG: lev:2 file:ael.flex line:672 func: setup_filestack --Read in included file ././t2/e.ael, 42 chars +LOG: lev:2 file:ael.flex line:672 func: setup_filestack --Read in included file ././t2/f.ael, 82 chars +LOG: lev:2 file:ael.flex line:672 func: setup_filestack --Read in included file ././qq.ael, 45 chars +LOG: lev:2 file:ael.flex line:672 func: setup_filestack --Read in included file ././t3/g.ael, 41 chars +LOG: lev:2 file:ael.flex line:672 func: setup_filestack --Read in included file ././t3/h.ael, 42 chars +LOG: lev:2 file:ael.flex line:672 func: setup_filestack --Read in included file ././t3/i.ael, 41 chars +LOG: lev:2 file:ael.flex line:672 func: setup_filestack --Read in included file ././t3/j.ael, 43 chars +LOG: lev:4 file:ael.y line:774 func: ael_yyerror ==== File: ././t1/c.ael, Line 10, Cols: 10-10: Error: syntax error, unexpected '(', expecting '{' +LOG: lev:2 file:pbx_ael.c line:129 func: pbx_load_module AEL load process: parsed config file name './extensions.ael'. +LOG: lev:4 file:pbx_ael.c line:145 func: pbx_load_module Sorry, but 2 syntax errors and 0 semantic errors were detected. It doesn't make sense to compile. +LOG: lev:4 file:ael2_parse line:544 func: main 0 contexts, 0 extensions, 0 priorities diff --git a/res/ael/ael.flex b/res/ael/ael.flex index 1ca6427f4..4d7790ec8 100644 --- a/res/ael/ael.flex +++ b/res/ael/ael.flex @@ -447,8 +447,6 @@ includes { STORE_POS; return KW_INCLUDES;} <<EOF>> { char fnamebuf[2048]; if (include_stack_index > 0 && include_stack[include_stack_index-1].globbuf_pos < include_stack[include_stack_index-1].globbuf.gl_pathc-1) { - free(my_file); - my_file = 0; yy_delete_buffer( YY_CURRENT_BUFFER, yyscanner ); include_stack[include_stack_index-1].globbuf_pos++; setup_filestack(fnamebuf, sizeof(fnamebuf), &include_stack[include_stack_index-1].globbuf, include_stack[include_stack_index-1].globbuf_pos, yyscanner, 0); @@ -459,13 +457,13 @@ includes { STORE_POS; return KW_INCLUDES;} free(include_stack[include_stack_index].fname); include_stack[include_stack_index].fname = 0; } + if (my_file) { + free(my_file); + my_file = 0; + } if ( --include_stack_index < 0 ) { yyterminate(); } else { - if (my_file) { - free(my_file); - my_file = 0; - } globfree(&include_stack[include_stack_index].globbuf); include_stack[include_stack_index].globbuf_pos = -1; @@ -672,12 +670,16 @@ static void setup_filestack(char *fnamebuf2, int fnamebuf_siz, glob_t *globbuf, buffer[stats.st_size] = 0; ast_log(LOG_NOTICE," --Read in included file %s, %d chars\n",fnamebuf2, (int)stats.st_size); fclose(in1); - if (my_file) - free(my_file); - my_file = strdup(fnamebuf2); + if (include_stack[include_stack_index].fname) { + free(include_stack[include_stack_index].fname); + include_stack[include_stack_index].fname = 0; + } include_stack[include_stack_index].fname = strdup(my_file); include_stack[include_stack_index].lineno = my_lineno; include_stack[include_stack_index].colno = my_col+yyleng; + if (my_file) + free(my_file); + my_file = strdup(fnamebuf2); if (create) include_stack[include_stack_index].globbuf = *globbuf; diff --git a/res/ael/ael_lex.c b/res/ael/ael_lex.c index 8b7436374..bc2b2bf28 100644 --- a/res/ael/ael_lex.c +++ b/res/ael/ael_lex.c @@ -793,6 +793,7 @@ static yyconst flex_int16_t yy_chk[1035] = * bison-locations is probably not needed. */ #line 63 "ael.flex" +#include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include <sys/types.h> @@ -1746,8 +1747,6 @@ case YY_STATE_EOF(comment): { char fnamebuf[2048]; if (include_stack_index > 0 && include_stack[include_stack_index-1].globbuf_pos < include_stack[include_stack_index-1].globbuf.gl_pathc-1) { - free(my_file); - my_file = 0; ael_yy_delete_buffer(YY_CURRENT_BUFFER,yyscanner ); include_stack[include_stack_index-1].globbuf_pos++; setup_filestack(fnamebuf, sizeof(fnamebuf), &include_stack[include_stack_index-1].globbuf, include_stack[include_stack_index-1].globbuf_pos, yyscanner, 0); @@ -1758,13 +1757,13 @@ case YY_STATE_EOF(comment): free(include_stack[include_stack_index].fname); include_stack[include_stack_index].fname = 0; } + if (my_file) { + free(my_file); + my_file = 0; + } if ( --include_stack_index < 0 ) { yyterminate(); } else { - if (my_file) { - free(my_file); - my_file = 0; - } globfree(&include_stack[include_stack_index].globbuf); include_stack[include_stack_index].globbuf_pos = -1; @@ -1779,10 +1778,10 @@ case YY_STATE_EOF(comment): YY_BREAK case 63: YY_RULE_SETUP -#line 481 "ael.flex" +#line 479 "ael.flex" ECHO; YY_BREAK -#line 1786 "ael_lex.c" +#line 1784 "ael_lex.c" case YY_END_OF_BUFFER: { @@ -2907,7 +2906,7 @@ void *ael_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 481 "ael.flex" +#line 479 "ael.flex" @@ -3103,12 +3102,16 @@ static void setup_filestack(char *fnamebuf2, int fnamebuf_siz, glob_t *globbuf, buffer[stats.st_size] = 0; ast_log(LOG_NOTICE," --Read in included file %s, %d chars\n",fnamebuf2, (int)stats.st_size); fclose(in1); - if (my_file) - free(my_file); - my_file = strdup(fnamebuf2); + if (include_stack[include_stack_index].fname) { + free(include_stack[include_stack_index].fname); + include_stack[include_stack_index].fname = 0; + } include_stack[include_stack_index].fname = strdup(my_file); include_stack[include_stack_index].lineno = my_lineno; include_stack[include_stack_index].colno = my_col+yyleng; + if (my_file) + free(my_file); + my_file = strdup(fnamebuf2); if (create) include_stack[include_stack_index].globbuf = *globbuf; diff --git a/utils/ael_main.c b/utils/ael_main.c index 24349b457..74a432fa9 100644 --- a/utils/ael_main.c +++ b/utils/ael_main.c @@ -97,7 +97,7 @@ int ast_add_extension2(struct ast_context *con, const char *registrar); void pbx_builtin_setvar(void *chan, void *data); struct ast_context * ast_context_create(void **extcontexts, const char *name, const char *registrar); -struct ast_context * ast_context_find_or_create(void **extcontexts, const char *name, const char *registrar); +struct ast_context * ast_context_find_or_create(void **extcontexts, void *tab, const char *name, const char *registrar); void ast_context_add_ignorepat2(struct ast_context *con, const char *value, const char *registrar); void ast_context_add_include2(struct ast_context *con, const char *value, const char *registrar); void ast_context_add_switch2(struct ast_context *con, const char *value, const char *data, int eval, const char *registrar); @@ -361,7 +361,7 @@ struct ast_context * ast_context_create(void **extcontexts, const char *name, co return x; } -struct ast_context * ast_context_find_or_create(void **extcontexts, const char *name, const char *registrar) +struct ast_context * ast_context_find_or_create(void **extcontexts, void *tab, const char *name, const char *registrar) { struct ast_context *x = calloc(1, sizeof(*x)); if (!x) diff --git a/utils/conf2ael.c b/utils/conf2ael.c index 56856efbf..c69486a33 100644 --- a/utils/conf2ael.c +++ b/utils/conf2ael.c @@ -610,7 +610,7 @@ struct ast_context *ast_context_find_or_create(struct ast_context **extcontexts, { printf("find/Creating context %s, registrar=%s\n", name, registrar); - return localized_context_create(extcontexts, name, registrar); + return localized_context_find_or_create(extcontexts, exttable, name, registrar); } void ast_cli_register_multiple(void); @@ -657,7 +657,7 @@ void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_ void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *registrar) { - localized_merge_contexts_and_delete(extcontexts, registrar); + localized_merge_contexts_and_delete(extcontexts, exttable, registrar); } struct ast_exten *pbx_find_extension(struct ast_channel *chan, diff --git a/utils/extconf.c b/utils/extconf.c index 9903ff295..4ff6e1dc0 100644 --- a/utils/extconf.c +++ b/utils/extconf.c @@ -5520,20 +5520,18 @@ static int ast_findlabel_extension2(struct ast_channel *c, struct ast_context *c return pbx_extension_helper(c, con, NULL, exten, 0, label, callerid, E_FINDLABEL); } -static struct ast_context *ast_context_find_or_create(struct ast_context **extcontexts, const char *name, const char *registrar) +static struct ast_context *ast_context_find_or_create(struct ast_context **extcontexts, void *tab, const char *name, const char *registrar) { return __ast_context_create(extcontexts, name, registrar, 1); } -struct ast_context *localized_context_create(struct ast_context **extcontexts, const char *name, const char *registrar); - -struct ast_context *localized_context_create(struct ast_context **extcontexts, const char *name, const char *registrar) +struct ast_context *localized_context_find_or_create(struct ast_context **extcontexts, void *tab, const char *name, const char *registrar); +struct ast_context *localized_context_find_or_create(struct ast_context **extcontexts, void *tab, const char *name, const char *registrar) { - return __ast_context_create(extcontexts, name, registrar, 0); + return __ast_context_create(extcontexts, name, registrar, 1); } - /* chopped this one off at the knees */ static int ast_func_read(struct ast_channel *chan, const char *function, char *workspace, size_t len) { @@ -5916,7 +5914,7 @@ static int pbx_load_config(const char *config_file) /* All categories but "general" or "globals" are considered contexts */ if (!strcasecmp(cxt, "general") || !strcasecmp(cxt, "globals")) continue; - con=ast_context_find_or_create(&local_contexts,cxt, registrar); + con=ast_context_find_or_create(&local_contexts,NULL,cxt, registrar); if (con == NULL) continue; |