X-Git-Url: https://code.citadel.org/?p=citadel.git;a=blobdiff_plain;f=webcit%2Fsubst.c;fp=webcit%2Fsubst.c;h=1370ca5b5fd7e6af2507b95c712bc14f4a3c6a17;hp=7443515e7bbaec272e78ab9e83995cc85667c42e;hb=82f8cebefd325c7eb8b98c6025bd43633fa9cd90;hpb=03e859ed5c8b493a18b4d289518c05321b0e9563 diff --git a/webcit/subst.c b/webcit/subst.c index 7443515e7..1370ca5b5 100644 --- a/webcit/subst.c +++ b/webcit/subst.c @@ -694,6 +694,55 @@ void StrBufAppendTemplate(StrBuf *Target, } } +/* + * puts string into the template and computes which escape methon we should use + * Source = the string we should put into the template + * FormatTypeIndex = where should we look for escape types if? + */ +void StrBufAppendTemplateStr(StrBuf *Target, + WCTemplputParams *TP, + const char *Source, int FormatTypeIndex) +{ + const char *pFmt = NULL; + char EscapeAs = ' '; + + if ((FormatTypeIndex < TP->Tokens->nParameters) && + (TP->Tokens->Params[FormatTypeIndex]->Type == TYPE_STR) && + (TP->Tokens->Params[FormatTypeIndex]->len >= 1)) { + pFmt = TP->Tokens->Params[FormatTypeIndex]->Start; + EscapeAs = *pFmt; + } + + switch(EscapeAs) + { + case 'H': + StrEscAppend(Target, NULL, Source, 0, 2); + break; + case 'X': + StrEscAppend(Target, NULL, Source, 0, 0); + break; + case 'J': + StrECMAEscAppend(Target, NULL, Source); + break; + case 'K': + StrHtmlEcmaEscAppend(Target, NULL, Source, 0, 0); + break; + case 'U': + StrBufUrlescAppend(Target, NULL, Source); + break; +/* + case 'F': + if (pFmt != NULL) pFmt++; + else pFmt = "JUSTIFY"; + if (*pFmt == '\0') pFmt = "JUSTIFY"; + FmOut(Target, pFmt, Source); + break; +*/ + default: + StrBufAppendBufPlain(Target, Source, 0, 0); + } +} + void PutNewToken(WCTemplate *Template, WCTemplateToken *NewToken) {