Skip to content

Commit ab50e38

Browse files
committed
mailinfo: move transfer_encoding to struct mailinfo
Signed-off-by: Junio C Hamano <[email protected]>
1 parent 28c6bfe commit ab50e38

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

builtin/mailinfo.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ struct mailinfo {
2323
const char *metainfo_charset;
2424

2525
char *message_id;
26+
enum {
27+
TE_DONTCARE, TE_QP, TE_BASE64
28+
} transfer_encoding;
2629
int patch_lines;
2730
int filter_stage; /* still reading log or are we copying patch? */
2831
int header_stage; /* still checking in-body headers? */
2932
};
3033

31-
static enum {
32-
TE_DONTCARE, TE_QP, TE_BASE64
33-
} transfer_encoding;
3434

3535
static struct strbuf charset = STRBUF_INIT;
3636
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)
221221
mi->message_id = strdup(line->buf);
222222
}
223223

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)
225226
{
226227
if (strcasestr(line->buf, "base64"))
227-
transfer_encoding = TE_BASE64;
228+
mi->transfer_encoding = TE_BASE64;
228229
else if (strcasestr(line->buf, "quoted-printable"))
229-
transfer_encoding = TE_QP;
230+
mi->transfer_encoding = TE_QP;
230231
else
231-
transfer_encoding = TE_DONTCARE;
232+
mi->transfer_encoding = TE_DONTCARE;
232233
}
233234

234235
static int is_multipart_boundary(const struct strbuf *line)
@@ -511,7 +512,7 @@ static int check_header(struct mailinfo *mi,
511512
len = strlen("Content-Transfer-Encoding: ");
512513
strbuf_add(&sb, line->buf + len, line->len - len);
513514
decode_header(mi, &sb);
514-
handle_content_transfer_encoding(&sb);
515+
handle_content_transfer_encoding(mi, &sb);
515516
ret = 1;
516517
goto check_header_out;
517518
}
@@ -544,11 +545,11 @@ static int check_header(struct mailinfo *mi,
544545
return ret;
545546
}
546547

547-
static void decode_transfer_encoding(struct strbuf *line)
548+
static void decode_transfer_encoding(struct mailinfo *mi, struct strbuf *line)
548549
{
549550
struct strbuf *ret;
550551

551-
switch (transfer_encoding) {
552+
switch (mi->transfer_encoding) {
552553
case TE_QP:
553554
ret = decode_q_segment(line, 0);
554555
break;
@@ -835,7 +836,7 @@ static int handle_boundary(struct mailinfo *mi, struct strbuf *line)
835836
}
836837

837838
/* set some defaults */
838-
transfer_encoding = TE_DONTCARE;
839+
mi->transfer_encoding = TE_DONTCARE;
839840
strbuf_reset(&charset);
840841

841842
/* slurp in this section's info */
@@ -873,9 +874,9 @@ static void handle_body(struct mailinfo *mi, struct strbuf *line)
873874
}
874875

875876
/* Unwrap transfer encoding */
876-
decode_transfer_encoding(line);
877+
decode_transfer_encoding(mi, line);
877878

878-
switch (transfer_encoding) {
879+
switch (mi->transfer_encoding) {
879880
case TE_BASE64:
880881
case TE_QP:
881882
{

0 commit comments

Comments
 (0)