diff options
-rw-r--r-- | grammar/rainerscript.c | 20 | ||||
-rw-r--r-- | runtime/modules.c | 3 | ||||
-rw-r--r-- | runtime/modules.h | 3 |
3 files changed, 23 insertions, 3 deletions
diff --git a/grammar/rainerscript.c b/grammar/rainerscript.c index d0c2dc6b..e5154156 100644 --- a/grammar/rainerscript.c +++ b/grammar/rainerscript.c @@ -45,6 +45,7 @@ #include "srUtils.h" #include "regexp.h" #include "obj.h" +#include "modules.h" DEFobjCurrIf(obj) DEFobjCurrIf(regexp) @@ -2086,6 +2087,19 @@ cnfstmtOptimizeIf(struct cnfstmt *stmt) } } + +static inline void +cnfstmtOptimizeAct(struct cnfstmt *stmt) +{ + action_t *pAct; + + pAct = stmt->d.act; + if(!strcmp((char*)modGetName(stmt->d.act->pMod), "builtin:omdiscard")) { + DBGPRINTF("RainerScript Optimizer: replacing omdiscard by STOP\n"); + stmt->nodetype = S_STOP; + } +} + /* (recursively) optimize a statement */ void cnfstmtOptimize(struct cnfstmt *root) @@ -2109,9 +2123,11 @@ dbgprintf("RRRR: stmtOptimize: stmt %p, nodetype %u\n", stmt, stmt->nodetype); case S_SET: cnfexprOptimize(stmt->d.s_set.expr); break; + case S_ACT: + cnfstmtOptimizeAct(stmt); + break; case S_STOP: - case S_UNSET: - case S_ACT: /* nothing to do */ + case S_UNSET: /* nothing to do */ break; case S_NOP: DBGPRINTF("optimizer error: we see a NOP, how come?\n"); diff --git a/runtime/modules.c b/runtime/modules.c index d3c51e90..f580e58e 100644 --- a/runtime/modules.c +++ b/runtime/modules.c @@ -313,7 +313,8 @@ finalize_it: /* get the name of a module */ -static uchar *modGetName(modInfo_t *pThis) +uchar +*modGetName(modInfo_t *pThis) { return((pThis->pszName == NULL) ? (uchar*) "" : pThis->pszName); } diff --git a/runtime/modules.h b/runtime/modules.h index 6a143ae3..16425beb 100644 --- a/runtime/modules.h +++ b/runtime/modules.h @@ -189,8 +189,11 @@ ENDinterface(module) PROTOTYPEObj(module); /* in v6, we go back to in-core static link for core objects, at least those * that are not called from plugins. + * ... and we need to know that none of the module functions are called from plugins! + * rgerhards, 2012-09-24 */ rsRetVal modulesProcessCnf(struct cnfobj *o); +uchar *modGetName(modInfo_t *pThis); rsRetVal addModToCnfList(modInfo_t *pThis); #endif /* #ifndef MODULES_H_INCLUDED */ |