<<< Date Index >>>     <<< Thread Index >>>

Re: [PATCH] Improve f=f interoperability



Hi,

* Johannes Stezenbach [07-11-04 12:43:00 +0100] wrote:

Have you made up your mind regarding this patch? It would
be nice if something like this would be comitted before
the next mutt release.

Attached is another version that wraps these changes in $flowed_compat so that the current behavior is left as default. Since I think 1.5.17 is for bug fixes only and this not entirely a bug fix, it needs lots of testing (more than just me).

Rocco
comparing with ../pdmef/ff-interop
searching for changes
diff --git a/handler.c b/handler.c
--- a/handler.c
+++ b/handler.c
@@ -1480,6 +1480,32 @@ void mutt_decode_attachment (BODY *b, ST
     iconv_close (cd);
 }
 
+static int text_plain_handler (BODY *b, STATE *s)
+{
+  char buf[LONG_STRING];
+  size_t l;
+
+  while (fgets (buf, sizeof (buf), s->fpin))
+  {
+    l = mutt_strlen (buf);
+    if (l > 0 && buf[l-1] == '\n')
+      buf[--l] = 0;
+    if (option (OPTTEXTFLOWED))
+    {
+      /* when generating format=flowed from format=fixed,
+       * strip all trailing spaces to improve interoperability */
+      while (l > 0 && buf[l-1] == ' ')
+       buf[--l] = 0;
+    }
+    if (s->prefix)
+      state_puts (s->prefix, s);
+    state_puts (buf, s);
+    state_putc ('\n', s);
+  }
+
+  return 0;
+}
+
 int mutt_body_handler (BODY *b, STATE *s)
 {
   int decode = 0;
@@ -1519,6 +1545,8 @@ int mutt_body_handler (BODY *b, STATE *s
        handler = crypt_pgp_application_pgp_handler;
       else if (ascii_strcasecmp ("flowed", mutt_get_parameter ("format", 
b->parameter)) == 0)
        handler = rfc3676_handler;
+      else if (option (OPTFLOWEDCOMPAT))
+       handler = text_plain_handler;
       else
        plaintext = 1;
     }
diff --git a/init.h b/init.h
--- a/init.h
+++ b/init.h
@@ -594,6 +594,18 @@ struct option_t MuttVars[] = {
   ** signed.
   ** (PGP only)
   */
+  { "flowed_compat",   DT_BOOL, R_NONE, OPTFLOWEDCOMPAT, 0 },
+  /*
+  ** .pp
+  ** When this variable is set, compatibility routines to improve
+  ** interoperability between \fIformat=flowed\fP and \fIformat=fixed\fP
+  ** clients are enabled: When making \fIformat=flowed\fP-replies (with
+  ** $$text_flowed \fIset\fP) to \fIformat=fixed\fP message and vice
+  ** versa, trailing spaces of quoted text are removed. In addition,
+  ** $$indent_string may be used when making \fIformat=fixed\fP
+  ** ($$text_flowed \fIunset\fP) replies to \fIformat=flowed\fP
+  ** messages.
+  */
   { "folder",          DT_PATH, R_NONE, UL &Maildir, UL "~/Mail" },
   /*
   ** .pp
@@ -980,6 +992,8 @@ struct option_t MuttVars[] = {
   ** Specifies the string to prepend to each line of text quoted in a
   ** message to which you are replying.  You are strongly encouraged not to
   ** change this value, as it tends to agitate the more fanatical netizens.
+  ** .pp
+  ** The value of this option is ignored if $$text_flowed is set, too.
   ** .pp
   ** This option is a format string, please see the description of
   ** ``$$index_format'' for supported printf()-style sequences.
diff --git a/mutt.h b/mutt.h
--- a/mutt.h
+++ b/mutt.h
@@ -353,6 +353,7 @@ enum
   OPTFASTREPLY,
   OPTFCCATTACH,
   OPTFCCCLEAR,
+  OPTFLOWEDCOMPAT,
   OPTFOLLOWUPTO,
   OPTFORCENAME,
   OPTFORWDECODE,
diff --git a/rfc3676.c b/rfc3676.c
--- a/rfc3676.c
+++ b/rfc3676.c
@@ -58,7 +58,22 @@ static void print_indent (int ql, STATE 
   int i;
 
   if (s->prefix)
-    ql++;
+  {
+    if (!option (OPTFLOWEDCOMPAT))
+      ql++;
+    else
+    {
+      /* use given prefix only for format=fixed replies to format=flowed
+       * if compatibility is required */
+      if (option (OPTTEXTFLOWED))
+       ql++;
+      else
+      {
+       state_puts (s->prefix, s);
+       sp = 0;
+      }
+    }
+  }
   for (i = 0; i < ql; i++)
     state_putc ('>', s);
   if (sp)
@@ -133,7 +148,10 @@ static void print_flowed_line (const cha
     print_indent (ql, s, ql > 0 || s->prefix);
     state_puts (oldpos, s);
 
-    if (pos < line + len)
+    /* only keep flowed paragraph flowable when generating f=f,
+     * for format=fixed strip them to improve interoperability
+     * with $flowed_compat set */
+    if (pos < line + len && (!option (OPTFLOWEDCOMPAT) && option 
(OPTTEXTFLOWED)))
       state_putc (' ', s);
     state_putc ('\n', s);
     oldpos = pos;