changeset 11910:32fc3a6c4499

Work around iconv_open problem on Solaris.
author Bruno Haible <bruno@clisp.org>
date Sun, 30 Aug 2009 14:29:34 +0200
parents 2cd9af4a1b6a
children d6806d72a21a
files ChangeLog doc/posix-functions/iconv_open.texi lib/iconv_open-solaris.gperf m4/iconv_open.m4 modules/iconv_open
diffstat 5 files changed, 55 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-08-30  Bruno Haible  <bruno@clisp.org>
+
+	Work around iconv_open problem on Solaris.
+	* lib/iconv_open-solaris.gperf: New file.
+	* m4/iconv_open.m4 (gl_FUNC_ICONV_OPEN): Also handle Solaris.
+	* modules/iconv_open (Files): Add lib/iconv_open-solaris.gperf.
+	(Makefile.am): Add rule for iconv_open-solaris.h. Augment
+	BUILT_SOURCES, MOSTLYCLEANFILES, MAINTAINERCLEANFILES, EXTRA_DIST.
+	* doc/posix-functions/iconv_open.texi: Mention the Solaris problem.
+
 2009-08-29  Jim Meyering  <meyering@redhat.com>
 
 	maint.mk: remove more coreutils-specific targets; XZ_OPT=-9ev
--- a/doc/posix-functions/iconv_open.texi
+++ b/doc/posix-functions/iconv_open.texi
@@ -20,7 +20,7 @@
 @item
 This function recognizes only non-standard aliases for many encodings (not
 the IANA registered encoding names) on many platforms:
-AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1.
+AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10.
 @end itemize
 
 Portability problems fixed by Gnulib module @code{iconv_open-utf}:
new file mode 100644
--- /dev/null
+++ b/lib/iconv_open-solaris.gperf
@@ -0,0 +1,30 @@
+struct mapping { int standard_name; const char vendor_name[10 + 1]; };
+%struct-type
+%language=ANSI-C
+%define slot-name standard_name
+%define hash-function-name mapping_hash
+%define lookup-function-name mapping_lookup
+%readonly-tables
+%global-table
+%define word-array-name mappings
+%pic
+%%
+# On Solaris 10, look in the "iconv -l" output. Some aliases are advertised but
+# not actually supported by the iconv() function and by the 'iconv' program.
+# For example:
+#   $ echo abc | iconv -f 646 -t ISO-8859-1
+#   Not supported 646 to ISO-8859-1
+#   $ echo abc | iconv -f 646 -t ISO8859-1
+$   abc
+ASCII, "646"
+ISO-8859-1, "ISO8859-1"
+ISO-8859-2, "ISO8859-2"
+ISO-8859-3, "ISO8859-3"
+ISO-8859-4, "ISO8859-4"
+ISO-8859-5, "ISO8859-5"
+ISO-8859-6, "ISO8859-6"
+ISO-8859-7, "ISO8859-7"
+ISO-8859-8, "ISO8859-8"
+ISO-8859-9, "ISO8859-9"
+ISO-8859-15, "ISO8859-15"
+CP1251, "ansi-1251"
--- a/m4/iconv_open.m4
+++ b/m4/iconv_open.m4
@@ -1,4 +1,4 @@
-# iconv_open.m4 serial 5
+# iconv_open.m4 serial 6
 dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -21,10 +21,11 @@
     if test $gl_func_iconv_gnu = no; then
       iconv_flavor=
       case "$host_os" in
-        aix*)  iconv_flavor=ICONV_FLAVOR_AIX ;;
-        irix*) iconv_flavor=ICONV_FLAVOR_IRIX ;;
-        hpux*) iconv_flavor=ICONV_FLAVOR_HPUX ;;
-        osf*)  iconv_flavor=ICONV_FLAVOR_OSF ;;
+        aix*)     iconv_flavor=ICONV_FLAVOR_AIX ;;
+        irix*)    iconv_flavor=ICONV_FLAVOR_IRIX ;;
+        hpux*)    iconv_flavor=ICONV_FLAVOR_HPUX ;;
+        osf*)     iconv_flavor=ICONV_FLAVOR_OSF ;;
+        solaris*) iconv_flavor=ICONV_FLAVOR_SOLARIS ;;
       esac
       if test -n "$iconv_flavor"; then
         AC_DEFINE_UNQUOTED([ICONV_FLAVOR], [$iconv_flavor],
--- a/modules/iconv_open
+++ b/modules/iconv_open
@@ -8,6 +8,7 @@
 lib/iconv_open-hpux.gperf
 lib/iconv_open-irix.gperf
 lib/iconv_open-osf.gperf
+lib/iconv_open-solaris.gperf
 m4/iconv_h.m4
 m4/iconv_open.m4
 
@@ -54,10 +55,13 @@
 iconv_open-osf.h: iconv_open-osf.gperf
 	$(GPERF) -m 10 $(srcdir)/iconv_open-osf.gperf > $(srcdir)/iconv_open-osf.h-t
 	mv $(srcdir)/iconv_open-osf.h-t $(srcdir)/iconv_open-osf.h
-BUILT_SOURCES        += iconv_open-aix.h iconv_open-hpux.h iconv_open-irix.h iconv_open-osf.h
-MOSTLYCLEANFILES     += iconv_open-aix.h-t iconv_open-hpux.h-t iconv_open-irix.h-t iconv_open-osf.h-t
-MAINTAINERCLEANFILES += iconv_open-aix.h iconv_open-hpux.h iconv_open-irix.h iconv_open-osf.h
-EXTRA_DIST           += iconv_open-aix.h iconv_open-hpux.h iconv_open-irix.h iconv_open-osf.h
+iconv_open-solaris.h: iconv_open-solaris.gperf
+	$(GPERF) -m 10 $(srcdir)/iconv_open-solaris.gperf > $(srcdir)/iconv_open-solaris.h-t
+	mv $(srcdir)/iconv_open-solaris.h-t $(srcdir)/iconv_open-solaris.h
+BUILT_SOURCES        += iconv_open-aix.h iconv_open-hpux.h iconv_open-irix.h iconv_open-osf.h iconv_open-solaris.h
+MOSTLYCLEANFILES     += iconv_open-aix.h-t iconv_open-hpux.h-t iconv_open-irix.h-t iconv_open-osf.h-t iconv_open-solaris.h-t
+MAINTAINERCLEANFILES += iconv_open-aix.h iconv_open-hpux.h iconv_open-irix.h iconv_open-osf.h iconv_open-solaris.h
+EXTRA_DIST           += iconv_open-aix.h iconv_open-hpux.h iconv_open-irix.h iconv_open-osf.h iconv_open-solaris.h
 
 Include:
 <iconv.h>