From 7c66083f062fa31913b14dcae2a94aafb6de33ff Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Mon, 16 May 2011 17:49:34 +0000 Subject: [PATCH] remove leading and trailing empty lines from mail output --- webcit/msg_renderers.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/webcit/msg_renderers.c b/webcit/msg_renderers.c index 7d21cf7a1..74c34e5d6 100644 --- a/webcit/msg_renderers.c +++ b/webcit/msg_renderers.c @@ -963,7 +963,8 @@ void render_MAIL_text_plain(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *F StrBuf *Line1; StrBuf *Line2; StrBuf *Target; - + long Linecount; + long nEmptyLines; int bn = 0; int bq = 0; int i; @@ -1009,7 +1010,8 @@ void render_MAIL_text_plain(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *F Line1 = NewStrBufPlain(NULL, SIZ); Line2 = NewStrBufPlain(NULL, SIZ); Target = NewStrBufPlain(NULL, StrLength(Mime->Data)); - + Linecount = 0; + nEmptyLines = 0; if (StrLength(Mime->Data) > 0) do { @@ -1032,10 +1034,14 @@ void render_MAIL_text_plain(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *F if (i > 0) StrBufCutLeft(Line, i); if (StrLength(Line) == 0) { + if (Linecount == 0) + continue; StrBufAppendBufPlain(Target, HKEY("
\n"), 0); + + nEmptyLines ++; continue; } - + nEmptyLines = 0; for (i = bn; i < bq; i++) StrBufAppendBufPlain(Target, HKEY("
"), 0); for (i = bq; i < bn; i++) @@ -1051,10 +1057,13 @@ void render_MAIL_text_plain(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *F StrEscAppend(Target, Line1, NULL, 0, 0); StrBufAppendBufPlain(Target, HKEY("
\n"), 0); bn = bq; + Linecount ++; } while ((BufPtr != StrBufNOTNULL) && (BufPtr != NULL)); + if (nEmptyLines > 0) + StrBufCutRight(Target, nEmptyLines * (sizeof ("
\n") - 1)); for (i = 0; i < bn; i++) StrBufAppendBufPlain(Target, HKEY("
"), 0); -- 2.30.2