From eb03beb60d4fb4e1614e0e69bfcfeba2882435ca Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Fri, 11 May 2001 16:37:27 +0000 Subject: [PATCH] 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.) --- handler.c | 26 ++++++++++++++++++++++++-- 1 file 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); -- 2.40.0