mailinfo: move transfer_encoding to struct mailinfo

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Oct 14, 2015 at 16:16 UTC ab50e38b5d15dc4490cc45c3d7ad6c232cb4c330
1 file changed +14 -13
builtin/mailinfo.c
+14 -13
@@ -23,14 +23,14 @@ struct mailinfo {
23 const char *metainfo_charset;
24
25 char *message_id;
26 + enum {
27 + TE_DONTCARE, TE_QP, TE_BASE64
28 + } transfer_encoding;
29 int patch_lines;
30 int filter_stage; /* still reading log or are we copying patch? */
31 int header_stage; /* still checking in-body headers? */
32 };
33
31 -static enum {
32 - TE_DONTCARE, TE_QP, TE_BASE64
33 -} transfer_encoding;
34
35 static struct strbuf charset = STRBUF_INIT;
36 static struct strbuf **p_hdr_data, **s_hdr_data;
@@ -221,14 +221,15 @@ static void handle_message_id(struct mailinfo *mi, const struct strbuf *line)
221 mi->message_id = strdup(line->buf);
222 }
223
224 -static void handle_content_transfer_encoding(const struct strbuf *line)
224 +static void handle_content_transfer_encoding(struct mailinfo *mi,
225 + const struct strbuf *line)
226 {
227 if (strcasestr(line->buf, "base64"))
227 - transfer_encoding = TE_BASE64;
228 + mi->transfer_encoding = TE_BASE64;
229 else if (strcasestr(line->buf, "quoted-printable"))
229 - transfer_encoding = TE_QP;
230 + mi->transfer_encoding = TE_QP;
231 else
231 - transfer_encoding = TE_DONTCARE;
232 + mi->transfer_encoding = TE_DONTCARE;
233 }
234
235 static int is_multipart_boundary(const struct strbuf *line)
@@ -511,7 +512,7 @@ static int check_header(struct mailinfo *mi,
512 len = strlen("Content-Transfer-Encoding: ");
513 strbuf_add(&sb, line->buf + len, line->len - len);
514 decode_header(mi, &sb);
514 - handle_content_transfer_encoding(&sb);
515 + handle_content_transfer_encoding(mi, &sb);
516 ret = 1;
517 goto check_header_out;
518 }
@@ -544,11 +545,11 @@ check_header_out:
545 return ret;
546 }
547
547 -static void decode_transfer_encoding(struct strbuf *line)
548 +static void decode_transfer_encoding(struct mailinfo *mi, struct strbuf *line)
549 {
550 struct strbuf *ret;
551
551 - switch (transfer_encoding) {
552 + switch (mi->transfer_encoding) {
553 case TE_QP:
554 ret = decode_q_segment(line, 0);
555 break;
@@ -835,7 +836,7 @@ again:
836 }
837
838 /* set some defaults */
838 - transfer_encoding = TE_DONTCARE;
839 + mi->transfer_encoding = TE_DONTCARE;
840 strbuf_reset(&charset);
841
842 /* slurp in this section's info */
@@ -873,9 +874,9 @@ static void handle_body(struct mailinfo *mi, struct strbuf *line)
874 }
875
876 /* Unwrap transfer encoding */
876 - decode_transfer_encoding(line);
877 + decode_transfer_encoding(mi, line);
878
878 - switch (transfer_encoding) {
879 + switch (mi->transfer_encoding) {
880 case TE_BASE64:
881 case TE_QP:
882 {