diff --git a/modules/libcom/src/as/asLib.y b/modules/libcom/src/as/asLib.y index b947223b4..30e1db901 100644 --- a/modules/libcom/src/as/asLib.y +++ b/modules/libcom/src/as/asLib.y @@ -18,12 +18,22 @@ static UAG *yyUag=NULL; static HAG *yyHag=NULL; static ASG *yyAsg=NULL; static ASGRULE *yyAsgRule=NULL; + +static +char* yystrdup(const char *inp) { + char* ret = strdup(inp); + if(!ret) + yyerror("MALLOC"); + return ret; +} + %} %start asconfig -%token tokenUAG tokenHAG tokenASG tokenRULE tokenCALC tokenINP tokenSTRING -%token tokenINT64 +%token tokenUAG tokenHAG tokenASG tokenRULE tokenCALC +%token tokenSTRING +%token tokenINT64 tokenINP %token tokenFLOAT64 %union @@ -54,30 +64,40 @@ asconfig_item: tokenUAG uag_head uag_body | generic_item ; +/* uniformally yield a string for use in warning messages */ keyword: tokenUAG + { $$ = yystrdup("UAG"); } | tokenHAG + { $$ = yystrdup("HAG"); } | tokenCALC + { $$ = yystrdup("CALC"); } | non_rule_keyword ; non_rule_keyword: tokenASG + { $$ = yystrdup("ASG"); } | tokenRULE + { $$ = yystrdup("RULE"); } | tokenINP + { + if(!!($$ = yystrdup("INPA"))) + $$[3] += $1; /* 'A' + input number */ + } ; generic_item: tokenSTRING generic_head generic_list_block { - yywarn("Ignoring unsupported TOP LEVEL Access Control Definition", $1); + yywarn("Ignoring unsupported TOP LEVEL nested block", $1); free($1); } | tokenSTRING generic_head generic_block { - yywarn("Ignoring unsupported TOP LEVEL Access Control Definition", $1); + yywarn("Ignoring unsupported TOP LEVEL block", $1); free($1); } | tokenSTRING generic_head { - yywarn("Ignoring unsupported TOP LEVEL Access Control Definition", $1); + yywarn("Ignoring unsupported TOP LEVEL bare block", $1); free($1); } ; @@ -130,14 +150,7 @@ generic_block_elem: generic_block_elem_name generic_head generic_block ; generic_block_elem_name: keyword - { - $$ = strdup($1); - if (!$$) yyerror("Out of memory"); - } | tokenSTRING - { - $$ = $1; - } ; rule_generic_block_elem: rule_generic_block_elem_name generic_head generic_block @@ -151,14 +164,7 @@ rule_generic_block_elem: rule_generic_block_elem_name generic_head generic_block ; rule_generic_block_elem_name: non_rule_keyword - { - $$ = strdup($1); - if (!$$) yyerror("Out of memory"); - } | tokenSTRING - { - $$ = $1; - } ; uag_head: '(' tokenSTRING ')' @@ -247,7 +253,7 @@ rule_head: '(' rule_head_mandatory ',' rule_log_option ')' rule_head_mandatory: tokenINT64 ',' tokenSTRING { if ($1 < 0) { - char message[40]; + char message[60]; sprintf(message, "RULE: LEVEL must be positive: %lld", $1); yyerror(message); } else if((strcmp($3,"NONE")==0)) { diff --git a/modules/libcom/src/as/asLibRoutines.c b/modules/libcom/src/as/asLibRoutines.c index f86f985e5..07487af13 100644 --- a/modules/libcom/src/as/asLibRoutines.c +++ b/modules/libcom/src/as/asLibRoutines.c @@ -1065,6 +1065,9 @@ void asFreeAll(ASBASE *pasbase) ASGUAG *pasguag; void *pnext; + if(!pasbase) + return; + puag = (UAG *)ellFirst(&pasbase->uagList); while(puag) { puagname = (UAGNAME *)ellFirst(&puag->list); diff --git a/modules/libcom/src/as/asLib_lex.l b/modules/libcom/src/as/asLib_lex.l index 7ba1c8da7..69a88eb8b 100644 --- a/modules/libcom/src/as/asLib_lex.l +++ b/modules/libcom/src/as/asLib_lex.l @@ -79,7 +79,7 @@ INP{link} { {doublequote}({stringchar}|{escape})*{doublequote} { /* quoted string */ yylval.Str=asStrdup(yytext+1); - yylval.Str[strlen(yylval.Str)-1] = '\0'; + yylval.Str[strlen(yylval.Str)-1] = '\0'; /* overwrite trailing '"' */ return(tokenSTRING); } diff --git a/modules/libcom/test/aslibtest.c b/modules/libcom/test/aslibtest.c index 705823de5..d1ca03b99 100644 --- a/modules/libcom/test/aslibtest.c +++ b/modules/libcom/test/aslibtest.c @@ -109,6 +109,7 @@ static const char supported_config_3[] = "" "COMPLEX_ARGUMENTS(1, WELL, \"FORMED\", ARG, LIST) {\n" " ALSO_GENERIC(WELL, FORMED, ARG, LIST, 2.0) \n" + " RULE(WELL, FORMED, ARG, LIST, 2.0) \n" "}\n" "ASG(DEFAULT) {\n" @@ -137,7 +138,7 @@ static const char supported_config_4[] = "" " ALSO_GENERIC() {\n" " AND_LIST_BODY\n" " }\n" -" ANOTHER_GENERIC() {\n" +" RULE() {\n" " BIGGER, LIST, BODY\n" " }\n" "}\n"