mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 04:11:08 +00:00
closes issue #11086 where a user complains that references to following contexts report a problem; The problem was REALLy that he was referring to empty contexts, which were being ignored. Reporter stated that empty contexts should be OK. I checked it out against extensions.conf, and sure enough, empty contexts ARE ok. So, I removed the restriction from AEL. This, though, highlighted a problem with multiple contexts of the same name. This should be OK, also. So, I added the extend keyword to AEL, and it can preceed the 'context' keyword (mixed with 'abstract', if nec.). This will turn off the warnings in AEL if the same context name is used 2 or more times. Also, I now call ast_context_find_or_create for contexts now, instead of just ast_context_create; I did this because pbx_config does this. The 'extend' keyword thus becomes a statement of intent. AEL can now duplicate the behavior of pbx_config,
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@87168 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -97,10 +97,11 @@ struct pval
|
||||
char *for_inc; /* used in FOR */
|
||||
struct pval *else_statements; /* used in IF */
|
||||
struct pval *macro_statements; /* used in MACRO */
|
||||
int abstract; /* used for context */
|
||||
int abstract; /* used for context 1=abstract; 2=extend; 3=both */
|
||||
char *hints; /* used in EXTENSION */
|
||||
int goto_target_in_case; /* used in GOTO */
|
||||
struct ael_extension *compiled_label;
|
||||
struct pval *extend; /* to link extended contexts to the 'original' */
|
||||
} u3;
|
||||
|
||||
union
|
||||
|
@@ -2,13 +2,12 @@
|
||||
(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_ael.c line:3914 func: pbx_load_module Starting AEL load process.
|
||||
LOG: lev:2 file:pbx_ael.c line:3921 func: pbx_load_module AEL load process: calculated config file name './extensions.ael'.
|
||||
LOG: lev:3 file:ael.y line:205 func: ael_yyparse ==== File: ./extensions.ael, Line 1, Cols: 19-19: Warning! The empty context real-small will be IGNORED!
|
||||
LOG: lev:2 file:pbx_ael.c line:3929 func: pbx_load_module AEL load process: parsed config file name './extensions.ael'.
|
||||
LOG: lev:2 file:pbx_ael.c line:3932 func: pbx_load_module AEL load process: checked config file name './extensions.ael'.
|
||||
LOG: lev:3 file:pbx_ael.c line:3545 func: add_extensions This file is Empty!
|
||||
LOG: lev:2 file:pbx_ael.c line:3934 func: pbx_load_module AEL load process: compiled config file name './extensions.ael'.
|
||||
LOG: lev:2 file:pbx_ael.c line:3937 func: pbx_load_module AEL load process: merged config file name './extensions.ael'.
|
||||
LOG: lev:2 file:pbx_ael.c line:3940 func: pbx_load_module AEL load process: verified config file name './extensions.ael'.
|
||||
LOG: lev:4 file:ael2_parse line:479 func: main 0 contexts, 0 extensions, 0 priorities
|
||||
LOG: lev:2 file:pbx_ael.c line:4090 func: pbx_load_module Starting AEL load process.
|
||||
LOG: lev:2 file:pbx_ael.c line:4097 func: pbx_load_module AEL load process: calculated config file name './extensions.ael'.
|
||||
LOG: lev:2 file:pbx_ael.c line:4105 func: pbx_load_module AEL load process: parsed config file name './extensions.ael'.
|
||||
LOG: lev:2 file:pbx_ael.c line:4108 func: pbx_load_module AEL load process: checked config file name './extensions.ael'.
|
||||
LOG: lev:3 file:pbx_ael.c line:3685 func: add_extensions This file is Empty!
|
||||
LOG: lev:2 file:pbx_ael.c line:4110 func: pbx_load_module AEL load process: compiled config file name './extensions.ael'.
|
||||
LOG: lev:2 file:pbx_ael.c line:4113 func: pbx_load_module AEL load process: merged config file name './extensions.ael'.
|
||||
LOG: lev:2 file:pbx_ael.c line:4116 func: pbx_load_module AEL load process: verified config file name './extensions.ael'.
|
||||
LOG: lev:4 file:ael2_parse line:543 func: main 1 contexts, 0 extensions, 0 priorities
|
||||
|
@@ -2,13 +2,13 @@
|
||||
(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_ael.c line:3978 func: pbx_load_module Starting AEL load process.
|
||||
LOG: lev:2 file:pbx_ael.c line:3985 func: pbx_load_module AEL load process: calculated config file name './extensions.ael'.
|
||||
LOG: lev:2 file:pbx_ael.c line:3993 func: pbx_load_module AEL load process: parsed config file name './extensions.ael'.
|
||||
LOG: lev:4 file:pbx_ael.c line:2250 func: check_context_names Error: file ./extensions.ael, line 49-62: The context name (incoming) is also declared in file ./extensions.ael, line 62-69!
|
||||
LOG: lev:2 file:pbx_ael.c line:4090 func: pbx_load_module Starting AEL load process.
|
||||
LOG: lev:2 file:pbx_ael.c line:4097 func: pbx_load_module AEL load process: calculated config file name './extensions.ael'.
|
||||
LOG: lev:2 file:pbx_ael.c line:4105 func: pbx_load_module AEL load process: parsed config file name './extensions.ael'.
|
||||
LOG: lev:4 file:pbx_ael.c line:2250 func: check_context_names Error: file ./extensions.ael, line 49-62: The context name (incoming) is also declared in file ./extensions.ael, line 62-69! (and neither is marked 'extend')
|
||||
LOG: lev:3 file:pbx_ael.c line:2234 func: check_switch_expr Warning: file ./extensions.ael, line 245-246: A default case was automatically added to the switch.
|
||||
LOG: lev:3 file:pbx_ael.c line:2347 func: check_pval_item Warning: file ./extensions.ael, line 312-312: macro call to non-existent funcA ! Hopefully it is present in extensions.conf!
|
||||
LOG: lev:3 file:pbx_ael.c line:2347 func: check_pval_item Warning: file ./extensions.ael, line 313-313: macro call to non-existent funcD ! Hopefully it is present in extensions.conf!
|
||||
LOG: lev:3 file:pbx_ael.c line:1287 func: check_goto Warning: file ./extensions.ael, line 319-319: goto: no context test5 could be found that matches the goto target!
|
||||
LOG: lev:4 file:pbx_ael.c line:4006 func: pbx_load_module Sorry, but 0 syntax errors and 1 semantic errors were detected. It doesn't make sense to compile.
|
||||
LOG: lev:4 file:ael2_parse line:523 func: main 0 contexts, 0 extensions, 0 priorities
|
||||
LOG: lev:4 file:pbx_ael.c line:4118 func: pbx_load_module Sorry, but 0 syntax errors and 1 semantic errors were detected. It doesn't make sense to compile.
|
||||
LOG: lev:4 file:ael2_parse line:543 func: main 0 contexts, 0 extensions, 0 priorities
|
||||
|
@@ -195,6 +195,7 @@ NOSEMIC ([^;()\{\}\[\]]|\\[;()\[\]\{\}])*
|
||||
\/\/[^\n]* {/*comment*/}
|
||||
context { STORE_POS; return KW_CONTEXT;}
|
||||
abstract { STORE_POS; return KW_ABSTRACT;}
|
||||
extend { STORE_POS; return KW_EXTEND;}
|
||||
macro { STORE_POS; return KW_MACRO;};
|
||||
globals { STORE_POS; return KW_GLOBALS;}
|
||||
ignorepat { STORE_POS; return KW_IGNOREPAT;}
|
||||
|
1389
pbx/ael/ael.tab.c
1389
pbx/ael/ael.tab.c
File diff suppressed because it is too large
Load Diff
@@ -50,24 +50,25 @@
|
||||
KW_ELSE = 276,
|
||||
KW_RANDOM = 277,
|
||||
KW_ABSTRACT = 278,
|
||||
EXTENMARK = 279,
|
||||
KW_GOTO = 280,
|
||||
KW_JUMP = 281,
|
||||
KW_RETURN = 282,
|
||||
KW_BREAK = 283,
|
||||
KW_CONTINUE = 284,
|
||||
KW_REGEXTEN = 285,
|
||||
KW_HINT = 286,
|
||||
KW_FOR = 287,
|
||||
KW_WHILE = 288,
|
||||
KW_CASE = 289,
|
||||
KW_PATTERN = 290,
|
||||
KW_DEFAULT = 291,
|
||||
KW_CATCH = 292,
|
||||
KW_SWITCHES = 293,
|
||||
KW_ESWITCHES = 294,
|
||||
KW_INCLUDES = 295,
|
||||
word = 296
|
||||
KW_EXTEND = 279,
|
||||
EXTENMARK = 280,
|
||||
KW_GOTO = 281,
|
||||
KW_JUMP = 282,
|
||||
KW_RETURN = 283,
|
||||
KW_BREAK = 284,
|
||||
KW_CONTINUE = 285,
|
||||
KW_REGEXTEN = 286,
|
||||
KW_HINT = 287,
|
||||
KW_FOR = 288,
|
||||
KW_WHILE = 289,
|
||||
KW_CASE = 290,
|
||||
KW_PATTERN = 291,
|
||||
KW_DEFAULT = 292,
|
||||
KW_CATCH = 293,
|
||||
KW_SWITCHES = 294,
|
||||
KW_ESWITCHES = 295,
|
||||
KW_INCLUDES = 296,
|
||||
word = 297
|
||||
};
|
||||
#endif
|
||||
/* Tokens. */
|
||||
@@ -92,24 +93,25 @@
|
||||
#define KW_ELSE 276
|
||||
#define KW_RANDOM 277
|
||||
#define KW_ABSTRACT 278
|
||||
#define EXTENMARK 279
|
||||
#define KW_GOTO 280
|
||||
#define KW_JUMP 281
|
||||
#define KW_RETURN 282
|
||||
#define KW_BREAK 283
|
||||
#define KW_CONTINUE 284
|
||||
#define KW_REGEXTEN 285
|
||||
#define KW_HINT 286
|
||||
#define KW_FOR 287
|
||||
#define KW_WHILE 288
|
||||
#define KW_CASE 289
|
||||
#define KW_PATTERN 290
|
||||
#define KW_DEFAULT 291
|
||||
#define KW_CATCH 292
|
||||
#define KW_SWITCHES 293
|
||||
#define KW_ESWITCHES 294
|
||||
#define KW_INCLUDES 295
|
||||
#define word 296
|
||||
#define KW_EXTEND 279
|
||||
#define EXTENMARK 280
|
||||
#define KW_GOTO 281
|
||||
#define KW_JUMP 282
|
||||
#define KW_RETURN 283
|
||||
#define KW_BREAK 284
|
||||
#define KW_CONTINUE 285
|
||||
#define KW_REGEXTEN 286
|
||||
#define KW_HINT 287
|
||||
#define KW_FOR 288
|
||||
#define KW_WHILE 289
|
||||
#define KW_CASE 290
|
||||
#define KW_PATTERN 291
|
||||
#define KW_DEFAULT 292
|
||||
#define KW_CATCH 293
|
||||
#define KW_SWITCHES 294
|
||||
#define KW_ESWITCHES 295
|
||||
#define KW_INCLUDES 296
|
||||
#define word 297
|
||||
|
||||
|
||||
|
||||
@@ -123,7 +125,7 @@ typedef union YYSTYPE
|
||||
struct pval *pval; /* full objects */
|
||||
}
|
||||
/* Line 1536 of yacc.c. */
|
||||
#line 127 "ael.tab.h"
|
||||
#line 129 "ael.tab.h"
|
||||
YYSTYPE;
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
|
@@ -80,7 +80,7 @@ static pval *update_last(pval *, YYLTYPE *);
|
||||
|
||||
|
||||
%token KW_CONTEXT LC RC LP RP SEMI EQ COMMA COLON AMPER BAR AT
|
||||
%token KW_MACRO KW_GLOBALS KW_IGNOREPAT KW_SWITCH KW_IF KW_IFTIME KW_ELSE KW_RANDOM KW_ABSTRACT
|
||||
%token KW_MACRO KW_GLOBALS KW_IGNOREPAT KW_SWITCH KW_IF KW_IFTIME KW_ELSE KW_RANDOM KW_ABSTRACT KW_EXTEND
|
||||
%token EXTENMARK KW_GOTO KW_JUMP KW_RETURN KW_BREAK KW_CONTINUE KW_REGEXTEN KW_HINT
|
||||
%token KW_FOR KW_WHILE KW_CASE KW_PATTERN KW_DEFAULT KW_CATCH KW_SWITCHES KW_ESWITCHES
|
||||
%token KW_INCLUDES
|
||||
@@ -201,22 +201,19 @@ context_name : word { $$ = $1; }
|
||||
;
|
||||
|
||||
context : opt_abstract KW_CONTEXT context_name LC elements RC {
|
||||
if (!$5) {
|
||||
ast_log(LOG_WARNING, "==== File: %s, Line %d, Cols: %d-%d: Warning! The empty context %s will be IGNORED!\n",
|
||||
my_file, @4.first_line, @4.first_column, @4.last_column, $3 );
|
||||
$$ = 0;
|
||||
free($3);
|
||||
} else {
|
||||
$$ = npval2(PV_CONTEXT, &@1, &@6);
|
||||
$$->u1.str = $3;
|
||||
$$->u2.statements = $5;
|
||||
set_dads($$,$5);
|
||||
$$->u3.abstract = $1;} }
|
||||
$$ = npval2(PV_CONTEXT, &@1, &@6);
|
||||
$$->u1.str = $3;
|
||||
$$->u2.statements = $5;
|
||||
set_dads($$,$5);
|
||||
$$->u3.abstract = $1;}
|
||||
;
|
||||
|
||||
/* optional "abstract" keyword XXX there is no regression test for this */
|
||||
opt_abstract: KW_ABSTRACT { $$ = 1; }
|
||||
| /* nothing */ { $$ = 0; }
|
||||
| KW_EXTEND { $$ = 2; }
|
||||
| KW_EXTEND KW_ABSTRACT { $$=3; }
|
||||
| KW_ABSTRACT KW_EXTEND { $$=3; }
|
||||
;
|
||||
|
||||
macro : KW_MACRO word LP arglist RP LC macro_statements RC {
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -2245,9 +2245,9 @@ static void check_context_names(void)
|
||||
if (i->type == PV_CONTEXT || i->type == PV_MACRO) {
|
||||
for (j=i->next; j; j=j->next) {
|
||||
if ( j->type == PV_CONTEXT || j->type == PV_MACRO ) {
|
||||
if ( !strcmp(i->u1.str, j->u1.str) )
|
||||
if ( !strcmp(i->u1.str, j->u1.str) && !(i->u3.abstract&2) && !(j->u3.abstract&2) )
|
||||
{
|
||||
ast_log(LOG_ERROR,"Error: file %s, line %d-%d: The context name (%s) is also declared in file %s, line %d-%d!\n",
|
||||
ast_log(LOG_ERROR,"Error: file %s, line %d-%d: The context name (%s) is also declared in file %s, line %d-%d! (and neither is marked 'extend')\n",
|
||||
i->filename, i->startline, i->endline, i->u1.str, j->filename, j->startline, j->endline);
|
||||
errs++;
|
||||
}
|
||||
@@ -3955,7 +3955,7 @@ void ast_compile_ael2(struct ast_context **local_contexts, struct pval *root)
|
||||
break;
|
||||
|
||||
case PV_CONTEXT:
|
||||
context = ast_context_create(local_contexts, p->u1.str, registrar);
|
||||
context = ast_context_find_or_create(local_contexts, p->u1.str, registrar);
|
||||
|
||||
/* contexts contain: ignorepat, includes, switches, eswitches, extensions, */
|
||||
for (p2=p->u2.statements; p2; p2=p2->next) {
|
||||
|
@@ -88,6 +88,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);
|
||||
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);
|
||||
@@ -312,6 +313,21 @@ 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 *x = calloc(1, sizeof(*x));
|
||||
if (!x)
|
||||
return NULL;
|
||||
x->next = context_list;
|
||||
context_list = x;
|
||||
if (!no_comp)
|
||||
printf("Executed ast_context_find_or_create(conts, name=%s, registrar=%s);\n", name, registrar);
|
||||
conts++;
|
||||
strncpy(x->name, name, sizeof(x->name) - 1);
|
||||
strncpy(x->registrar, registrar, sizeof(x->registrar) - 1);
|
||||
return x;
|
||||
}
|
||||
|
||||
void ast_context_add_ignorepat2(struct ast_context *con, const char *value, const char *registrar)
|
||||
{
|
||||
if(!no_comp)
|
||||
|
Reference in New Issue
Block a user