* lib/idcache.c: Restore most of the 2006-11-06 patch, so as to
[gnulib.git] / lib / striconv.c
index 4ca9839..5326376 100644 (file)
@@ -16,9 +16,7 @@
    along with this program; if not, write to the Free Software Foundation,
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include <config.h>
 
 /* Specification.  */
 #include "striconv.h"
@@ -82,8 +80,11 @@ mem_cd_iconv (const char *src, size_t srclen, iconv_t cd,
            else
              return -1;
          }
-# if !defined _LIBICONV_VERSION && (defined sgi || defined __sgi)
-       /* Irix iconv() inserts a NUL byte if it cannot convert.  */
+# if !defined _LIBICONV_VERSION && !defined __GLIBC__
+       /* Irix iconv() inserts a NUL byte if it cannot convert.
+          NetBSD iconv() inserts a question mark if it cannot convert.
+          Only GNU libiconv and GNU libc are known to prefer to fail rather
+          than doing a lossy conversion.  */
        else if (res > 0)
          {
            errno = EILSEQ;
@@ -113,7 +114,8 @@ mem_cd_iconv (const char *src, size_t srclen, iconv_t cd,
       *lengthp = 0;
       return 0;
     }
-  result = (*resultp != NULL ? realloc (*resultp, length) : malloc (length));
+  result =
+    (char *) (*resultp != NULL ? realloc (*resultp, length) : malloc (length));
   if (result == NULL)
     {
       errno = ENOMEM;
@@ -149,8 +151,11 @@ mem_cd_iconv (const char *src, size_t srclen, iconv_t cd,
            else
              return -1;
          }
-# if !defined _LIBICONV_VERSION && (defined sgi || defined __sgi)
-       /* Irix iconv() inserts a NUL byte if it cannot convert.  */
+# if !defined _LIBICONV_VERSION && !defined __GLIBC__
+       /* Irix iconv() inserts a NUL byte if it cannot convert.
+          NetBSD iconv() inserts a question mark if it cannot convert.
+          Only GNU libiconv and GNU libc are known to prefer to fail rather
+          than doing a lossy conversion.  */
        else if (res > 0)
          {
            errno = EILSEQ;
@@ -290,8 +295,11 @@ str_cd_iconv (const char *src, iconv_t cd)
            else
              goto failed;
          }
-# if !defined _LIBICONV_VERSION && (defined sgi || defined __sgi)
-       /* Irix iconv() inserts a NUL byte if it cannot convert.  */
+# if !defined _LIBICONV_VERSION && !defined __GLIBC__
+       /* Irix iconv() inserts a NUL byte if it cannot convert.
+          NetBSD iconv() inserts a question mark if it cannot convert.
+          Only GNU libiconv and GNU libc are known to prefer to fail rather
+          than doing a lossy conversion.  */
        else if (res > 0)
          {
            errno = EILSEQ;