From mboxrd@z Thu Jan 1 00:00:00 1970 From: Junio C Hamano Subject: [PATCH 17/26] mailinfo: move charset to struct mailinfo Date: Tue, 13 Oct 2015 16:16:38 -0700 Message-ID: <1444778207-859-18-git-send-email-gitster@pobox.com> References: <1444778207-859-1-git-send-email-gitster@pobox.com> To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Wed Oct 14 01:17:48 2015 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Zm8pF-0006XH-HF for gcvg-git-2@plane.gmane.org; Wed, 14 Oct 2015 01:17:45 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753391AbbJMXRj (ORCPT ); Tue, 13 Oct 2015 19:17:39 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:34846 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751986AbbJMXRJ (ORCPT ); Tue, 13 Oct 2015 19:17:09 -0400 Received: by padcn9 with SMTP id cn9so3398508pad.2 for ; Tue, 13 Oct 2015 16:17:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=iBaYiJD9DiEcz2z6dRk7TOlTbaenKP/HSRvChBaRbyA=; b=NyODwN0sBhggqyZFehpdRdYFIbG+vmeomPYJMLuBNFYxU5MDFT3wxlv34QXS+ZXT4Y s93Q9F6N4N3igyMBfGMRMN+8c5/y/iMSLCP2ekPVuYG98s9X2YznEhrdWi93ttv9u82j qeDDoUCgwopAH00FL20yylb9mgFjDFb96mC1L95Pjgvys4+8HMmnFPn1zT+bSyLduwL7 91BEqQlY/7KNnXaIsun1cbaw7ExDEB1NHRBFQrL10kUXPqFzyjHpCGOkRJYJYSymKwrC j9uIuI9UHDWBhnr+zr7HZqQc5aU6KGTkMDQqgvP4Q9xXJOxnRoAVlC3kR+LrNeZOsrHH 13Cg== X-Received: by 10.67.5.42 with SMTP id cj10mr36048pad.128.1444778229136; Tue, 13 Oct 2015 16:17:09 -0700 (PDT) Received: from localhost ([2620:0:1000:861b:45f3:915b:d2ba:37bc]) by smtp.gmail.com with ESMTPSA id fe8sm5856426pab.40.2015.10.13.16.17.08 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 13 Oct 2015 16:17:08 -0700 (PDT) X-Mailer: git-send-email 2.6.1-320-g86a1181 In-Reply-To: <1444778207-859-1-git-send-email-gitster@pobox.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Signed-off-by: Junio C Hamano --- builtin/mailinfo.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c index fbfa27e..a51b2c5 100644 --- a/builtin/mailinfo.c +++ b/builtin/mailinfo.c @@ -22,6 +22,7 @@ struct mailinfo { int use_inbody_headers; /* defaults to 1 */ const char *metainfo_charset; + struct strbuf charset; char *message_id; enum { TE_DONTCARE, TE_QP, TE_BASE64 @@ -31,9 +32,6 @@ struct mailinfo { int header_stage; /* still checking in-body headers? */ }; - -static struct strbuf charset = STRBUF_INIT; - static struct strbuf **p_hdr_data, **s_hdr_data; #define MAX_HDR_PARSED 10 @@ -186,7 +184,7 @@ static struct strbuf *content[MAX_BOUNDARIES]; static struct strbuf **content_top = content; -static void handle_content_type(struct strbuf *line) +static void handle_content_type(struct mailinfo *mi, struct strbuf *line) { struct strbuf *boundary = xmalloc(sizeof(struct strbuf)); strbuf_init(boundary, line->len); @@ -200,7 +198,7 @@ static void handle_content_type(struct strbuf *line) *content_top = boundary; boundary = NULL; } - slurp_attr(line->buf, "charset=", &charset); + slurp_attr(line->buf, "charset=", &mi->charset); if (boundary) { strbuf_release(boundary); @@ -349,7 +347,7 @@ static int check_header(struct mailinfo *mi, strbuf_add(&sb, line->buf + len, line->len - len); decode_header(mi, &sb); strbuf_insert(&sb, 0, "Content-Type: ", len); - handle_content_type(&sb); + handle_content_type(mi, &sb); ret = 1; goto check_header_out; } @@ -774,7 +772,7 @@ static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line) mi->header_stage = 0; /* normalize the log message to UTF-8. */ - convert_to_utf8(mi, line, charset.buf); + convert_to_utf8(mi, line, mi->charset.buf); if (mi->use_scissors && is_scissors_line(line)) { int i; @@ -869,7 +867,7 @@ again: /* set some defaults */ mi->transfer_encoding = TE_DONTCARE; - strbuf_reset(&charset); + strbuf_reset(&mi->charset); /* slurp in this section's info */ while (read_one_header_line(line, mi->input)) @@ -1054,6 +1052,7 @@ static void setup_mailinfo(struct mailinfo *mi) memset(mi, 0, sizeof(*mi)); strbuf_init(&mi->name, 0); strbuf_init(&mi->email, 0); + strbuf_init(&mi->charset, 0); mi->header_stage = 1; mi->use_inbody_headers = 1; git_config(git_mailinfo_config, &mi); -- 2.6.1-320-g86a1181