make destroy_pval able to handle a NULL value

(the warning should be removed);
define a 'elements_block' rule to simplify some other rules
removing duplicated code - runtests seems happy with this.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@23613 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Luigi Rizzo
2006-04-30 12:30:08 +00:00
parent ce05a548c3
commit f4b05f86cc
3 changed files with 642 additions and 640 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -116,6 +116,7 @@ static pval *update_last(pval *, YYLTYPE *);
%type <pval>file %type <pval>file
/* XXX lr changes */ /* XXX lr changes */
%type <pval>opt_else %type <pval>opt_else
%type <pval>elements_block
%type <str>opt_word %type <str>opt_word
%type <str>word_or_default %type <str>word_or_default
@@ -159,6 +160,7 @@ static pval *update_last(pval *, YYLTYPE *);
ignorepat element elements arglist global_statement ignorepat element elements arglist global_statement
global_statements globals macro context object objects global_statements globals macro context object objects
opt_else opt_else
elements_block
%destructor { free($$);} word word_list goto_word word3_list includedname opt_word word_or_default %destructor { free($$);} word word_list goto_word word3_list includedname opt_word word_or_default
@@ -193,21 +195,14 @@ word_or_default : word { $$ = $1; }
| KW_DEFAULT { $$ = strdup("default"); } | KW_DEFAULT { $$ = strdup("default"); }
; ;
context : KW_CONTEXT word_or_default LC elements RC { context : KW_CONTEXT word_or_default elements_block {
$$ = npval2(PV_CONTEXT, &@1, &@5); $$ = npval2(PV_CONTEXT, &@1, &@3);
$$->u1.str = $2; $$->u1.str = $2;
$$->u2.statements = $4; } $$->u2.statements = $3; }
| KW_CONTEXT word_or_default LC RC /* empty context OK */ { | KW_ABSTRACT KW_CONTEXT word_or_default elements_block {
$$ = npval2(PV_CONTEXT, &@1, &@4); $$ = npval2(PV_CONTEXT, &@1, &@4);
$$->u1.str = $2; }
| KW_ABSTRACT KW_CONTEXT word_or_default LC elements RC {
$$ = npval2(PV_CONTEXT, &@1, &@6);
$$->u1.str = $3;
$$->u2.statements = $5;
$$->u3.abstract = 1; }
| KW_ABSTRACT KW_CONTEXT word_or_default LC RC /* empty context OK */ {
$$ = npval2(PV_CONTEXT, &@1, &@5);
$$->u1.str = $3; $$->u1.str = $3;
$$->u2.statements = $4;
$$->u3.abstract = 1; } $$->u3.abstract = 1; }
; ;
@@ -254,6 +249,10 @@ arglist : word {
| arglist error {$$=$1;} | arglist error {$$=$1;}
; ;
elements_block : LC RC { $$ = NULL; }
| LC elements RC { $$ = $2; }
;
elements : element { $$=$1;} elements : element { $$=$1;}
| error {$$=0;} | error {$$=0;}
| elements element { if ( $1 && $2 ) {$$=$1; linku1($$,$2);} | elements element { if ( $1 && $2 ) {$$=$1; linku1($$,$2);}

View File

@@ -3554,6 +3554,11 @@ STD_MOD(MOD_1 | NO_USECOUNT, reload, NULL, NULL);
void destroy_pval_item(pval *item) void destroy_pval_item(pval *item)
{ {
if (item == NULL) {
ast_log(LOG_WARNING, "null item\n");
return;
}
if (item->filename) if (item->filename)
free(item->filename); free(item->filename);