summaryrefslogtreecommitdiffstats
path: root/handler.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>2001-05-11 16:37:27 +0000
committerThomas Roessler <roessler@does-not-exist.org>2001-05-11 16:37:27 +0000
commiteb03beb60d4fb4e1614e0e69bfcfeba2882435ca (patch)
treeda4d45a8d90e9f05b1d72d9557f65fcbdb5aa204 /handler.c
parenta0a7688fb03fe69ec6110b46d20542f3a88b1567 (diff)
Improve handling of indented text when wrapping text/plain;
format=flowed. This is, in particular, important when replying to messages with indented text. I hope this code does The Right Thing most of the time now. (Further note that we still try to avoid wrapping at places where the user didn't do so.)
Diffstat (limited to 'handler.c')
-rw-r--r--handler.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/handler.c b/handler.c
index cf39f243..19293ec2 100644
--- a/handler.c
+++ b/handler.c
@@ -912,9 +912,18 @@ static void flowed_stuff (STATE *s, const char *cont, int level)
state_putc (' ', s);
}
+static char *flowed_skip_indent (char *prefix, char *cont)
+{
+ for (; *cont == ' ' || *cont == '\t'; cont++)
+ *prefix++ = *cont;
+ *prefix = '\0';
+ return cont;
+}
+
static void text_plain_flowed_handler (BODY *a, STATE *s)
{
char line[LONG_STRING];
+ char indent[LONG_STRING];
int quoted = -1;
int col = 0;
@@ -933,6 +942,8 @@ static void text_plain_flowed_handler (BODY *a, STATE *s)
char *tail = NULL;
char *lc = NULL;
char *t;
+
+ *indent = '\0';
if (s->prefix)
add = 1;
@@ -957,11 +968,16 @@ static void text_plain_flowed_handler (BODY *a, STATE *s)
cont = line + quoted;
if (*cont == ' ')
cont++;
-
+
+ /* If there is an indentation, record it. */
+ cont = flowed_skip_indent (indent, cont);
+
do
{
if (tail)
cont = tail;
+
+ SKIPWS (cont);
tail = NULL;
soft = 0;
@@ -1011,7 +1027,13 @@ static void text_plain_flowed_handler (BODY *a, STATE *s)
if (!col)
{
flowed_quote (s, quoted);
- flowed_stuff (s, cont, quoted + add);
+ if (*indent)
+ {
+ flowed_stuff (s, indent, quoted + add);
+ state_puts (indent, s);
+ }
+ else
+ flowed_stuff (s, cont, quoted + add);
}
state_puts (cont, s);