Hi Noah,

Thanks for the patch and explanations from
<https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00172.html>.

> iconv.m4 clears HAVE_ICONV if it detects iconv() bugs.  Docs list those bugs
> under "Portability problems fixed by Gnulib:".  If changing HAVE_ICONV were
> enough to qualify as a fix, then "This function is missing on some platforms"
> would also belong under that heading.  I'm proposing to move those bugs under
> "not fixed by Gnulib".

Good point. Yes, it doesn't belong under "fixed by Gnulib". But "not fixed by
Gnulib" is also not the right category. I'll list these under "handled by
Gnulib", with an extra explanation.

> Two of those iconv() bugs involve what POSIX calls "non-identical conversion".
> (GNU libc calls it "non-reversible conversion".)  The gnulib docs and code
> comments use terms "failures" and "conversion errors", but these bugs don't
> entail the distinct POSIX concept of "error" or failure.  Hence, I propose
> standardizing on the term "non-identical conversion".

"non-identical conversion" is a nonsensical term. Therefore it's better not
to use it. (Two objects can be identical if they are in the same mathematical
set. But when we use iconv, we are doing a mapping between the minimal byte
sequences of the input character set and the minimal byte sequences of the
destination character set; these are two different sets. If anyone uses
the term "identical" here, it would mean that the sets have an intersection,
and that the corresponding byte sequences are the same (e.g. like ISO-8859-1
and UTF-8 have, as intersection, the set of 1-byte sequences with values >= 0,
<= 0x7F).)

> The following patch has those changes.  It also updates modules/iconv_open to
> check HAVE_ICONV where modules/iconv checks it.

Good point, yes.

> Incidentally, the AIX iconv() buffer overrun was gone no later than AIX
> 7100-03-02-1412.  The non-POSIX-conforming return value remains as of AIX
> 7100-05-06-2028 and AIX 7200-04-01-1939.  Moreover, IBM documents it:
> https://www.ibm.com/support/knowledgecenter/ssw_aix_72/i_bostechref/iconv.html

Thanks for the info. Reflected in the patches below.

Bruno
>From afae962fedb0e0fb10c855435922a33f7a20c597 Mon Sep 17 00:00:00 2001
From: Noah Misch <n...@leadboat.com>
Date: Sun, 3 Jan 2021 19:17:52 +0100
Subject: [PATCH 1/3] iconv_open: Fix module description.

* modules/iconv_open (Include): Check HAVE_ICONV, like modules/iconv.
---
 ChangeLog          | 5 +++++
 modules/iconv_open | 4 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 82e4a10..78fa7be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2021-01-03  Noah Misch  <n...@leadboat.com>
+
+	iconv_open: Fix module description.
+	* modules/iconv_open (Include): Check HAVE_ICONV, like modules/iconv.
+
 2021-01-03  Bruno Haible  <br...@clisp.org>
 
 	stddef: Override wrong max_align_t on AIX 7 with xlc in 64-bit mode.
diff --git a/modules/iconv_open b/modules/iconv_open
index 3486901..dba4592 100644
--- a/modules/iconv_open
+++ b/modules/iconv_open
@@ -58,7 +58,9 @@ MAINTAINERCLEANFILES += iconv_open-aix.h iconv_open-hpux.h iconv_open-irix.h ico
 EXTRA_DIST           += iconv_open-aix.h iconv_open-hpux.h iconv_open-irix.h iconv_open-osf.h iconv_open-solaris.h iconv_open-zos.h
 
 Include:
-<iconv.h>
+#if HAVE_ICONV
+# include <iconv.h>
+#endif
 
 Link:
 $(LTLIBICONV) when linking with libtool, $(LIBICONV) otherwise
-- 
2.7.4

>From 00932fa5644e4a0da2214fe89bdc14663444921a Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 3 Jan 2021 19:19:01 +0100
Subject: [PATCH 2/3] iconv-h: Fix module description.

* modules/iconv-h (Include): Check HAVE_ICONV_H.
---
 ChangeLog       | 5 +++++
 modules/iconv-h | 4 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 78fa7be..4b9f083 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2021-01-03  Bruno Haible  <br...@clisp.org>
+
+	iconv-h: Fix module description.
+	* modules/iconv-h (Include): Check HAVE_ICONV_H.
+
 2021-01-03  Noah Misch  <n...@leadboat.com>
 
 	iconv_open: Fix module description.
diff --git a/modules/iconv-h b/modules/iconv-h
index 08371a4..c5f353a 100644
--- a/modules/iconv-h
+++ b/modules/iconv-h
@@ -46,7 +46,9 @@ endif
 MOSTLYCLEANFILES += iconv.h iconv.h-t
 
 Include:
-<iconv.h>
+#if HAVE_ICONV_H
+# include <iconv.h>
+#endif
 
 License:
 LGPLv2+
-- 
2.7.4

>From 5886f0967c83e27bf4cccfef13a1528195e3651a Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 3 Jan 2021 20:46:04 +0100
Subject: [PATCH 3/3] iconv, iconv_open: Improve documentation.

Reported by Noah Misch <n...@leadboat.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00172.html>.

* doc/posix-functions/iconv_open.texi: Add new paragraph "Portability
problems handled by Gnulib".
* doc/posix-functions/iconv.texi: Likewise. Update info about AIX.
* m4/iconv.m4 (AM_ICONV_LINK): Improve comments.
---
 ChangeLog                           | 10 ++++++++++
 doc/posix-functions/iconv.texi      |  8 +++++++-
 doc/posix-functions/iconv_open.texi |  6 ++++++
 m4/iconv.m4                         |  7 ++++---
 4 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4b9f083..6c042f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2021-01-03  Bruno Haible  <br...@clisp.org>
 
+	iconv, iconv_open: Improve documentation.
+	Reported by Noah Misch <n...@leadboat.com> in
+	<https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00172.html>.
+	* doc/posix-functions/iconv_open.texi: Add new paragraph "Portability
+	problems handled by Gnulib".
+	* doc/posix-functions/iconv.texi: Likewise. Update info about AIX.
+	* m4/iconv.m4 (AM_ICONV_LINK): Improve comments.
+
+2021-01-03  Bruno Haible  <br...@clisp.org>
+
 	iconv-h: Fix module description.
 	* modules/iconv-h (Include): Check HAVE_ICONV_H.
 
diff --git a/doc/posix-functions/iconv.texi b/doc/posix-functions/iconv.texi
index 01e7fd1..4e1c182 100644
--- a/doc/posix-functions/iconv.texi
+++ b/doc/posix-functions/iconv.texi
@@ -10,9 +10,15 @@ Portability problems fixed by Gnulib:
 @itemize
 @item
 GNU libiconv is not found if installed in @file{$PREFIX/lib}.
+@end itemize
+
+Portability problems handled by Gnulib
+(in the sense that @code{HAVE_ICONV} does not get defined if the system's
+@code{iconv} function has this problem):
+@itemize
 @item
 Failures are not distinguishable from successful returns on some platforms:
-AIX 5.1, Solaris 10.
+AIX 5.1..7.2, Solaris 10.
 @item
 A buffer overrun can occur on some platforms:
 AIX 6.1..7.1.
diff --git a/doc/posix-functions/iconv_open.texi b/doc/posix-functions/iconv_open.texi
index f46cf98..98f22ae 100644
--- a/doc/posix-functions/iconv_open.texi
+++ b/doc/posix-functions/iconv_open.texi
@@ -10,6 +10,12 @@ Portability problems fixed by either Gnulib module @code{iconv} or @code{iconv_o
 @itemize
 @item
 GNU libiconv is not found if installed in @file{$PREFIX/lib}.
+@end itemize
+
+Portability problems handled by either Gnulib module @code{iconv} or @code{iconv_open}
+(in the sense that @code{HAVE_ICONV} does not get defined if the system's
+@code{iconv_open} function has this problem):
+@itemize
 @item
 No converter from EUC-JP to UTF-8 is provided on some platforms:
 HP-UX 11.
diff --git a/m4/iconv.m4 b/m4/iconv.m4
index 04e3bad..d0e61de 100644
--- a/m4/iconv.m4
+++ b/m4/iconv.m4
@@ -1,4 +1,4 @@
-# iconv.m4 serial 23
+# iconv.m4 serial 24
 dnl Copyright (C) 2000-2002, 2007-2014, 2016-2021 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
@@ -92,8 +92,9 @@ AC_DEFUN([AM_ICONV_LINK],
 #endif
              ]],
              [[int result = 0;
-  /* Test against AIX 5.1 bug: Failures are not distinguishable from successful
-     returns.  */
+  /* Test against AIX 5.1...7.2 bug: Failures are not distinguishable from
+     successful returns.  This is even documented in
+     <https://www.ibm.com/support/knowledgecenter/ssw_aix_72/i_bostechref/iconv.html> */
   {
     iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
     if (cd_utf8_to_88591 != (iconv_t)(-1))
-- 
2.7.4

Reply via email to