summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--grammar/lexer.l4
-rw-r--r--grammar/rainerscript.c51
-rw-r--r--grammar/rainerscript.h1
-rw-r--r--runtime/ruleset.c2
4 files changed, 53 insertions, 5 deletions
diff --git a/grammar/lexer.l b/grammar/lexer.l
index 51b0fbd2..b0f4bba9 100644
--- a/grammar/lexer.l
+++ b/grammar/lexer.l
@@ -172,9 +172,7 @@ int fileno(FILE *stream);
\/[^*][^\n]* |
:[a-z0-9]+:[^\n]* |
[\|\.\-\@\^?~>][^\n]+ |
-[a-z0-9_][a-z0-9_\-\+,;]* { yylval.s = strdup(yytext);
- dbgprintf("lex: LEGA ACT: '%s'\n", yytext);
- return LEGACY_ACTION; }
+[a-z0-9_][a-z0-9_\-\+,;]* { yylval.s = yytext; return LEGACY_ACTION; }
<INOBJ>")" { BEGIN INITIAL; return ENDOBJ; }
<INOBJ>[a-z][a-z0-9_\.]* { yylval.estr = es_newStrFromCStr(yytext, yyleng);
return NAME; }
diff --git a/grammar/rainerscript.c b/grammar/rainerscript.c
index 0ebfb44e..d6a51191 100644
--- a/grammar/rainerscript.c
+++ b/grammar/rainerscript.c
@@ -1635,6 +1635,7 @@ cnfstringvalNew(es_str_t *estr)
return strval;
}
+
struct cnfvar*
cnfvarNew(char *name)
{
@@ -1657,12 +1658,57 @@ cnfstmtNew(unsigned s_type)
return cnfstmt;
}
+void
+cnfstmtDestruct(struct cnfstmt *root)
+{
+ struct cnfstmt *stmt, *todel;
+ for(stmt = root ; stmt != NULL ; ) {
+ switch(stmt->nodetype) {
+ case S_NOP:
+ case S_STOP:
+ break;
+ case S_ACT:
+dbgprintf("XXXX: destruct action %p\n", stmt->d.act);
+ actionDestruct(stmt->d.act);
+ break;
+ case S_IF:
+ cnfexprDestruct(stmt->d.s_if.expr);
+ if(stmt->d.s_if.t_then != NULL) {
+ cnfstmtDestruct(stmt->d.s_if.t_then);
+ }
+ if(stmt->d.s_if.t_else != NULL) {
+ cnfstmtDestruct(stmt->d.s_if.t_else);
+ }
+ break;
+ case S_PRIFILT:
+ cnfstmtDestruct(stmt->d.s_prifilt.t_then);
+ break;
+ case S_PROPFILT:
+ if(stmt->d.s_propfilt.propName != NULL)
+ es_deleteStr(stmt->d.s_propfilt.propName);
+ if(stmt->d.s_propfilt.regex_cache != NULL)
+ rsCStrRegexDestruct(&stmt->d.s_propfilt.regex_cache);
+ if(stmt->d.s_propfilt.pCSCompValue != NULL)
+ cstrDestruct(&stmt->d.s_propfilt.pCSCompValue);
+ cnfstmtDestruct(stmt->d.s_propfilt.t_then);
+ break;
+ default:
+ dbgprintf("error: unknown stmt type during destruct %u\n",
+ (unsigned) stmt->nodetype);
+ break;
+ }
+ todel = stmt;
+ stmt = stmt->next;
+ free(todel);
+ }
+}
+
struct cnfstmt *
cnfstmtNewPRIFILT(char *prifilt, struct cnfstmt *t_then)
{
struct cnfstmt* cnfstmt;
if((cnfstmt = cnfstmtNew(S_PRIFILT)) != NULL) {
- cnfstmt->printable = (uchar*)strdup(prifilt);
+ cnfstmt->printable = (uchar*)prifilt;
cnfstmt->d.s_prifilt.t_then = t_then;
DecodePRIFilter((uchar*)prifilt, cnfstmt->d.s_prifilt.pmask);
}
@@ -1676,6 +1722,9 @@ cnfstmtNewPROPFILT(char *propfilt, struct cnfstmt *t_then)
if((cnfstmt = cnfstmtNew(S_PROPFILT)) != NULL) {
cnfstmt->printable = (uchar*)strdup(propfilt);
cnfstmt->d.s_propfilt.t_then = t_then;
+ cnfstmt->d.s_propfilt.propName = NULL;
+ cnfstmt->d.s_propfilt.regex_cache = NULL;
+ cnfstmt->d.s_propfilt.pCSCompValue = NULL;
DecodePropFilter((uchar*)propfilt, cnfstmt);
}
return cnfstmt;
diff --git a/grammar/rainerscript.h b/grammar/rainerscript.h
index b7d13a65..2f4aec8a 100644
--- a/grammar/rainerscript.h
+++ b/grammar/rainerscript.h
@@ -324,6 +324,7 @@ struct cnfstmt * cnfstmtNewPRIFILT(char *prifilt, struct cnfstmt *t_then);
struct cnfstmt * cnfstmtNewPROPFILT(char *propfilt, struct cnfstmt *t_then);
struct cnfstmt * cnfstmtNewAct(struct nvlst *lst);
struct cnfstmt * cnfstmtNewLegaAct(char *actline);
+void cnfstmtDestruct(struct cnfstmt *root);
char* getFIOPName(unsigned iFIOP);
rsRetVal initRainerscript(void);
diff --git a/runtime/ruleset.c b/runtime/ruleset.c
index 30254f0c..74f078b6 100644
--- a/runtime/ruleset.c
+++ b/runtime/ruleset.c
@@ -665,7 +665,7 @@ CODESTARTobjDestruct(ruleset)
parser.DestructParserList(&pThis->pParserLst);
}
free(pThis->pszName);
- // TODO: free rainerscript root (not look at last)
+ cnfstmtDestruct(pThis->root);
ENDobjDestruct(ruleset)