* adjust the loops using StrBufSipLine to match our new logic
authorWilfried Göesgens <willi@citadel.org>
Mon, 21 Sep 2009 23:37:01 +0000 (23:37 +0000)
committerWilfried Göesgens <willi@citadel.org>
Mon, 21 Sep 2009 23:37:01 +0000 (23:37 +0000)
webcit/msg_renderers.c
webcit/serv_func.c

index 5e88b91721be8f03cc0fde5e20969be01a903411..97b454abdbdf3cfa4f1ee2c4361f3ca6503c2eff 100644 (file)
@@ -827,7 +827,7 @@ void render_MAIL_text_plain(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *F
        int ConvertIt = 1;
        int bn = 0;
        int bq = 0;
-       int i, n, done = 0;
+       int i;
        long len;
 #ifdef HAVE_ICONV
        iconv_t ic = (iconv_t)(-1) ;
@@ -869,47 +869,50 @@ void render_MAIL_text_plain(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *F
        Line2 = NewStrBufPlain(NULL, SIZ);
        Target = NewStrBufPlain(NULL, StrLength(Mime->Data));
 
-       while ((n = StrBufSipLine(Line, Mime->Data, &BufPtr), n >= 0) && !done)
-       {
-               done = n == 0;
-               bq = 0;
-               i = 0;
-               ptr = ChrPtr(Line);
-               len = StrLength(Line);
-               pte = ptr + len;
-               
-               while ((ptr < pte) &&
-                      ((*ptr == '>') ||
-                       isspace(*ptr)))
+       if (StrLength(Mime->Data) > 0) 
+               do 
                {
-                       if (*ptr == '>')
-                               bq++;
-                       ptr ++;
-                       i++;
-               }
-               if (i > 0) StrBufCutLeft(Line, i);
+                       StrBufSipLine(Line, Mime->Data, &BufPtr);
+                       bq = 0;
+                       i = 0;
+                       ptr = ChrPtr(Line);
+                       len = StrLength(Line);
+                       pte = ptr + len;
                
-               if (StrLength(Line) == 0) {
-                       StrBufAppendBufPlain(Target, HKEY("<tt></tt><br />\n"), 0);
-                       continue;
-               }
+                       while ((ptr < pte) &&
+                              ((*ptr == '>') ||
+                               isspace(*ptr)))
+                       {
+                               if (*ptr == '>')
+                                       bq++;
+                               ptr ++;
+                               i++;
+                       }
+                       if (i > 0) StrBufCutLeft(Line, i);
+               
+                       if (StrLength(Line) == 0) {
+                               StrBufAppendBufPlain(Target, HKEY("<tt></tt><br />\n"), 0);
+                               continue;
+                       }
 
-               for (i = bn; i < bq; i++)                               
-                       StrBufAppendBufPlain(Target, HKEY("<blockquote>"), 0);
-               for (i = bq; i < bn; i++)                               
-                       StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
+                       for (i = bn; i < bq; i++)                               
+                               StrBufAppendBufPlain(Target, HKEY("<blockquote>"), 0);
+                       for (i = bq; i < bn; i++)                               
+                               StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
 
-               if (ConvertIt) {
-                       StrBufConvert(Line, Line1, &ic);
-               }
+                       if (ConvertIt) {
+                               StrBufConvert(Line, Line1, &ic);
+                       }
 
-               StrBufAppendBufPlain(Target, HKEY("<tt>"), 0);
-               UrlizeText(Line1, Line, Line2);
+                       StrBufAppendBufPlain(Target, HKEY("<tt>"), 0);
+                       UrlizeText(Line1, Line, Line2);
 
-               StrEscAppend(Target, Line1, NULL, 0, 0);
-               StrBufAppendBufPlain(Target, HKEY("</tt><br />\n"), 0);
-               bn = bq;
-       }
+                       StrEscAppend(Target, Line1, NULL, 0, 0);
+                       StrBufAppendBufPlain(Target, HKEY("</tt><br />\n"), 0);
+                       bn = bq;
+               }
+       while ((BufPtr != StrBufNOTNULL) &&
+              (BufPtr != NULL));
 
        for (i = 0; i < bn; i++)                                
                StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
index e9f5f8c5675e631ce11e4b3e0be72ff8b6dcf086..9e12d1afbbe8710fbcd23db46c3910af59a3fda3 100644 (file)
@@ -269,57 +269,62 @@ void FmOut(StrBuf *Target, char *align, StrBuf *Source)
        StrBuf *Line2 = NewStrBufPlain(NULL, SIZ);
        int bn = 0;
        int bq = 0;
-       int i, n, done = 0;
+       int i;
        long len;
        int intext = 0;
 
        StrBufAppendPrintf(Target, "<div class=\"fmout-%s\">\n", align);
-       while ((n = StrBufSipLine(Line, Source, &BufPtr), n >= 0) && !done)
-       {
-               done = n == 0;
-               bq = 0;
-               i = 0;
-               ptr = ChrPtr(Line);
-               len = StrLength(Line);
-               pte = ptr + len;
-
-               if ((intext == 1) && (isspace(*ptr))) {
-                       StrBufAppendBufPlain(Target, HKEY("<br>"), 0);
-               }
-               intext = 1;
-               if (isspace(*ptr)) while ((ptr < pte) &&
-                      ((*ptr == '>') ||
-                       isspace(*ptr)))
+
+       if (StrLength(Source) > 0) 
+               do 
                {
-                       if (*ptr == '>')
-                               bq++;
-                       ptr ++;
-                       i++;
-               }
+                       StrBufSipLine(Line, Source, &BufPtr);
+                       bq = 0;
+                       i = 0;
+                       ptr = ChrPtr(Line);
+                       len = StrLength(Line);
+                       pte = ptr + len;
 
-               /**
-                * Quoted text should be displayed in italics and in a
-                * different colour.  This code understands Citadel-style
-                * " >" quotes and will convert to <BLOCKQUOTE> tags.
-                */
-               if (i > 0) StrBufCutLeft(Line, i);
+                       if ((intext == 1) && (isspace(*ptr))) {
+                               StrBufAppendBufPlain(Target, HKEY("<br>"), 0);
+                       }
+                       intext = 1;
+                       if (isspace(*ptr)) while ((ptr < pte) &&
+                                                 ((*ptr == '>') ||
+                                                  isspace(*ptr)))
+                                          {
+                                                  if (*ptr == '>')
+                                                          bq++;
+                                                  ptr ++;
+                                                  i++;
+                                          }
+
+                       /**
+                        * Quoted text should be displayed in italics and in a
+                        * different colour.  This code understands Citadel-style
+                        * " >" quotes and will convert to <BLOCKQUOTE> tags.
+                        */
+                       if (i > 0) StrBufCutLeft(Line, i);
                
 
-               for (i = bn; i < bq; i++)                               
-                       StrBufAppendBufPlain(Target, HKEY("<blockquote>"), 0);
-               for (i = bq; i < bn; i++)                               
-                       StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
-               bn = bq;
+                       for (i = bn; i < bq; i++)                               
+                               StrBufAppendBufPlain(Target, HKEY("<blockquote>"), 0);
+                       for (i = bq; i < bn; i++)                               
+                               StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
+                       bn = bq;
 
-               if (StrLength(Line) == 0)
-                       continue;
-               /** Activate embedded URL's */
-               UrlizeText(Line1, Line, Line2);
+                       if (StrLength(Line) == 0)
+                               continue;
+                       /** Activate embedded URL's */
+                       UrlizeText(Line1, Line, Line2);
 
-               StrEscAppend(Target, Line1, NULL, 0, 0);
+                       StrEscAppend(Target, Line1, NULL, 0, 0);
+
+                       StrBufAppendBufPlain(Target, HKEY("\n"), 0);
+               }
+               while ((BufPtr != StrBufNOTNULL) &&
+                      (BufPtr != NULL));
 
-               StrBufAppendBufPlain(Target, HKEY("\n"), 0);
-       }
        for (i = 0; i < bn; i++)                                
                StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
        StrBufAppendBufPlain(Target, HKEY("</div><br>\n"), 0);