git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "ZHANG, Le" <r0bertz@gentoo.org>
To: git@vger.kernel.org
Cc: "ZHANG, Le" <r0bertz@gentoo.org>
Subject: [PATCH v4 1/4] mailinfo.c: convert_to_utf8(): added a target_charset parameter
Date: Mon, 29 Nov 2010 03:10:14 +0800	[thread overview]
Message-ID: <1290971417-4474-2-git-send-email-r0bertz@gentoo.org> (raw)
In-Reply-To: <1290971417-4474-1-git-send-email-r0bertz@gentoo.org>

This is required for my recode-patch patch which needs a seperate patch_charset variable.

Signed-off-by: ZHANG, Le <r0bertz@gentoo.org>
---
 builtin/mailinfo.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c
index 2320d98..1406d9f 100644
--- a/builtin/mailinfo.c
+++ b/builtin/mailinfo.c
@@ -492,22 +492,22 @@ static const char *guess_charset(const struct strbuf *line, const char *target_c
 	return "ISO8859-1";
 }
 
-static void convert_to_utf8(struct strbuf *line, const char *charset)
+static void convert_to_utf8(struct strbuf *line, const char *charset, const char *target_charset)
 {
 	char *out;
 
 	if (!charset || !*charset) {
-		charset = guess_charset(line, metainfo_charset);
+		charset = guess_charset(line, target_charset);
 		if (!charset)
 			return;
 	}
 
-	if (!strcasecmp(metainfo_charset, charset))
+	if (!strcasecmp(target_charset, charset))
 		return;
-	out = reencode_string(line->buf, metainfo_charset, charset);
+	out = reencode_string(line->buf, target_charset, charset);
 	if (!out)
 		die("cannot convert from %s to %s",
-		    charset, metainfo_charset);
+		    charset, target_charset);
 	strbuf_attach(line, out, strlen(out), strlen(out));
 }
 
@@ -577,7 +577,7 @@ static int decode_header_bq(struct strbuf *it)
 			break;
 		}
 		if (metainfo_charset)
-			convert_to_utf8(dec, charset_q.buf);
+			convert_to_utf8(dec, charset_q.buf, metainfo_charset);
 
 		strbuf_addbuf(&outbuf, dec);
 		strbuf_release(dec);
@@ -602,7 +602,7 @@ static void decode_header(struct strbuf *it)
 	 * This can be binary guck but there is no charset specified.
 	 */
 	if (metainfo_charset)
-		convert_to_utf8(it, "");
+		convert_to_utf8(it, "", metainfo_charset);
 }
 
 static void decode_transfer_encoding(struct strbuf *line)
@@ -796,7 +796,7 @@ static int handle_commit_msg(struct strbuf *line)
 
 	/* normalize the log message to UTF-8. */
 	if (metainfo_charset)
-		convert_to_utf8(line, charset.buf);
+		convert_to_utf8(line, charset.buf, metainfo_charset);
 
 	if (use_scissors && is_scissors_line(line)) {
 		int i;
-- 
1.7.3.2.344.gb3680.dirty

  reply	other threads:[~2010-11-28 19:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-28 19:10 [PATCH v4 0/4] add --recode-patch parameter to mailinfo and am ZHANG, Le
2010-11-28 19:10 ` ZHANG, Le [this message]
2010-11-29 20:23   ` [PATCH v4 1/4] mailinfo.c: convert_to_utf8(): added a target_charset parameter Junio C Hamano
2011-04-16  6:22     ` ZHANG, Le
2010-11-28 19:10 ` [PATCH v4 2/4] i18n.patchencoding: introduce a new config variable ZHANG, Le
2010-11-29 20:23   ` Junio C Hamano
2010-11-28 19:10 ` [PATCH v4 3/4] git mailinfo: added a --recode-patch parameter ZHANG, Le
2010-11-29 20:23   ` Junio C Hamano
2010-11-28 19:10 ` [PATCH v4 4/4] git am: " ZHANG, Le

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1290971417-4474-2-git-send-email-r0bertz@gentoo.org \
    --to=r0bertz@gentoo.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).