diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-10-14 17:44:21 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-10-21 15:32:43 -0700 |
commit | 4f0f9d46c72f049c80c7cec0f321429ac2e49d11 (patch) | |
tree | 2b38b2990641906b3d3a540ad7388a67d6f2004d /builtin/mailinfo.c | |
parent | 9cc243f7a9b06fefb29cd8e4d91ecf97298c0cb5 (diff) | |
download | git-4f0f9d46c72f049c80c7cec0f321429ac2e49d11.tar.gz |
mailinfo: move check_header() after the helpers it uses
This way, we can lose a forward decl for decode_header().
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/mailinfo.c')
-rw-r--r-- | builtin/mailinfo.c | 135 |
1 files changed, 67 insertions, 68 deletions
diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c index 04927f7ae5..dd9aad2723 100644 --- a/builtin/mailinfo.c +++ b/builtin/mailinfo.c @@ -284,7 +284,6 @@ static void cleanup_space(struct strbuf *sb) } } -static void decode_header(struct strbuf *line); static const char *header[MAX_HDR_PARSED] = { "From","Subject","Date", }; @@ -312,73 +311,6 @@ static int is_format_patch_separator(const char *line, int len) return !memcmp(SAMPLE + (cp - line), cp, strlen(SAMPLE) - (cp - line)); } -static int check_header(const struct strbuf *line, - struct strbuf *hdr_data[], int overwrite) -{ - int i, ret = 0, len; - struct strbuf sb = STRBUF_INIT; - /* search for the interesting parts */ - for (i = 0; header[i]; i++) { - int len = strlen(header[i]); - if ((!hdr_data[i] || overwrite) && cmp_header(line, header[i])) { - /* Unwrap inline B and Q encoding, and optionally - * normalize the meta information to utf8. - */ - strbuf_add(&sb, line->buf + len + 2, line->len - len - 2); - decode_header(&sb); - handle_header(&hdr_data[i], &sb); - ret = 1; - goto check_header_out; - } - } - - /* Content stuff */ - if (cmp_header(line, "Content-Type")) { - len = strlen("Content-Type: "); - strbuf_add(&sb, line->buf + len, line->len - len); - decode_header(&sb); - strbuf_insert(&sb, 0, "Content-Type: ", len); - handle_content_type(&sb); - ret = 1; - goto check_header_out; - } - if (cmp_header(line, "Content-Transfer-Encoding")) { - len = strlen("Content-Transfer-Encoding: "); - strbuf_add(&sb, line->buf + len, line->len - len); - decode_header(&sb); - handle_content_transfer_encoding(&sb); - ret = 1; - goto check_header_out; - } - if (cmp_header(line, "Message-Id")) { - len = strlen("Message-Id: "); - strbuf_add(&sb, line->buf + len, line->len - len); - decode_header(&sb); - handle_message_id(&sb); - ret = 1; - goto check_header_out; - } - - /* for inbody stuff */ - if (starts_with(line->buf, ">From") && isspace(line->buf[5])) { - ret = is_format_patch_separator(line->buf + 1, line->len - 1); - goto check_header_out; - } - if (starts_with(line->buf, "[PATCH]") && isspace(line->buf[7])) { - for (i = 0; header[i]; i++) { - if (!strcmp("Subject", header[i])) { - handle_header(&hdr_data[i], line); - ret = 1; - goto check_header_out; - } - } - } - -check_header_out: - strbuf_release(&sb); - return ret; -} - static struct strbuf *decode_q_segment(const struct strbuf *q_seg, int rfc2047) { const char *in = q_seg->buf; @@ -539,6 +471,73 @@ release_return: strbuf_release(&piecebuf); } +static int check_header(const struct strbuf *line, + struct strbuf *hdr_data[], int overwrite) +{ + int i, ret = 0, len; + struct strbuf sb = STRBUF_INIT; + /* search for the interesting parts */ + for (i = 0; header[i]; i++) { + int len = strlen(header[i]); + if ((!hdr_data[i] || overwrite) && cmp_header(line, header[i])) { + /* Unwrap inline B and Q encoding, and optionally + * normalize the meta information to utf8. + */ + strbuf_add(&sb, line->buf + len + 2, line->len - len - 2); + decode_header(&sb); + handle_header(&hdr_data[i], &sb); + ret = 1; + goto check_header_out; + } + } + + /* Content stuff */ + if (cmp_header(line, "Content-Type")) { + len = strlen("Content-Type: "); + strbuf_add(&sb, line->buf + len, line->len - len); + decode_header(&sb); + strbuf_insert(&sb, 0, "Content-Type: ", len); + handle_content_type(&sb); + ret = 1; + goto check_header_out; + } + if (cmp_header(line, "Content-Transfer-Encoding")) { + len = strlen("Content-Transfer-Encoding: "); + strbuf_add(&sb, line->buf + len, line->len - len); + decode_header(&sb); + handle_content_transfer_encoding(&sb); + ret = 1; + goto check_header_out; + } + if (cmp_header(line, "Message-Id")) { + len = strlen("Message-Id: "); + strbuf_add(&sb, line->buf + len, line->len - len); + decode_header(&sb); + handle_message_id(&sb); + ret = 1; + goto check_header_out; + } + + /* for inbody stuff */ + if (starts_with(line->buf, ">From") && isspace(line->buf[5])) { + ret = is_format_patch_separator(line->buf + 1, line->len - 1); + goto check_header_out; + } + if (starts_with(line->buf, "[PATCH]") && isspace(line->buf[7])) { + for (i = 0; header[i]; i++) { + if (!strcmp("Subject", header[i])) { + handle_header(&hdr_data[i], line); + ret = 1; + goto check_header_out; + } + } + } + +check_header_out: + strbuf_release(&sb); + return ret; +} + static void decode_transfer_encoding(struct strbuf *line) { struct strbuf *ret; |