git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: Max Kirillov <max@max630.net>
To: Eric Sunshine <sunshine@sunshineco.com>,
	Jeff King <peff@peff.net>, Junio C Hamano <gitster@pobox.com>
Cc: Max Kirillov <max@max630.net>, git@vger.kernel.org
Subject: [PATCH] utf8.c: print warning about disabled iconv
Date: Sun,  7 Jun 2015 00:02:31 +0300	[thread overview]
Message-ID: <1433624551-20730-1-git-send-email-max@max630.net> (raw)

It is an allowed compile-time option to build git without iconv
support. Resulting build almost always functions correctly, and
never displays that it is missing anything, but reencode_string_len()
just never modifies its input. This gives undesirable result that
returned data or even data written into repository is incorrect
and user is not aware about it.

Show warning there is non-trivial reencoding requested. Show it only once
during program run.

Signed-off-by: Max Kirillov <max@max630.net>
---
Hi.

I have noticed there is some activity around the option, so it's not completely
abandoned. Maybe then this patch could be useful?
 utf8.c | 13 +++++++++++++
 utf8.h |  5 ++---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/utf8.c b/utf8.c
index 520fbb4..b1b836e 100644
--- a/utf8.c
+++ b/utf8.c
@@ -521,6 +521,19 @@ char *reencode_string_len(const char *in, int insz,
 	iconv_close(conv);
 	return out;
 }
+#else
+static int noiconv_warning_shown = 0;
+
+char *reencode_string_len(const char *in, int insz,
+			  const char *out_encoding, const char *in_encoding,
+			  int *outsz)
+{
+	if (!same_encoding(in_encoding, out_encoding) && !noiconv_warning_shown) {
+		warning("Iconv support is disabled at compile time. It is likely that\nincorrect data will be printed or stored in repository.\nConsider using other build for this task.");
+		noiconv_warning_shown = 1;
+	}
+	return NULL;
+}
 #endif
 
 /*
diff --git a/utf8.h b/utf8.h
index e4d9183..3d900f1 100644
--- a/utf8.h
+++ b/utf8.h
@@ -23,13 +23,12 @@ void strbuf_utf8_replace(struct strbuf *sb, int pos, int width,
 #ifndef NO_ICONV
 char *reencode_string_iconv(const char *in, size_t insz,
 			    iconv_t conv, int *outsz);
+#endif
+
 char *reencode_string_len(const char *in, int insz,
 			  const char *out_encoding,
 			  const char *in_encoding,
 			  int *outsz);
-#else
-#define reencode_string_len(a,b,c,d,e) NULL
-#endif
 
 static inline char *reencode_string(const char *in,
 				    const char *out_encoding,
-- 
2.3.4.2801.g3d0809b

             reply	other threads:[~2015-06-06 21:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-06 21:02 Max Kirillov [this message]
2015-06-08 16:16 ` [PATCH] utf8.c: print warning about disabled iconv Junio C Hamano
2015-06-08 21:07   ` Max Kirillov
2015-06-08 21:14     ` Junio C Hamano
2015-08-14 21:55 ` [PATCH v2] utf8.c: print warning about iconv errors Max Kirillov
2015-08-14 22:35   ` Junio C Hamano
2015-08-17 19:02     ` Jeff King
2015-08-17 19:49       ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=1433624551-20730-1-git-send-email-max@max630.net \
    --to=max@max630.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --cc=sunshine@sunshineco.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).