Fix a "pointer type missmatch" warning.
authorRamsay Jones <ramsay@ramsay1.demon.co.uk>
Sat, 3 Mar 2007 18:29:03 +0000 (18:29 +0000)
committerJunio C Hamano <junkio@cox.net>
Sun, 4 Mar 2007 02:55:17 +0000 (18:55 -0800)
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>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Makefile
utf8.c
index 9f2cbe2cb9eb941b0a0d3c7edb7f931fabf6c145..e18b007da26e95b2c34297d2f8c55fb055c0f5dc 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -89,6 +89,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.
@@ -573,6 +576,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 211e100b95fa7f4f943965dac3e74339869a9b03..f381a7f137319f636955f2e4b21b8926a442c35e 100644 (file)
--- 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);