iconv_close (cd);
}
+/* when generating format=flowed ($text_flowed is set) from format=fixed,
+ * strip all trailing spaces to improve interoperability;
+ * if $text_flowed is unset, simply verbatim copy input
+ */
+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))
+ {
+ 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;
else if (ascii_strcasecmp ("flowed", mutt_get_parameter ("format", b->parameter)) == 0)
handler = rfc3676_handler;
else
- plaintext = 1;
+ handler = text_plain_handler;
}
else if (ascii_strcasecmp ("enriched", b->subtype) == 0)
handler = text_enriched_handler;
** 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 because
+ ** the quoting mechanism is strictly defined for format=flowed.
+ ** .pp
** This option is a format string, please see the description of
** $$index_format for supported \fCprintf(3)\fP-style sequences.
- ** .pp
- ** Because for \fCformat=lowed\fP style messages the quoting mechanism
- ** is strictly defined, this setting is ignored if $$text_flowed is
- ** \fIset\fP.
*/
{ "indent_str", DT_SYN, R_NONE, UL "indent_string", 0 },
/*
/*
* Copyright (C) 2005 Andreas Krennmair <ak@synflood.at>
* Copyright (C) 2005 Peter J. Holzer <hjp@hjp.net>
- * Copyright (C) 2005-7 Rocco Rutte <pdmef@gmx.net>
+ * Copyright (C) 2005-9 Rocco Rutte <pdmef@gmx.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
static size_t print_indent (int ql, STATE *s, int sp)
{
int i;
+ size_t len = 0;
if (s->prefix)
- ql++;
+ {
+ /* use given prefix only for format=fixed replies to format=flowed,
+ * for format=flowed replies to format=flowed, use '>' indentation
+ */
+ if (option (OPTTEXTFLOWED))
+ ql++;
+ else
+ {
+ state_puts (s->prefix, s);
+ len = mutt_strlen (s->prefix);
+ sp = 0;
+ }
+ }
for (i = 0; i < ql; i++)
state_putc ('>', s);
if (sp)
state_putc (' ', s);
- return ql + sp;
+ return ql + sp + len;
}
static void flush_par (STATE *s, size_t *sofar)
dprint (4, (debugfile, "f=f: word [%s], width = %ld, line = %ld\n", NONULL(p), (long)w, (long)*sofar));
if (w + 1 + (*sofar) > width)
{
- /* line would be too long, flush */
+ /* line would be too long, flush; for format=flowed we keep a
+ * trailing space but remove it otherwise for interoperability
+ */
dprint (4, (debugfile, "f=f: width: %ld\n", (long)*sofar));
- state_puts (" \n", s);
+ state_puts (option (OPTTEXTFLOWED) ? " \n" : "\n", s);
*sofar = 0;
}
if (*sofar == 0)
}
if (words > 0)
{
- /* put space before current word if we have words already */
- state_putc (' ', s);
+ /* put space before current word if we have words already,
+ and the current word isn't the trailing space */
+ if (w > 0)
+ state_putc (' ', s);
(*sofar)++;
}
state_puts (NONULL(p), s);