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 <gitster@pobox.com>

Junio C Hamano committed Oct 14, 2015 at 15:33 UTC 3a8fcdaf844910578d91ff225bcb1587ddb4d062
1 file changed +7 -16
builtin/mailinfo.c
+7 -16
@@ -525,19 +525,17 @@ static void convert_to_utf8(struct strbuf *line, const char *charset)
525 strbuf_attach(line, out, strlen(out), strlen(out));
526 }
527
528 -static int decode_header_bq(struct strbuf *it)
528 +static void decode_header(struct strbuf *it)
529 {
530 char *in, *ep, *cp;
531 struct strbuf outbuf = STRBUF_INIT, *dec;
532 struct strbuf charset_q = STRBUF_INIT, piecebuf = STRBUF_INIT;
533 - int rfc2047 = 0;
533
534 in = it->buf;
535 while (in - it->buf <= it->len && (ep = strstr(in, "=?")) != NULL) {
536 int encoding;
537 strbuf_reset(&charset_q);
538 strbuf_reset(&piecebuf);
540 - rfc2047 = 1;
539
540 if (in != ep) {
541 /*
@@ -567,22 +565,22 @@ static int decode_header_bq(struct strbuf *it)
565 ep += 2;
566
567 if (ep - it->buf >= it->len || !(cp = strchr(ep, '?')))
570 - goto decode_header_bq_out;
568 + goto release_return;
569
570 if (cp + 3 - it->buf > it->len)
573 - goto decode_header_bq_out;
571 + goto release_return;
572 strbuf_add(&charset_q, ep, cp - ep);
573
574 encoding = cp[1];
575 if (!encoding || cp[2] != '?')
578 - goto decode_header_bq_out;
576 + goto release_return;
577 ep = strstr(cp + 3, "?=");
578 if (!ep)
581 - goto decode_header_bq_out;
579 + goto release_return;
580 strbuf_add(&piecebuf, cp + 3, ep - cp - 3);
581 switch (tolower(encoding)) {
582 default:
585 - goto decode_header_bq_out;
583 + goto release_return;
584 case 'b':
585 dec = decode_b_segment(&piecebuf);
586 break;
@@ -601,17 +599,10 @@ static int decode_header_bq(struct strbuf *it)
599 strbuf_addstr(&outbuf, in);
600 strbuf_reset(it);
601 strbuf_addbuf(it, &outbuf);
604 -decode_header_bq_out:
602 +release_return:
603 strbuf_release(&outbuf);
604 strbuf_release(&charset_q);
605 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;
606 }
607
608 static void decode_transfer_encoding(struct strbuf *line)