From 87b5e880d0bd8d72aec9446069e063b27bf3e988 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Thu, 15 Jan 2009 00:23:48 +0000 Subject: [PATCH] * temporarily disable parameter-checking. Conditionals don't contain enough information, this needs to be fixed. --- webcit/subst.c | 25 ++++++++++--------------- webcit/subst.h | 1 - 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/webcit/subst.c b/webcit/subst.c index 3a52342de..6a9c28baa 100644 --- a/webcit/subst.c +++ b/webcit/subst.c @@ -206,7 +206,7 @@ int CheckContext(StrBuf *Target, ContextFilter *Need, WCTemplputParams *TP, cons CtxNames[TP->Filter.ControlContextType]); return 0; } - +/* if (TP->Tokens->nParameters < Need->nMinArgs) { LogTemplateError(Target, ErrType, ERR_NAME, TP, "needs at least %ld params, have %ld", @@ -218,11 +218,12 @@ int CheckContext(StrBuf *Target, ContextFilter *Need, WCTemplputParams *TP, cons else if (TP->Tokens->nParameters > Need->nMaxArgs) { LogTemplateError(Target, ErrType, ERR_NAME, TP, "just needs %ld params, you gave %ld", - TP->Tokens->nParameters, - Need->nMaxArgs); + Need->nMaxArgs, + TP->Tokens->nParameters); return 0; } +*/ return 1; } @@ -1755,14 +1756,10 @@ int EvaluateConditional(StrBuf *Target, int Neg, int state, WCTemplputParams *TP return 1; } - if (TP->Tokens->nParameters < Cond->nParams) { - LogTemplateError( - Target, "Conditional", ERR_PARM1, TP, - "needs %ld Params, have %ld!", - Cond->nParams, - TP->Tokens->nParameters); + if (!CheckContext(Target, &Cond->Filter, TP, "Conditional")) { return 0; } + if (Cond->CondF(Target, TP) == Neg) return TP->Tokens->Params[1]->lvalue; return 0; @@ -1777,10 +1774,6 @@ int ConditionalVar(StrBuf *Target, WCTemplputParams *TP) return 0; subst = (wcsubst*) vsubst; - if (!CheckContext(Target, &subst->Filter, TP, "Conditional")) { - return -1; - } - switch(subst->wcs_type) { case WCS_FUNCTION: return (subst->wcs_function!=NULL); @@ -1811,7 +1804,8 @@ void RegisterConditional(const char *Name, long len, { ConditionalStruct *Cond = (ConditionalStruct*)malloc(sizeof(ConditionalStruct)); Cond->PlainName = Name; - Cond->nParams = nParams; + Cond->Filter.nMaxArgs = nParams; + Cond->Filter.nMinArgs = nParams; Cond->CondF = CondF; Cond->Filter.ContextType = ContextRequired; Cond->Filter.ControlContextType = CTX_NONE; @@ -1825,7 +1819,8 @@ void RegisterControlConditional(const char *Name, long len, { ConditionalStruct *Cond = (ConditionalStruct*)malloc(sizeof(ConditionalStruct)); Cond->PlainName = Name; - Cond->nParams = nParams; + Cond->Filter.nMaxArgs = nParams; + Cond->Filter.nMinArgs = nParams; Cond->CondF = CondF; Cond->Filter.ContextType = CTX_NONE; Cond->Filter.ControlContextType = ControlContextRequired; diff --git a/webcit/subst.h b/webcit/subst.h index b39ba22dd..1d66e4966 100644 --- a/webcit/subst.h +++ b/webcit/subst.h @@ -128,7 +128,6 @@ typedef int (*WCConditionalFunc)(StrBuf *Target, WCTemplputParams *TP); typedef struct _ConditionalStruct { ContextFilter Filter; const char *PlainName; - int nParams; WCConditionalFunc CondF; } ConditionalStruct; void RegisterConditional(const char *Name, long len, -- 2.30.2