git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 6/6] Fix a "pointer type missmatch" warning.
@ 2007-03-03 18:29 Ramsay Jones
  2007-03-03 18:41 ` Johannes Schindelin
  0 siblings, 1 reply; 3+ messages in thread
From: Ramsay Jones @ 2007-03-03 18:29 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: GIT Mailing-list


In particular, the second parameter in the call to iconv() will
cause this warning if your library declares iconv() with the
second (input buffer pointer) parameter of type const char **.
This is the old prototype, which is none-the-less used by the
current version of newlib on Cygwin. (It appears in old versions
of glibc too).

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---

Note: set OLD_ICONV in your config.mak file on Cygwin.

  Makefile |    7 +++++++
  utf8.c   |   10 ++++++++--
  2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 8390a94..d447c43 100644
--- a/Makefile
+++ b/Makefile
@@ -85,6 +85,9 @@ all::
  #
  # Define NO_ICONV if your libc does not properly support iconv.
  #
+# Define OLD_ICONV if your library has an old iconv(), where the second
+# (input buffer pointer) parameter is declared with type (const char **).
+#
  # Define NO_R_TO_GCC if your gcc does not like "-R/path/lib" that
  # tells runtime paths to dynamic libraries; "-Wl,-rpath=/path/lib"
  # is used instead.
@@ -560,6 +563,10 @@ ifdef NO_ICONV
  	BASIC_CFLAGS += -DNO_ICONV
  endif

+ifdef OLD_ICONV
+	BASIC_CFLAGS += -DOLD_ICONV
+endif
+
  ifdef PPC_SHA1
  	SHA1_HEADER = "ppc/sha1.h"
  	LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
diff --git a/utf8.c b/utf8.c
index 211e100..f381a7f 100644
--- a/utf8.c
+++ b/utf8.c
@@ -293,11 +293,17 @@ int is_encoding_utf8(const char *name)
   * with iconv.  If the conversion fails, returns NULL.
   */
  #ifndef NO_ICONV
+#ifdef OLD_ICONV
+	typedef const char * iconv_ibp;
+#else
+	typedef char * iconv_ibp;
+#endif
  char *reencode_string(const char *in, const char *out_encoding, const char *in_encoding)
  {
  	iconv_t conv;
  	size_t insz, outsz, outalloc;
-	char *out, *outpos, *cp;
+	char *out, *outpos;
+	iconv_ibp cp;

  	if (!in_encoding)
  		return NULL;
@@ -309,7 +315,7 @@ char *reencode_string(const char *in, const char *out_encoding, const char *in_e
  	outalloc = outsz + 1; /* for terminating NUL */
  	out = xmalloc(outalloc);
  	outpos = out;
-	cp = (char *)in;
+	cp = (iconv_ibp)in;

  	while (1) {
  		size_t cnt = iconv(conv, &cp, &insz, &outpos, &outsz);
-- 
1.5.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 6/6] Fix a "pointer type missmatch" warning.
  2007-03-03 18:29 [PATCH 6/6] Fix a "pointer type missmatch" warning Ramsay Jones
@ 2007-03-03 18:41 ` Johannes Schindelin
  2007-03-04 16:30   ` Ramsay Jones
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Schindelin @ 2007-03-03 18:41 UTC (permalink / raw)
  To: Ramsay Jones; +Cc: Junio C Hamano, GIT Mailing-list

Hi,

On Sat, 3 Mar 2007, Ramsay Jones wrote:

> Note: set OLD_ICONV in your config.mak file on Cygwin.

Shouldn't you set it in Makefile instead?

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 6/6] Fix a "pointer type missmatch" warning.
  2007-03-03 18:41 ` Johannes Schindelin
@ 2007-03-04 16:30   ` Ramsay Jones
  0 siblings, 0 replies; 3+ messages in thread
From: Ramsay Jones @ 2007-03-04 16:30 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Junio C Hamano, GIT Mailing-list

Hi Johannes,

Johannes Schindelin wrote:
> On Sat, 3 Mar 2007, Ramsay Jones wrote:
> 
>> Note: set OLD_ICONV in your config.mak file on Cygwin.
> 
> Shouldn't you set it in Makefile instead?
> 

Yes, well the first version of that patch did exactly that!
(which caused me to use "git commit --amend" for the first time.)

However, I changed my mind, in order to be consistent with
the NO_C99_FORMAT patch (2/6); I am assuming that at some point
newlib will update iconv() to the new prototype, and I would
have to remove OLD_ICONV from the Makefile again.

To be clear, the setting of both NO_C99_FORMAT and OLD_ICONV in
the config.mak file is determined by the capabilities (version)
of your compiler/library. (And is not just a Cygwin issue)

Having said that, I don't really mind if it is added to the Makefile.

All the best,

Ramsay Jones

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-03-04 18:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-03 18:29 [PATCH 6/6] Fix a "pointer type missmatch" warning Ramsay Jones
2007-03-03 18:41 ` Johannes Schindelin
2007-03-04 16:30   ` Ramsay Jones

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).