]> code.citadel.org Git - citadel.git/blobdiff - webcit/subst.c
* don't ignore the last char of a template
[citadel.git] / webcit / subst.c
index 716a46e718077bbb15a6419d7d10262d593611f8..41aad9274daad0bb6e6d3818cf6795c8f1956215 100644 (file)
@@ -936,21 +936,21 @@ WCTemplateToken *NewTemplateSubstitute(StrBuf *Buf,
        case SV_CUST_STR_CONDITIONAL:
        case SV_CONDITIONAL:
        case SV_NEG_CONDITIONAL:
-               if (NewToken->Params[1]->lvalue == 0) {
+               if (NewToken->nParameters <2) {
                        lprintf(1, "Conditional (in '%s' line %ld); "
-                               "Conditional ID mustn't be 0! [%s]\n", 
+                               "require at least 2 parameters, you gave %ld params [%s]\n", 
                                ChrPtr(pTmpl->FileName),
                                NewToken->Line,
+                               NewToken->nParameters, 
                                ChrPtr(NewToken->FlatToken));
                        NewToken->Flags = 0;
                        break;
                }
-               if (NewToken->nParameters <2) {
+               if (NewToken->Params[1]->lvalue == 0) {
                        lprintf(1, "Conditional (in '%s' line %ld); "
-                               "require at least 2 parameters, you gave %ld params [%s]\n", 
+                               "Conditional ID mustn't be 0! [%s]\n", 
                                ChrPtr(pTmpl->FileName),
                                NewToken->Line,
-                               NewToken->nParameters, 
                                ChrPtr(NewToken->FlatToken));
                        NewToken->Flags = 0;
                        break;
@@ -1070,7 +1070,7 @@ void *load_template(StrBuf *filename, StrBuf *Key, HashList *PutThere)
                pts = pch;
 
                /** Found one? parse it. */
-               for (; pch < pE - 1; pch ++) {
+               for (; pch <= pE - 1; pch ++) {
                        if (*pch == '"')
                                InDoubleQuotes = ! InDoubleQuotes;
                        else if (*pch == '\'')
@@ -1081,7 +1081,7 @@ void *load_template(StrBuf *filename, StrBuf *Key, HashList *PutThere)
                                break;
                        }
                }
-               if (pch + 1 >= pE)
+               if (pch + 1 > pE)
                        continue;
                pte = pch;
                PutNewToken(NewTemplate,