From 257c776fa7bb6336f307c34329fd173fecacec9a Mon Sep 17 00:00:00 2001
From: Bruno Haible
Date: Sun, 18 Jul 2010 23:10:13 +0200
Subject: [PATCH] Avoid warnings on systems where sizeof(long) < sizeof(void*).
---
ChangeLog | 17 +++++++++++++++++
Makefile.devel | 10 +++++-----
configure.ac | 7 ++++++-
lib/config.h.in | 9 +++++++++
lib/genaliases.c | 4 ++--
lib/genaliases2.c | 4 ++--
lib/iconv.c | 15 +++++++++++----
7 files changed, 52 insertions(+), 14 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f1f0428..892bd21 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2010-07-18 Ozkan Sezer
+ Bruno Haible
+
+ Avoid warnings on systems where sizeof(long) < sizeof(void*).
+ * configure.ac: Check for stdint.h, inttypes.h. Invoke
+ AC_TYPE_INTPTR_T.
+ * lib/config.h.in (HAVE_STDINT_H, HAVE_INTTYPES_H, intptr_t): New
+ macros.
+ * lib/genaliases.c (emit_encoding): Emit a cast to intptr_t rather than
+ to long.
+ * lib/genaliases2.c (emit_encoding): Likewise.
+ * lib/iconv.c: Include , , .
+ (sysdep_aliases): Cast to intptr_t rather than to long.
+ * Makefile.devel (lib/aliases.h, lib/aliases_sysaix.h,
+ lib/aliases_syshpux.h, lib/aliases_sysosf1.h, lib/aliases_syssolaris.h):
+ Change a cast to intptr_t in the gperf output.
+
2010-07-03 Bruno Haible
* Makefile.devel (AUTOCONF, AUTOHEADER): Switch to version 2.66.
diff --git a/Makefile.devel b/Makefile.devel
index 70096a3..09d3c4d 100644
--- a/Makefile.devel
+++ b/Makefile.devel
@@ -105,7 +105,7 @@ lib/aliases.h lib/canonical.h lib/canonical_local.h : lib/encodings.def lib/enco
$(CC) $(CFLAGS) lib/genaliases.c -o genaliases
./genaliases > lib/aliases.gperf 3> canonical.sh 4> canonical_local.sh
$(RM) genaliases
- $(GPERF) -m 10 lib/aliases.gperf > tmp.h
+ $(GPERF) -m 10 lib/aliases.gperf | sed -e 's/(long)/(intptr_t)/' > tmp.h
$(CP) tmp.h lib/aliases.h
sh canonical.sh > lib/canonical.h
sh canonical_local.sh > lib/canonical_local.h
@@ -115,7 +115,7 @@ lib/aliases_sysaix.h lib/canonical_sysaix.h lib/canonical_local_sysaix.h : lib/e
$(CC) $(CFLAGS) -DUSE_AIX_ALIASES lib/genaliases.c -o genaliases
./genaliases > lib/aliases_sysaix.gperf 3> canonical.sh 4> canonical_local.sh
$(RM) genaliases
- $(GPERF) -m 10 lib/aliases_sysaix.gperf > tmp.h
+ $(GPERF) -m 10 lib/aliases_sysaix.gperf | sed -e 's/(long)/(intptr_t)/' > tmp.h
$(CP) tmp.h lib/aliases_sysaix.h
sh canonical.sh > lib/canonical_sysaix.h
sh canonical_local.sh > lib/canonical_local_sysaix.h
@@ -125,7 +125,7 @@ lib/aliases_syshpux.h lib/canonical_syshpux.h lib/canonical_local_syshpux.h : li
$(CC) $(CFLAGS) -DUSE_HPUX_ALIASES lib/genaliases.c -o genaliases
./genaliases > lib/aliases_syshpux.gperf 3> canonical.sh 4> canonical_local.sh
$(RM) genaliases
- $(GPERF) -m 10 lib/aliases_syshpux.gperf > tmp.h
+ $(GPERF) -m 10 lib/aliases_syshpux.gperf | sed -e 's/(long)/(intptr_t)/' > tmp.h
$(CP) tmp.h lib/aliases_syshpux.h
sh canonical.sh > lib/canonical_syshpux.h
sh canonical_local.sh > lib/canonical_local_syshpux.h
@@ -135,7 +135,7 @@ lib/aliases_sysosf1.h lib/canonical_sysosf1.h lib/canonical_local_sysosf1.h : li
$(CC) $(CFLAGS) -DUSE_OSF1_ALIASES lib/genaliases.c -o genaliases
./genaliases > lib/aliases_sysosf1.gperf 3> canonical.sh 4> canonical_local.sh
$(RM) genaliases
- $(GPERF) -m 10 lib/aliases_sysosf1.gperf > tmp.h
+ $(GPERF) -m 10 lib/aliases_sysosf1.gperf | sed -e 's/(long)/(intptr_t)/' > tmp.h
$(CP) tmp.h lib/aliases_sysosf1.h
sh canonical.sh > lib/canonical_sysosf1.h
sh canonical_local.sh > lib/canonical_local_sysosf1.h
@@ -145,7 +145,7 @@ lib/aliases_syssolaris.h lib/canonical_syssolaris.h lib/canonical_local_syssolar
$(CC) $(CFLAGS) -DUSE_SOLARIS_ALIASES lib/genaliases.c -o genaliases
./genaliases > lib/aliases_syssolaris.gperf 3> canonical.sh 4> canonical_local.sh
$(RM) genaliases
- $(GPERF) -m 10 lib/aliases_syssolaris.gperf > tmp.h
+ $(GPERF) -m 10 lib/aliases_syssolaris.gperf | sed -e 's/(long)/(intptr_t)/' > tmp.h
$(CP) tmp.h lib/aliases_syssolaris.h
sh canonical.sh > lib/canonical_syssolaris.h
sh canonical_local.sh > lib/canonical_local_syssolaris.h
diff --git a/configure.ac b/configure.ac
index 3585bd2..c16d34d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -100,12 +100,17 @@ gl_VISIBILITY
AM_ICONV
AM_GNU_GETTEXT([external], [need-ngettext])
+dnl checks for header files
+
+AC_CHECK_HEADERS([stdint.h inttypes.h])
+
dnl checks for typedefs
+AC_TYPE_INTPTR_T
AC_TYPE_MBSTATE_T
gt_TYPE_WCHAR_T
-dnl checks for header files, functions and declarations
+dnl checks for functions and declarations
if test "$am_cv_func_iconv" = yes -a -n "$am_cv_proto_iconv_arg1"; then
ICONV_CONST="const"
diff --git a/lib/config.h.in b/lib/config.h.in
index 6db23e1..b7cd3e9 100644
--- a/lib/config.h.in
+++ b/lib/config.h.in
@@ -23,6 +23,9 @@
/* Define to 1 if the package shall run at any location in the filesystem. */
#undef ENABLE_RELOCATABLE
+/* Define to a type if , , do not define. */
+#undef intptr_t
+
/* Define to a type if does not define. */
#undef mbstate_t
@@ -35,6 +38,9 @@
/* Define to 1 if you have the getc_unlocked() function. */
#undef HAVE_GETC_UNLOCKED
+/* Define to 1 if you have the header file. */
+#undef HAVE_INTTYPES_H
+
/* Define if you have and nl_langinfo(CODESET). */
#undef HAVE_LANGINFO_CODESET
@@ -47,6 +53,9 @@
/* Define to 1 if you have the header file. */
#undef HAVE_STDDEF_H
+/* Define to 1 if you have the header file. */
+#undef HAVE_STDINT_H
+
/* Define to 1 if you have the header file. */
#undef HAVE_STDLIB_H
diff --git a/lib/genaliases.c b/lib/genaliases.c
index b54b97d..0aecd74 100644
--- a/lib/genaliases.c
+++ b/lib/genaliases.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999-2001, 2003, 2005, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2001, 2003, 2005, 2008, 2010 Free Software Foundation, Inc.
This file is part of the GNU LIBICONV Library.
The GNU LIBICONV Library is free software; you can redistribute it
@@ -51,7 +51,7 @@ static void emit_encoding (FILE* out1, FILE* out2, const char* const* names, siz
putc(c, out2);
}
}
- fprintf(out2,"\")' tmp.h | sed -e 's|^.*\\(stringpool_str[0-9]*\\).*$| (int)(long)\\&((struct stringpool_t *)0)->\\1,|'\n");
+ fprintf(out2,"\")' tmp.h | sed -e 's|^.*\\(stringpool_str[0-9]*\\).*$| (int)(intptr_t)\\&((struct stringpool_t *)0)->\\1,|'\n");
for (; n > 0; names++, n--)
emit_alias(out1, *names, c_name);
}
diff --git a/lib/genaliases2.c b/lib/genaliases2.c
index 1b789ed..d0ae844 100644
--- a/lib/genaliases2.c
+++ b/lib/genaliases2.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999-2003, 2005, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2003, 2005, 2008, 2010 Free Software Foundation, Inc.
This file is part of the GNU LIBICONV Library.
The GNU LIBICONV Library is free software; you can redistribute it
@@ -44,7 +44,7 @@ static void emit_alias (FILE* out1, const char* tag, const char* alias, const ch
static void emit_encoding (FILE* out1, FILE* out2, const char* tag, const char* const* names, size_t n, const char* c_name)
{
- fprintf(out2," (int)(long)&((struct stringpool2_t *)0)->stringpool_%s_%u,\n",tag,counter);
+ fprintf(out2," (int)(intptr_t)&((struct stringpool2_t *)0)->stringpool_%s_%u,\n",tag,counter);
for (; n > 0; names++, n--)
emit_alias(out1, tag, *names, c_name);
}
diff --git a/lib/iconv.c b/lib/iconv.c
index 5ea9499..2d4dabd 100644
--- a/lib/iconv.c
+++ b/lib/iconv.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1999-2008 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2008, 2010 Free Software Foundation, Inc.
* This file is part of the GNU LIBICONV Library.
*
* The GNU LIBICONV Library is free software; you can redistribute it
@@ -20,8 +20,15 @@
#include
-#include
-#include
+#include /* for abort(), malloc(), free(), qsort(), MB_CUR_MAX */
+#include /* for memcpy(), memset(), strcmp() */
+#include /* for intptr_t */
+#if HAVE_STDINT_H
+#include /* for intptr_t */
+#endif
+#if HAVE_INTTYPES_H
+#include /* for intptr_t */
+#endif
#include "config.h"
#include "localcharset.h"
@@ -168,7 +175,7 @@ static const struct stringpool2_t stringpool2_contents = {
};
#define stringpool2 ((const char *) &stringpool2_contents)
static const struct alias sysdep_aliases[] = {
-#define S(tag,name,encoding_index) { (int)(long)&((struct stringpool2_t *)0)->stringpool_##tag, encoding_index },
+#define S(tag,name,encoding_index) { (int)(intptr_t)&((struct stringpool2_t *)0)->stringpool_##tag, encoding_index },
#include "aliases2.h"
#undef S
};
--
1.6.3.2