SUBST: fix double linked list handling for contexts.
authorWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Nov 2012 13:23:47 +0000 (14:23 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Nov 2012 13:23:47 +0000 (14:23 +0100)
webcit/subst.c

index 02de06103b982a2baa6a7762c6c524987eba9684..c3b094874778772db7758442a2e70036e6c8cf2b 100644 (file)
@@ -163,6 +163,8 @@ void StackDynamicContext(WCTemplputParams *Super,
                Sub->Sub = Super->Sub;
                Super->Sub = Sub;
        }
+       if (Sub->Sub != NULL)
+               Sub->Sub->Super = Sub;
        Sub->Super = Super;
        
        Sub->Context = Context;
@@ -179,6 +181,10 @@ void UnStackContext(WCTemplputParams *Sub)
        {
                Sub->Super->Sub = Sub->Sub;
        }
+       if (Sub->Sub != NULL)
+       {
+               Sub->Sub->Super = Sub->Super;
+       }
 }
 void UnStackDynamicContext(StrBuf *Target, WCTemplputParams **TPP)
 {
@@ -315,9 +321,6 @@ void LogTemplateError (StrBuf *Target, const char *Type, int ErrorPos, WCTemplpu
 */
 }
 
-
-
-
 void LogError (StrBuf *Target, const char *Type, const char *Format, ...)
 {
        wcsession *WCC;
@@ -2254,10 +2257,12 @@ int EvaluateConditional(StrBuf *Target, int Neg, int state, WCTemplputParams **T
        res = Cond->CondF(Target, TP);
        if (res == Neg)
                rc = TP->Tokens->Params[1]->lvalue;
+
        if (LoadTemplates > 5) 
                syslog(1, "<%s> : %d %d==%d\n", 
                        ChrPtr(TP->Tokens->FlatToken), 
                        rc, res, Neg);
+
        if (TP->Sub != NULL)
        {
                *TPP = TP->Sub;