[PATCH] Format=Flowed space-stuffing
Dennis Preiser <[email protected]> Sun, 16 Feb 2014 15:00:23 +0100
| Newsgroups | gmane.network.tin.devel |
|---|---|
| Message-ID | <[email protected]> |
--DocE+STaALJfprDB Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit Hello, from time to time I see article with ASCII art and with Format=Flowed. Here is an example: | Date: Thu, 13 Feb 2014 12:24:07 +0100 | From: Matthias Eißing <[email protected]> | MIME-Version: 1.0 | Newsgroups: ger.ct | Subject: Re: Ossis - Akt 2 | Content-Type: text/plain; charset=ISO-8859-1; format=flowed | Content-Transfer-Encoding: 8bit | Message-ID: <[email protected]> The ASCII art looks ugly because tin does not support Format=Flowed. The attached patch implements the space-stuffing part (skipping over the first space in a line). At least ASCII art looks better with the patch. Dennis --DocE+STaALJfprDB Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="2014-02-16.diff" diff -urp tin-2.2.0_r6/include/rfc2046.h tin-2.2.0_r7/include/rfc2046.h --- tin-2.2.0_r6/include/rfc2046.h 2013-11-26 09:11:11.000000000 +0100 +++ tin-2.2.0_r7/include/rfc2046.h 2014-02-16 12:09:32.000000000 +0100 @@ -63,6 +63,8 @@ # define BOUND_START 1 # define BOUND_END 2 +# define FORMAT_FIXED 0 +# define FORMAT_FLOWED 1 /* * Linked list of parameter/value pairs @@ -84,6 +86,7 @@ typedef struct part { unsigned type:3; /* Content major type */ unsigned encoding:3; /* Transfer encoding */ + unsigned format:1; /* Format=Fixed/Flowed */ # if 0 unsigned disposition:1; # endif /* 0 */ diff -urp tin-2.2.0_r6/src/cook.c tin-2.2.0_r7/src/cook.c --- tin-2.2.0_r6/src/cook.c 2013-12-28 14:49:48.000000000 +0100 +++ tin-2.2.0_r7/src/cook.c 2014-02-16 12:11:42.000000000 +0100 @@ -675,7 +675,18 @@ process_text_body_part( if (expand_ctrl_chars(&line, &max_line_len, tabwidth)) flags |= C_CTRLL; /* Line contains form-feed */ - put_cooked(max_line_len, wrap_lines && (!IS_LOCAL_CHARSET("Big5")), flags, "%s", line); + + buf = line; + + /* + * Skip over the first space in case of Format=Flowed (space-stuffing) + */ + if (part->format == FORMAT_FLOWED) { + if (line[0] == ' ') + ++buf; + } + + put_cooked(max_line_len, wrap_lines && (!IS_LOCAL_CHARSET("Big5")), flags, "%s", buf); } /* while */ /* diff -urp tin-2.2.0_r6/src/rfc2046.c tin-2.2.0_r7/src/rfc2046.c --- tin-2.2.0_r6/src/rfc2046.c 2013-12-24 06:29:54.000000000 +0100 +++ tin-2.2.0_r7/src/rfc2046.c 2014-02-16 12:13:01.000000000 +0100 @@ -388,6 +388,7 @@ parse_content_type( * Parse any parameters into a list */ if ((params = strtok(NULL, "\n")) != NULL) { + const char *format; #ifndef CHARSET_CONVERSION char defparms[] = CT_DEFPARMS; /* must be writable */ #endif /* !CHARSET_CONVERSION */ @@ -413,6 +414,10 @@ parse_content_type( } #endif /* !CHARSET_CONVERSION */ } + if ((format = get_param(content->params, "format"))) { + if (!strcasecmp(format, "flowed")) + content->format = FORMAT_FLOWED; + } } } @@ -479,6 +484,7 @@ new_part( ptr->subtype = my_strdup("plain"); ptr->description = NULL; ptr->encoding = ENCODING_7BIT; + ptr->format = FORMAT_FIXED; ptr->params = NULL; #ifndef CHARSET_CONVERSION --DocE+STaALJfprDB--