From mboxrd@z Thu Jan 1 00:00:00 1970 From: Junio C Hamano Subject: [PATCH v3 21/34] mailinfo: move charset to struct mailinfo Date: Mon, 19 Oct 2015 00:28:38 -0700 Message-ID: <1445239731-10677-22-git-send-email-gitster@pobox.com> References: <1444855557-2127-1-git-send-email-gitster@pobox.com> <1445239731-10677-1-git-send-email-gitster@pobox.com> To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Mon Oct 19 09:30:11 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 1Zo4tU-0003CF-DL for gcvg-git-2@plane.gmane.org; Mon, 19 Oct 2015 09:30:08 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752951AbbJSH3Y (ORCPT ); Mon, 19 Oct 2015 03:29:24 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:34132 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752897AbbJSH3T (ORCPT ); Mon, 19 Oct 2015 03:29:19 -0400 Received: by padhk11 with SMTP id hk11so21775147pad.1 for ; Mon, 19 Oct 2015 00:29:19 -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=ycmiuIgV9QHe6d9JtLEMD6Zbs6KyzUqUDVt1OTrRyy8=; b=Vp6ysqvvLdqvbqLrLYLF2KeCmi8c1jCHJdQPRNTWwERCl64dMO7TZIEKNdFOC5PeUQ x4t/wSUR6qeisA1+I4Z6Kmrde2vU89KRU9Tbk+NhopAOxa/f7UH+S7RvpwSAy77uH5lf 6o0qcHedBHrtEKzCjSQKVmWMnOMwqq3FJ+ybtRxJFW4uf3VwOF2gYRDD3egE5ZnAjHuU 9jv5ySuzrjXvYDy7Ibr4coz7nRMlqLTaFyZGTJ8OtI7pTfTs0hBzWsC3UngLJDl+3BCF yl0StSly9V3F0DQF5cG4Gl8gtUDrlv+ERF8Z+6BTD9bvSIFr+TBGhVhdbmUSepVIL/hy 4khA== X-Received: by 10.66.165.106 with SMTP id yx10mr33359436pab.102.1445239759115; Mon, 19 Oct 2015 00:29:19 -0700 (PDT) Received: from localhost ([2620:0:1000:861b:f5db:ee54:4f5:9373]) by smtp.gmail.com with ESMTPSA id gw3sm34480197pbc.46.2015.10.19.00.29.18 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 19 Oct 2015 00:29:18 -0700 (PDT) X-Mailer: git-send-email 2.6.2-388-g10c4a0e In-Reply-To: <1445239731-10677-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 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c index 18781b7..810d132 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; } @@ -745,7 +743,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; @@ -840,7 +838,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)) @@ -1027,6 +1025,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); @@ -1036,6 +1035,7 @@ static void clear_mailinfo(struct mailinfo *mi) { strbuf_release(&mi->name); strbuf_release(&mi->email); + strbuf_release(&mi->charset); free(mi->message_id); } -- 2.6.2-383-g144b2e6