Skip to content

Commit 3a8fcda

Browse files
committed
mailinfo: fold decode_header_bq() into decode_header()
In olden days we might have wanted to behave differently in decode_header() if the header line was encoded with RFC2047, but we apparently do not do so, hence this helper function can go, together with its return value. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2a5ce7c commit 3a8fcda

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

builtin/mailinfo.c

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -525,19 +525,17 @@ static void convert_to_utf8(struct strbuf *line, const char *charset)
525525
strbuf_attach(line, out, strlen(out), strlen(out));
526526
}
527527

528-
static int decode_header_bq(struct strbuf *it)
528+
static void decode_header(struct strbuf *it)
529529
{
530530
char *in, *ep, *cp;
531531
struct strbuf outbuf = STRBUF_INIT, *dec;
532532
struct strbuf charset_q = STRBUF_INIT, piecebuf = STRBUF_INIT;
533-
int rfc2047 = 0;
534533

535534
in = it->buf;
536535
while (in - it->buf <= it->len && (ep = strstr(in, "=?")) != NULL) {
537536
int encoding;
538537
strbuf_reset(&charset_q);
539538
strbuf_reset(&piecebuf);
540-
rfc2047 = 1;
541539

542540
if (in != ep) {
543541
/*
@@ -567,22 +565,22 @@ static int decode_header_bq(struct strbuf *it)
567565
ep += 2;
568566

569567
if (ep - it->buf >= it->len || !(cp = strchr(ep, '?')))
570-
goto decode_header_bq_out;
568+
goto release_return;
571569

572570
if (cp + 3 - it->buf > it->len)
573-
goto decode_header_bq_out;
571+
goto release_return;
574572
strbuf_add(&charset_q, ep, cp - ep);
575573

576574
encoding = cp[1];
577575
if (!encoding || cp[2] != '?')
578-
goto decode_header_bq_out;
576+
goto release_return;
579577
ep = strstr(cp + 3, "?=");
580578
if (!ep)
581-
goto decode_header_bq_out;
579+
goto release_return;
582580
strbuf_add(&piecebuf, cp + 3, ep - cp - 3);
583581
switch (tolower(encoding)) {
584582
default:
585-
goto decode_header_bq_out;
583+
goto release_return;
586584
case 'b':
587585
dec = decode_b_segment(&piecebuf);
588586
break;
@@ -601,17 +599,10 @@ static int decode_header_bq(struct strbuf *it)
601599
strbuf_addstr(&outbuf, in);
602600
strbuf_reset(it);
603601
strbuf_addbuf(it, &outbuf);
604-
decode_header_bq_out:
602+
release_return:
605603
strbuf_release(&outbuf);
606604
strbuf_release(&charset_q);
607605
strbuf_release(&piecebuf);
608-
return rfc2047;
609-
}
610-
611-
static void decode_header(struct strbuf *it)
612-
{
613-
if (decode_header_bq(it))
614-
return;
615606
}
616607

617608
static void decode_transfer_encoding(struct strbuf *line)

0 commit comments

Comments
 (0)