Skip to content

Commit fd547a9

Browse files
Ramsay JonesJunio C Hamano
authored andcommitted
Fix a "pointer type missmatch" warning.
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2832114 commit fd547a9

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ all::
8989
#
9090
# Define NO_ICONV if your libc does not properly support iconv.
9191
#
92+
# Define OLD_ICONV if your library has an old iconv(), where the second
93+
# (input buffer pointer) parameter is declared with type (const char **).
94+
#
9295
# Define NO_R_TO_GCC if your gcc does not like "-R/path/lib" that
9396
# tells runtime paths to dynamic libraries; "-Wl,-rpath=/path/lib"
9497
# is used instead.
@@ -573,6 +576,10 @@ ifdef NO_ICONV
573576
BASIC_CFLAGS += -DNO_ICONV
574577
endif
575578

579+
ifdef OLD_ICONV
580+
BASIC_CFLAGS += -DOLD_ICONV
581+
endif
582+
576583
ifdef PPC_SHA1
577584
SHA1_HEADER = "ppc/sha1.h"
578585
LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o

utf8.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,17 @@ int is_encoding_utf8(const char *name)
293293
* with iconv. If the conversion fails, returns NULL.
294294
*/
295295
#ifndef NO_ICONV
296+
#ifdef OLD_ICONV
297+
typedef const char * iconv_ibp;
298+
#else
299+
typedef char * iconv_ibp;
300+
#endif
296301
char *reencode_string(const char *in, const char *out_encoding, const char *in_encoding)
297302
{
298303
iconv_t conv;
299304
size_t insz, outsz, outalloc;
300-
char *out, *outpos, *cp;
305+
char *out, *outpos;
306+
iconv_ibp cp;
301307

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

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

0 commit comments

Comments
 (0)