From f7c3580478601e3a77dc864e5a1d91c1edad5187 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= <debian@jff.email>
Date: Wed, 7 Mar 2018 05:31:03 +0100
Subject: New upstream version 0.9.9

---
 tests/uniconv/test-u16-conv-from-enc.c    | 166 +++++++++++++++---------------
 tests/uniconv/test-u16-conv-to-enc.c      |   2 +-
 tests/uniconv/test-u16-strconv-from-enc.c |  76 +++++++-------
 tests/uniconv/test-u16-strconv-to-enc.c   |   2 +-
 tests/uniconv/test-u32-conv-from-enc.c    | 166 +++++++++++++++---------------
 tests/uniconv/test-u32-conv-to-enc.c      |   2 +-
 tests/uniconv/test-u32-strconv-from-enc.c |  76 +++++++-------
 tests/uniconv/test-u32-strconv-to-enc.c   |   2 +-
 tests/uniconv/test-u8-conv-from-enc.c     | 148 +++++++++++++-------------
 tests/uniconv/test-u8-conv-to-enc.c       |   2 +-
 tests/uniconv/test-u8-strconv-from-enc.c  |  64 ++++++------
 tests/uniconv/test-u8-strconv-to-enc.c    |   2 +-
 12 files changed, 366 insertions(+), 342 deletions(-)

(limited to 'tests/uniconv')

diff --git a/tests/uniconv/test-u16-conv-from-enc.c b/tests/uniconv/test-u16-conv-from-enc.c
index be20406b..d1d70267 100644
--- a/tests/uniconv/test-u16-conv-from-enc.c
+++ b/tests/uniconv/test-u16-conv-from-enc.c
@@ -1,5 +1,5 @@
 /* Test of conversion to UTF-16 from legacy encodings.
-   Copyright (C) 2007-2017 Free Software Foundation, Inc.
+   Copyright (C) 2007-2018 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
 
 #include "unistr.h"
 #include "macros.h"
+extern int iconv_supports_encoding (const char *encoding);
 
 /* Magic number for detecting bounds violations.  */
 #define MAGIC 0x1983EFF1
@@ -117,98 +118,101 @@ main ()
 
   /* autodetect_jp is only supported when iconv() support ISO-2022-JP-2.  */
 # if defined _LIBICONV_VERSION || !(defined _AIX || defined __sgi || defined __hpux || defined __osf__ || defined __sun)
-  /* Test conversions from autodetect_jp to UTF-16.  */
-  for (h = 0; h < SIZEOF (handlers); h++)
+  if (iconv_supports_encoding ("ISO-2022-JP-2"))
     {
-      enum iconv_ilseq_handler handler = handlers[h];
-      static const char input[] = "\244\263\244\363\244\313\244\301\244\317"; /* こんにちは in EUC-JP */
-      static const uint16_t expected[] = /* こんにちは */
-        {
-          0x3053, 0x3093, 0x306B, 0x3061, 0x306F
-        };
-      for (o = 0; o < 2; o++)
+      /* Test conversions from autodetect_jp to UTF-16.  */
+      for (h = 0; h < SIZEOF (handlers); h++)
         {
-          size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
-          size_t length;
-          uint16_t *result = u16_conv_from_encoding ("autodetect_jp", handler,
-                                                     input, strlen (input),
-                                                     offsets,
-                                                     NULL, &length);
-          ASSERT (result != NULL);
-          ASSERT (length == SIZEOF (expected));
-          ASSERT (u16_cmp (result, expected, SIZEOF (expected)) == 0);
-          if (o)
+          enum iconv_ilseq_handler handler = handlers[h];
+          static const char input[] = "\244\263\244\363\244\313\244\301\244\317"; /* こんにちは in EUC-JP */
+          static const uint16_t expected[] = /* こんにちは */
             {
-              for (i = 0; i < 10; i++)
-                ASSERT (offsets[i] == ((i % 2) == 0 ? i / 2 : (size_t)(-1)));
-              ASSERT (offsets[10] == MAGIC);
-              free (offsets);
+              0x3053, 0x3093, 0x306B, 0x3061, 0x306F
+            };
+          for (o = 0; o < 2; o++)
+            {
+              size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
+              size_t length;
+              uint16_t *result = u16_conv_from_encoding ("autodetect_jp", handler,
+                                                         input, strlen (input),
+                                                         offsets,
+                                                         NULL, &length);
+              ASSERT (result != NULL);
+              ASSERT (length == SIZEOF (expected));
+              ASSERT (u16_cmp (result, expected, SIZEOF (expected)) == 0);
+              if (o)
+                {
+                  for (i = 0; i < 10; i++)
+                    ASSERT (offsets[i] == ((i % 2) == 0 ? i / 2 : (size_t)(-1)));
+                  ASSERT (offsets[10] == MAGIC);
+                  free (offsets);
+                }
+              free (result);
             }
-          free (result);
         }
-    }
-  for (h = 0; h < SIZEOF (handlers); h++)
-    {
-      enum iconv_ilseq_handler handler = handlers[h];
-      static const char input[] = "\202\261\202\361\202\311\202\277\202\315"; /* こんにちは in Shift_JIS */
-      static const uint16_t expected[] = /* こんにちは */
-        {
-          0x3053, 0x3093, 0x306B, 0x3061, 0x306F
-        };
-      for (o = 0; o < 2; o++)
+      for (h = 0; h < SIZEOF (handlers); h++)
         {
-          size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
-          size_t length;
-          uint16_t *result = u16_conv_from_encoding ("autodetect_jp", handler,
-                                                     input, strlen (input),
-                                                     offsets,
-                                                     NULL, &length);
-          ASSERT (result != NULL);
-          ASSERT (length == SIZEOF (expected));
-          ASSERT (u16_cmp (result, expected, SIZEOF (expected)) == 0);
-          if (o)
+          enum iconv_ilseq_handler handler = handlers[h];
+          static const char input[] = "\202\261\202\361\202\311\202\277\202\315"; /* こんにちは in Shift_JIS */
+          static const uint16_t expected[] = /* こんにちは */
             {
-              for (i = 0; i < 10; i++)
-                ASSERT (offsets[i] == ((i % 2) == 0 ? i / 2 : (size_t)(-1)));
-              ASSERT (offsets[10] == MAGIC);
-              free (offsets);
+              0x3053, 0x3093, 0x306B, 0x3061, 0x306F
+            };
+          for (o = 0; o < 2; o++)
+            {
+              size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
+              size_t length;
+              uint16_t *result = u16_conv_from_encoding ("autodetect_jp", handler,
+                                                         input, strlen (input),
+                                                         offsets,
+                                                         NULL, &length);
+              ASSERT (result != NULL);
+              ASSERT (length == SIZEOF (expected));
+              ASSERT (u16_cmp (result, expected, SIZEOF (expected)) == 0);
+              if (o)
+                {
+                  for (i = 0; i < 10; i++)
+                    ASSERT (offsets[i] == ((i % 2) == 0 ? i / 2 : (size_t)(-1)));
+                  ASSERT (offsets[10] == MAGIC);
+                  free (offsets);
+                }
+              free (result);
             }
-          free (result);
         }
-    }
-  for (h = 0; h < SIZEOF (handlers); h++)
-    {
-      enum iconv_ilseq_handler handler = handlers[h];
-      static const char input[] = "\033$B$3$s$K$A$O\033(B"; /* こんにちは in ISO-2022-JP-2 */
-      static const uint16_t expected[] = /* こんにちは */
-        {
-          0x3053, 0x3093, 0x306B, 0x3061, 0x306F
-        };
-      for (o = 0; o < 2; o++)
+      for (h = 0; h < SIZEOF (handlers); h++)
         {
-          size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
-          size_t length;
-          uint16_t *result = u16_conv_from_encoding ("autodetect_jp", handler,
-                                                     input, strlen (input),
-                                                     offsets,
-                                                     NULL, &length);
-          ASSERT (result != NULL);
-          ASSERT (length == SIZEOF (expected));
-          ASSERT (u16_cmp (result, expected, SIZEOF (expected)) == 0);
-          if (o)
+          enum iconv_ilseq_handler handler = handlers[h];
+          static const char input[] = "\033$B$3$s$K$A$O\033(B"; /* こんにちは in ISO-2022-JP-2 */
+          static const uint16_t expected[] = /* こんにちは */
             {
-              for (i = 0; i < 16; i++)
-                ASSERT (offsets[i] == (i == 0 ? 0 :
-                                       i == 5 ? 1 :
-                                       i == 7 ? 2 :
-                                       i == 9 ? 3 :
-                                       i == 11 ? 4 :
-                                       i == 13 ? 5 :
-                                       (size_t)(-1)));
-              ASSERT (offsets[16] == MAGIC);
-              free (offsets);
+              0x3053, 0x3093, 0x306B, 0x3061, 0x306F
+            };
+          for (o = 0; o < 2; o++)
+            {
+              size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
+              size_t length;
+              uint16_t *result = u16_conv_from_encoding ("autodetect_jp", handler,
+                                                         input, strlen (input),
+                                                         offsets,
+                                                         NULL, &length);
+              ASSERT (result != NULL);
+              ASSERT (length == SIZEOF (expected));
+              ASSERT (u16_cmp (result, expected, SIZEOF (expected)) == 0);
+              if (o)
+                {
+                  for (i = 0; i < 16; i++)
+                    ASSERT (offsets[i] == (i == 0 ? 0 :
+                                           i == 5 ? 1 :
+                                           i == 7 ? 2 :
+                                           i == 9 ? 3 :
+                                           i == 11 ? 4 :
+                                           i == 13 ? 5 :
+                                           (size_t)(-1)));
+                  ASSERT (offsets[16] == MAGIC);
+                  free (offsets);
+                }
+              free (result);
             }
-          free (result);
         }
     }
 # endif
diff --git a/tests/uniconv/test-u16-conv-to-enc.c b/tests/uniconv/test-u16-conv-to-enc.c
index 574cf116..8c2f7660 100644
--- a/tests/uniconv/test-u16-conv-to-enc.c
+++ b/tests/uniconv/test-u16-conv-to-enc.c
@@ -1,5 +1,5 @@
 /* Test of conversion from UTF-16 to legacy encodings.
-   Copyright (C) 2007-2017 Free Software Foundation, Inc.
+   Copyright (C) 2007-2018 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
diff --git a/tests/uniconv/test-u16-strconv-from-enc.c b/tests/uniconv/test-u16-strconv-from-enc.c
index b27d42ad..393634e6 100644
--- a/tests/uniconv/test-u16-strconv-from-enc.c
+++ b/tests/uniconv/test-u16-strconv-from-enc.c
@@ -1,5 +1,5 @@
 /* Test of conversion to UTF-16 from legacy encodings.
-   Copyright (C) 2007-2017 Free Software Foundation, Inc.
+   Copyright (C) 2007-2018 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 #include "unistr.h"
 #include "macros.h"
+extern int iconv_supports_encoding (const char *encoding);
 
 int
 main ()
@@ -71,45 +72,48 @@ main ()
 
   /* autodetect_jp is only supported when iconv() support ISO-2022-JP-2.  */
 # if defined _LIBICONV_VERSION || !(defined _AIX || defined __sgi || defined __hpux || defined __osf__ || defined __sun)
-  /* Test conversions from autodetect_jp to UTF-16.  */
-  for (h = 0; h < SIZEOF (handlers); h++)
+  if (iconv_supports_encoding ("ISO-2022-JP-2"))
     {
-      enum iconv_ilseq_handler handler = handlers[h];
-      static const char input[] = "\244\263\244\363\244\313\244\301\244\317"; /* こんにちは in EUC-JP */
-      static const uint16_t expected[] = /* こんにちは */
+      /* Test conversions from autodetect_jp to UTF-16.  */
+      for (h = 0; h < SIZEOF (handlers); h++)
         {
-          0x3053, 0x3093, 0x306B, 0x3061, 0x306F, 0
-        };
-      uint16_t *result = u16_strconv_from_encoding (input, "autodetect_jp", handler);
-      ASSERT (result != NULL);
-      ASSERT (u16_strcmp (result, expected) == 0);
-      free (result);
-    }
-  for (h = 0; h < SIZEOF (handlers); h++)
-    {
-      enum iconv_ilseq_handler handler = handlers[h];
-      static const char input[] = "\202\261\202\361\202\311\202\277\202\315"; /* こんにちは in Shift_JIS */
-      static const uint16_t expected[] = /* こんにちは */
+          enum iconv_ilseq_handler handler = handlers[h];
+          static const char input[] = "\244\263\244\363\244\313\244\301\244\317"; /* こんにちは in EUC-JP */
+          static const uint16_t expected[] = /* こんにちは */
+            {
+              0x3053, 0x3093, 0x306B, 0x3061, 0x306F, 0
+            };
+          uint16_t *result = u16_strconv_from_encoding (input, "autodetect_jp", handler);
+          ASSERT (result != NULL);
+          ASSERT (u16_strcmp (result, expected) == 0);
+          free (result);
+        }
+      for (h = 0; h < SIZEOF (handlers); h++)
         {
-          0x3053, 0x3093, 0x306B, 0x3061, 0x306F, 0
-        };
-      uint16_t *result = u16_strconv_from_encoding (input, "autodetect_jp", handler);
-      ASSERT (result != NULL);
-      ASSERT (u16_strcmp (result, expected) == 0);
-      free (result);
-    }
-  for (h = 0; h < SIZEOF (handlers); h++)
-    {
-      enum iconv_ilseq_handler handler = handlers[h];
-      static const char input[] = "\033$B$3$s$K$A$O\033(B"; /* こんにちは in ISO-2022-JP-2 */
-      static const uint16_t expected[] = /* こんにちは */
+          enum iconv_ilseq_handler handler = handlers[h];
+          static const char input[] = "\202\261\202\361\202\311\202\277\202\315"; /* こんにちは in Shift_JIS */
+          static const uint16_t expected[] = /* こんにちは */
+            {
+              0x3053, 0x3093, 0x306B, 0x3061, 0x306F, 0
+            };
+          uint16_t *result = u16_strconv_from_encoding (input, "autodetect_jp", handler);
+          ASSERT (result != NULL);
+          ASSERT (u16_strcmp (result, expected) == 0);
+          free (result);
+        }
+      for (h = 0; h < SIZEOF (handlers); h++)
         {
-          0x3053, 0x3093, 0x306B, 0x3061, 0x306F, 0
-        };
-      uint16_t *result = u16_strconv_from_encoding (input, "autodetect_jp", handler);
-      ASSERT (result != NULL);
-      ASSERT (u16_strcmp (result, expected) == 0);
-      free (result);
+          enum iconv_ilseq_handler handler = handlers[h];
+          static const char input[] = "\033$B$3$s$K$A$O\033(B"; /* こんにちは in ISO-2022-JP-2 */
+          static const uint16_t expected[] = /* こんにちは */
+            {
+              0x3053, 0x3093, 0x306B, 0x3061, 0x306F, 0
+            };
+          uint16_t *result = u16_strconv_from_encoding (input, "autodetect_jp", handler);
+          ASSERT (result != NULL);
+          ASSERT (u16_strcmp (result, expected) == 0);
+          free (result);
+        }
     }
 # endif
 
diff --git a/tests/uniconv/test-u16-strconv-to-enc.c b/tests/uniconv/test-u16-strconv-to-enc.c
index 4a920e15..cf771ff7 100644
--- a/tests/uniconv/test-u16-strconv-to-enc.c
+++ b/tests/uniconv/test-u16-strconv-to-enc.c
@@ -1,5 +1,5 @@
 /* Test of conversion from UTF-16 to legacy encodings.
-   Copyright (C) 2007-2017 Free Software Foundation, Inc.
+   Copyright (C) 2007-2018 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
diff --git a/tests/uniconv/test-u32-conv-from-enc.c b/tests/uniconv/test-u32-conv-from-enc.c
index efbb6b70..91dda647 100644
--- a/tests/uniconv/test-u32-conv-from-enc.c
+++ b/tests/uniconv/test-u32-conv-from-enc.c
@@ -1,5 +1,5 @@
 /* Test of conversion to UTF-32 from legacy encodings.
-   Copyright (C) 2007-2017 Free Software Foundation, Inc.
+   Copyright (C) 2007-2018 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
 
 #include "unistr.h"
 #include "macros.h"
+extern int iconv_supports_encoding (const char *encoding);
 
 /* Magic number for detecting bounds violations.  */
 #define MAGIC 0x1983EFF1
@@ -117,98 +118,101 @@ main ()
 
   /* autodetect_jp is only supported when iconv() support ISO-2022-JP-2.  */
 # if defined _LIBICONV_VERSION || !(defined _AIX || defined __sgi || defined __hpux || defined __osf__ || defined __sun)
-  /* Test conversions from autodetect_jp to UTF-16.  */
-  for (h = 0; h < SIZEOF (handlers); h++)
+  if (iconv_supports_encoding ("ISO-2022-JP-2"))
     {
-      enum iconv_ilseq_handler handler = handlers[h];
-      static const char input[] = "\244\263\244\363\244\313\244\301\244\317"; /* こんにちは in EUC-JP */
-      static const uint32_t expected[] = /* こんにちは */
-        {
-          0x3053, 0x3093, 0x306B, 0x3061, 0x306F
-        };
-      for (o = 0; o < 2; o++)
+      /* Test conversions from autodetect_jp to UTF-16.  */
+      for (h = 0; h < SIZEOF (handlers); h++)
         {
-          size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
-          size_t length;
-          uint32_t *result = u32_conv_from_encoding ("autodetect_jp", handler,
-                                                     input, strlen (input),
-                                                     offsets,
-                                                     NULL, &length);
-          ASSERT (result != NULL);
-          ASSERT (length == SIZEOF (expected));
-          ASSERT (u32_cmp (result, expected, SIZEOF (expected)) == 0);
-          if (o)
+          enum iconv_ilseq_handler handler = handlers[h];
+          static const char input[] = "\244\263\244\363\244\313\244\301\244\317"; /* こんにちは in EUC-JP */
+          static const uint32_t expected[] = /* こんにちは */
             {
-              for (i = 0; i < 10; i++)
-                ASSERT (offsets[i] == ((i % 2) == 0 ? i / 2 : (size_t)(-1)));
-              ASSERT (offsets[10] == MAGIC);
-              free (offsets);
+              0x3053, 0x3093, 0x306B, 0x3061, 0x306F
+            };
+          for (o = 0; o < 2; o++)
+            {
+              size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
+              size_t length;
+              uint32_t *result = u32_conv_from_encoding ("autodetect_jp", handler,
+                                                         input, strlen (input),
+                                                         offsets,
+                                                         NULL, &length);
+              ASSERT (result != NULL);
+              ASSERT (length == SIZEOF (expected));
+              ASSERT (u32_cmp (result, expected, SIZEOF (expected)) == 0);
+              if (o)
+                {
+                  for (i = 0; i < 10; i++)
+                    ASSERT (offsets[i] == ((i % 2) == 0 ? i / 2 : (size_t)(-1)));
+                  ASSERT (offsets[10] == MAGIC);
+                  free (offsets);
+                }
+              free (result);
             }
-          free (result);
         }
-    }
-  for (h = 0; h < SIZEOF (handlers); h++)
-    {
-      enum iconv_ilseq_handler handler = handlers[h];
-      static const char input[] = "\202\261\202\361\202\311\202\277\202\315"; /* こんにちは in Shift_JIS */
-      static const uint32_t expected[] = /* こんにちは */
-        {
-          0x3053, 0x3093, 0x306B, 0x3061, 0x306F
-        };
-      for (o = 0; o < 2; o++)
+      for (h = 0; h < SIZEOF (handlers); h++)
         {
-          size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
-          size_t length;
-          uint32_t *result = u32_conv_from_encoding ("autodetect_jp", handler,
-                                                     input, strlen (input),
-                                                     offsets,
-                                                     NULL, &length);
-          ASSERT (result != NULL);
-          ASSERT (length == SIZEOF (expected));
-          ASSERT (u32_cmp (result, expected, SIZEOF (expected)) == 0);
-          if (o)
+          enum iconv_ilseq_handler handler = handlers[h];
+          static const char input[] = "\202\261\202\361\202\311\202\277\202\315"; /* こんにちは in Shift_JIS */
+          static const uint32_t expected[] = /* こんにちは */
             {
-              for (i = 0; i < 10; i++)
-                ASSERT (offsets[i] == ((i % 2) == 0 ? i / 2 : (size_t)(-1)));
-              ASSERT (offsets[10] == MAGIC);
-              free (offsets);
+              0x3053, 0x3093, 0x306B, 0x3061, 0x306F
+            };
+          for (o = 0; o < 2; o++)
+            {
+              size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
+              size_t length;
+              uint32_t *result = u32_conv_from_encoding ("autodetect_jp", handler,
+                                                         input, strlen (input),
+                                                         offsets,
+                                                         NULL, &length);
+              ASSERT (result != NULL);
+              ASSERT (length == SIZEOF (expected));
+              ASSERT (u32_cmp (result, expected, SIZEOF (expected)) == 0);
+              if (o)
+                {
+                  for (i = 0; i < 10; i++)
+                    ASSERT (offsets[i] == ((i % 2) == 0 ? i / 2 : (size_t)(-1)));
+                  ASSERT (offsets[10] == MAGIC);
+                  free (offsets);
+                }
+              free (result);
             }
-          free (result);
         }
-    }
-  for (h = 0; h < SIZEOF (handlers); h++)
-    {
-      enum iconv_ilseq_handler handler = handlers[h];
-      static const char input[] = "\033$B$3$s$K$A$O\033(B"; /* こんにちは in ISO-2022-JP-2 */
-      static const uint32_t expected[] = /* こんにちは */
-        {
-          0x3053, 0x3093, 0x306B, 0x3061, 0x306F
-        };
-      for (o = 0; o < 2; o++)
+      for (h = 0; h < SIZEOF (handlers); h++)
         {
-          size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
-          size_t length;
-          uint32_t *result = u32_conv_from_encoding ("autodetect_jp", handler,
-                                                     input, strlen (input),
-                                                     offsets,
-                                                     NULL, &length);
-          ASSERT (result != NULL);
-          ASSERT (length == SIZEOF (expected));
-          ASSERT (u32_cmp (result, expected, SIZEOF (expected)) == 0);
-          if (o)
+          enum iconv_ilseq_handler handler = handlers[h];
+          static const char input[] = "\033$B$3$s$K$A$O\033(B"; /* こんにちは in ISO-2022-JP-2 */
+          static const uint32_t expected[] = /* こんにちは */
             {
-              for (i = 0; i < 16; i++)
-                ASSERT (offsets[i] == (i == 0 ? 0 :
-                                       i == 5 ? 1 :
-                                       i == 7 ? 2 :
-                                       i == 9 ? 3 :
-                                       i == 11 ? 4 :
-                                       i == 13 ? 5 :
-                                       (size_t)(-1)));
-              ASSERT (offsets[16] == MAGIC);
-              free (offsets);
+              0x3053, 0x3093, 0x306B, 0x3061, 0x306F
+            };
+          for (o = 0; o < 2; o++)
+            {
+              size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
+              size_t length;
+              uint32_t *result = u32_conv_from_encoding ("autodetect_jp", handler,
+                                                         input, strlen (input),
+                                                         offsets,
+                                                         NULL, &length);
+              ASSERT (result != NULL);
+              ASSERT (length == SIZEOF (expected));
+              ASSERT (u32_cmp (result, expected, SIZEOF (expected)) == 0);
+              if (o)
+                {
+                  for (i = 0; i < 16; i++)
+                    ASSERT (offsets[i] == (i == 0 ? 0 :
+                                           i == 5 ? 1 :
+                                           i == 7 ? 2 :
+                                           i == 9 ? 3 :
+                                           i == 11 ? 4 :
+                                           i == 13 ? 5 :
+                                           (size_t)(-1)));
+                  ASSERT (offsets[16] == MAGIC);
+                  free (offsets);
+                }
+              free (result);
             }
-          free (result);
         }
     }
 # endif
diff --git a/tests/uniconv/test-u32-conv-to-enc.c b/tests/uniconv/test-u32-conv-to-enc.c
index d4f9f6ec..f35118fc 100644
--- a/tests/uniconv/test-u32-conv-to-enc.c
+++ b/tests/uniconv/test-u32-conv-to-enc.c
@@ -1,5 +1,5 @@
 /* Test of conversion from UTF-32 to legacy encodings.
-   Copyright (C) 2007-2017 Free Software Foundation, Inc.
+   Copyright (C) 2007-2018 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
diff --git a/tests/uniconv/test-u32-strconv-from-enc.c b/tests/uniconv/test-u32-strconv-from-enc.c
index 21008697..94166105 100644
--- a/tests/uniconv/test-u32-strconv-from-enc.c
+++ b/tests/uniconv/test-u32-strconv-from-enc.c
@@ -1,5 +1,5 @@
 /* Test of conversion to UTF-32 from legacy encodings.
-   Copyright (C) 2007-2017 Free Software Foundation, Inc.
+   Copyright (C) 2007-2018 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 #include "unistr.h"
 #include "macros.h"
+extern int iconv_supports_encoding (const char *encoding);
 
 int
 main ()
@@ -71,45 +72,48 @@ main ()
 
   /* autodetect_jp is only supported when iconv() support ISO-2022-JP-2.  */
 # if defined _LIBICONV_VERSION || !(defined _AIX || defined __sgi || defined __hpux || defined __osf__ || defined __sun)
-  /* Test conversions from autodetect_jp to UTF-16.  */
-  for (h = 0; h < SIZEOF (handlers); h++)
+  if (iconv_supports_encoding ("ISO-2022-JP-2"))
     {
-      enum iconv_ilseq_handler handler = handlers[h];
-      static const char input[] = "\244\263\244\363\244\313\244\301\244\317"; /* こんにちは in EUC-JP */
-      static const uint32_t expected[] = /* こんにちは */
+      /* Test conversions from autodetect_jp to UTF-16.  */
+      for (h = 0; h < SIZEOF (handlers); h++)
         {
-          0x3053, 0x3093, 0x306B, 0x3061, 0x306F, 0
-        };
-      uint32_t *result = u32_strconv_from_encoding (input, "autodetect_jp", handler);
-      ASSERT (result != NULL);
-      ASSERT (u32_strcmp (result, expected) == 0);
-      free (result);
-    }
-  for (h = 0; h < SIZEOF (handlers); h++)
-    {
-      enum iconv_ilseq_handler handler = handlers[h];
-      static const char input[] = "\202\261\202\361\202\311\202\277\202\315"; /* こんにちは in Shift_JIS */
-      static const uint32_t expected[] = /* こんにちは */
+          enum iconv_ilseq_handler handler = handlers[h];
+          static const char input[] = "\244\263\244\363\244\313\244\301\244\317"; /* こんにちは in EUC-JP */
+          static const uint32_t expected[] = /* こんにちは */
+            {
+              0x3053, 0x3093, 0x306B, 0x3061, 0x306F, 0
+            };
+          uint32_t *result = u32_strconv_from_encoding (input, "autodetect_jp", handler);
+          ASSERT (result != NULL);
+          ASSERT (u32_strcmp (result, expected) == 0);
+          free (result);
+        }
+      for (h = 0; h < SIZEOF (handlers); h++)
         {
-          0x3053, 0x3093, 0x306B, 0x3061, 0x306F, 0
-        };
-      uint32_t *result = u32_strconv_from_encoding (input, "autodetect_jp", handler);
-      ASSERT (result != NULL);
-      ASSERT (u32_strcmp (result, expected) == 0);
-      free (result);
-    }
-  for (h = 0; h < SIZEOF (handlers); h++)
-    {
-      enum iconv_ilseq_handler handler = handlers[h];
-      static const char input[] = "\033$B$3$s$K$A$O\033(B"; /* こんにちは in ISO-2022-JP-2 */
-      static const uint32_t expected[] = /* こんにちは */
+          enum iconv_ilseq_handler handler = handlers[h];
+          static const char input[] = "\202\261\202\361\202\311\202\277\202\315"; /* こんにちは in Shift_JIS */
+          static const uint32_t expected[] = /* こんにちは */
+            {
+              0x3053, 0x3093, 0x306B, 0x3061, 0x306F, 0
+            };
+          uint32_t *result = u32_strconv_from_encoding (input, "autodetect_jp", handler);
+          ASSERT (result != NULL);
+          ASSERT (u32_strcmp (result, expected) == 0);
+          free (result);
+        }
+      for (h = 0; h < SIZEOF (handlers); h++)
         {
-          0x3053, 0x3093, 0x306B, 0x3061, 0x306F, 0
-        };
-      uint32_t *result = u32_strconv_from_encoding (input, "autodetect_jp", handler);
-      ASSERT (result != NULL);
-      ASSERT (u32_strcmp (result, expected) == 0);
-      free (result);
+          enum iconv_ilseq_handler handler = handlers[h];
+          static const char input[] = "\033$B$3$s$K$A$O\033(B"; /* こんにちは in ISO-2022-JP-2 */
+          static const uint32_t expected[] = /* こんにちは */
+            {
+              0x3053, 0x3093, 0x306B, 0x3061, 0x306F, 0
+            };
+          uint32_t *result = u32_strconv_from_encoding (input, "autodetect_jp", handler);
+          ASSERT (result != NULL);
+          ASSERT (u32_strcmp (result, expected) == 0);
+          free (result);
+        }
     }
 # endif
 
diff --git a/tests/uniconv/test-u32-strconv-to-enc.c b/tests/uniconv/test-u32-strconv-to-enc.c
index e50728fe..e21aaa7c 100644
--- a/tests/uniconv/test-u32-strconv-to-enc.c
+++ b/tests/uniconv/test-u32-strconv-to-enc.c
@@ -1,5 +1,5 @@
 /* Test of conversion from UTF-32 to legacy encodings.
-   Copyright (C) 2007-2017 Free Software Foundation, Inc.
+   Copyright (C) 2007-2018 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
diff --git a/tests/uniconv/test-u8-conv-from-enc.c b/tests/uniconv/test-u8-conv-from-enc.c
index 3adedc6c..6e7e1f28 100644
--- a/tests/uniconv/test-u8-conv-from-enc.c
+++ b/tests/uniconv/test-u8-conv-from-enc.c
@@ -1,5 +1,5 @@
 /* Test of conversion to UTF-8 from legacy encodings.
-   Copyright (C) 2007-2017 Free Software Foundation, Inc.
+   Copyright (C) 2007-2018 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
 
 #include "unistr.h"
 #include "macros.h"
+extern int iconv_supports_encoding (const char *encoding);
 
 /* Magic number for detecting bounds violations.  */
 #define MAGIC 0x1983EFF1
@@ -112,89 +113,92 @@ main ()
 
   /* autodetect_jp is only supported when iconv() support ISO-2022-JP-2.  */
 # if defined _LIBICONV_VERSION || !(defined _AIX || defined __sgi || defined __hpux || defined __osf__ || defined __sun)
-  /* Test conversions from autodetect_jp to UTF-8.  */
-  for (h = 0; h < SIZEOF (handlers); h++)
+  if (iconv_supports_encoding ("ISO-2022-JP-2"))
     {
-      enum iconv_ilseq_handler handler = handlers[h];
-      static const char input[] = "\244\263\244\363\244\313\244\301\244\317"; /* こんにちは in EUC-JP */
-      static const uint8_t expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
-      for (o = 0; o < 2; o++)
+      /* Test conversions from autodetect_jp to UTF-8.  */
+      for (h = 0; h < SIZEOF (handlers); h++)
         {
-          size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
-          size_t length;
-          uint8_t *result = u8_conv_from_encoding ("autodetect_jp", handler,
-                                                   input, strlen (input),
-                                                   offsets,
-                                                   NULL, &length);
-          ASSERT (result != NULL);
-          ASSERT (length == u8_strlen (expected));
-          ASSERT (u8_cmp (result, expected, u8_strlen (expected)) == 0);
-          if (o)
+          enum iconv_ilseq_handler handler = handlers[h];
+          static const char input[] = "\244\263\244\363\244\313\244\301\244\317"; /* こんにちは in EUC-JP */
+          static const uint8_t expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
+          for (o = 0; o < 2; o++)
             {
-              for (i = 0; i < 10; i++)
-                ASSERT (offsets[i] == ((i % 2) == 0 ? (i / 2) * 3 : (size_t)(-1)));
-              ASSERT (offsets[10] == MAGIC);
-              free (offsets);
+              size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
+              size_t length;
+              uint8_t *result = u8_conv_from_encoding ("autodetect_jp", handler,
+                                                       input, strlen (input),
+                                                       offsets,
+                                                       NULL, &length);
+              ASSERT (result != NULL);
+              ASSERT (length == u8_strlen (expected));
+              ASSERT (u8_cmp (result, expected, u8_strlen (expected)) == 0);
+              if (o)
+                {
+                  for (i = 0; i < 10; i++)
+                    ASSERT (offsets[i] == ((i % 2) == 0 ? (i / 2) * 3 : (size_t)(-1)));
+                  ASSERT (offsets[10] == MAGIC);
+                  free (offsets);
+                }
+              free (result);
             }
-          free (result);
         }
-    }
-  for (h = 0; h < SIZEOF (handlers); h++)
-    {
-      enum iconv_ilseq_handler handler = handlers[h];
-      static const char input[] = "\202\261\202\361\202\311\202\277\202\315"; /* こんにちは in Shift_JIS */
-      static const uint8_t expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
-      for (o = 0; o < 2; o++)
+      for (h = 0; h < SIZEOF (handlers); h++)
         {
-          size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
-          size_t length;
-          uint8_t *result = u8_conv_from_encoding ("autodetect_jp", handler,
-                                                   input, strlen (input),
-                                                   offsets,
-                                                   NULL, &length);
-          ASSERT (result != NULL);
-          ASSERT (length == u8_strlen (expected));
-          ASSERT (u8_cmp (result, expected, u8_strlen (expected)) == 0);
-          if (o)
+          enum iconv_ilseq_handler handler = handlers[h];
+          static const char input[] = "\202\261\202\361\202\311\202\277\202\315"; /* こんにちは in Shift_JIS */
+          static const uint8_t expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
+          for (o = 0; o < 2; o++)
             {
-              for (i = 0; i < 10; i++)
-                ASSERT (offsets[i] == ((i % 2) == 0 ? (i / 2) * 3 : (size_t)(-1)));
-              ASSERT (offsets[10] == MAGIC);
-              free (offsets);
+              size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
+              size_t length;
+              uint8_t *result = u8_conv_from_encoding ("autodetect_jp", handler,
+                                                       input, strlen (input),
+                                                       offsets,
+                                                       NULL, &length);
+              ASSERT (result != NULL);
+              ASSERT (length == u8_strlen (expected));
+              ASSERT (u8_cmp (result, expected, u8_strlen (expected)) == 0);
+              if (o)
+                {
+                  for (i = 0; i < 10; i++)
+                    ASSERT (offsets[i] == ((i % 2) == 0 ? (i / 2) * 3 : (size_t)(-1)));
+                  ASSERT (offsets[10] == MAGIC);
+                  free (offsets);
+                }
+              free (result);
             }
-          free (result);
         }
-    }
-  for (h = 0; h < SIZEOF (handlers); h++)
-    {
-      enum iconv_ilseq_handler handler = handlers[h];
-      static const char input[] = "\033$B$3$s$K$A$O\033(B"; /* こんにちは in ISO-2022-JP-2 */
-      static const uint8_t expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
-      for (o = 0; o < 2; o++)
+      for (h = 0; h < SIZEOF (handlers); h++)
         {
-          size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
-          size_t length;
-          uint8_t *result = u8_conv_from_encoding ("autodetect_jp", handler,
-                                                   input, strlen (input),
-                                                   offsets,
-                                                   NULL, &length);
-          ASSERT (result != NULL);
-          ASSERT (length == u8_strlen (expected));
-          ASSERT (u8_cmp (result, expected, u8_strlen (expected)) == 0);
-          if (o)
+          enum iconv_ilseq_handler handler = handlers[h];
+          static const char input[] = "\033$B$3$s$K$A$O\033(B"; /* こんにちは in ISO-2022-JP-2 */
+          static const uint8_t expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
+          for (o = 0; o < 2; o++)
             {
-              for (i = 0; i < 16; i++)
-                ASSERT (offsets[i] == (i == 0 ? 0 :
-                                       i == 5 ? 3 :
-                                       i == 7 ? 6 :
-                                       i == 9 ? 9 :
-                                       i == 11 ? 12 :
-                                       i == 13 ? 15 :
-                                       (size_t)(-1)));
-              ASSERT (offsets[16] == MAGIC);
-              free (offsets);
+              size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
+              size_t length;
+              uint8_t *result = u8_conv_from_encoding ("autodetect_jp", handler,
+                                                       input, strlen (input),
+                                                       offsets,
+                                                       NULL, &length);
+              ASSERT (result != NULL);
+              ASSERT (length == u8_strlen (expected));
+              ASSERT (u8_cmp (result, expected, u8_strlen (expected)) == 0);
+              if (o)
+                {
+                  for (i = 0; i < 16; i++)
+                    ASSERT (offsets[i] == (i == 0 ? 0 :
+                                           i == 5 ? 3 :
+                                           i == 7 ? 6 :
+                                           i == 9 ? 9 :
+                                           i == 11 ? 12 :
+                                           i == 13 ? 15 :
+                                           (size_t)(-1)));
+                  ASSERT (offsets[16] == MAGIC);
+                  free (offsets);
+                }
+              free (result);
             }
-          free (result);
         }
     }
 # endif
diff --git a/tests/uniconv/test-u8-conv-to-enc.c b/tests/uniconv/test-u8-conv-to-enc.c
index 9af9f4c0..fab1a48d 100644
--- a/tests/uniconv/test-u8-conv-to-enc.c
+++ b/tests/uniconv/test-u8-conv-to-enc.c
@@ -1,5 +1,5 @@
 /* Test of conversion from UTF-8 to legacy encodings.
-   Copyright (C) 2007-2017 Free Software Foundation, Inc.
+   Copyright (C) 2007-2018 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
diff --git a/tests/uniconv/test-u8-strconv-from-enc.c b/tests/uniconv/test-u8-strconv-from-enc.c
index 46060726..3d032dbd 100644
--- a/tests/uniconv/test-u8-strconv-from-enc.c
+++ b/tests/uniconv/test-u8-strconv-from-enc.c
@@ -1,5 +1,5 @@
 /* Test of conversion to UTF-8 from legacy encodings.
-   Copyright (C) 2007-2017 Free Software Foundation, Inc.
+   Copyright (C) 2007-2018 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 #include "unistr.h"
 #include "macros.h"
+extern int iconv_supports_encoding (const char *encoding);
 
 int
 main ()
@@ -62,36 +63,39 @@ main ()
 
   /* autodetect_jp is only supported when iconv() support ISO-2022-JP-2.  */
 # if defined _LIBICONV_VERSION || !(defined _AIX || defined __sgi || defined __hpux || defined __osf__ || defined __sun)
-  /* Test conversions from autodetect_jp to UTF-8.  */
-  for (h = 0; h < SIZEOF (handlers); h++)
-    {
-      enum iconv_ilseq_handler handler = handlers[h];
-      static const char input[] = "\244\263\244\363\244\313\244\301\244\317"; /* こんにちは in EUC-JP */
-      static const uint8_t expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
-      uint8_t *result = u8_strconv_from_encoding (input, "autodetect_jp", handler);
-      ASSERT (result != NULL);
-      ASSERT (u8_strcmp (result, expected) == 0);
-      free (result);
-    }
-  for (h = 0; h < SIZEOF (handlers); h++)
+  if (iconv_supports_encoding ("ISO-2022-JP-2"))
     {
-      enum iconv_ilseq_handler handler = handlers[h];
-      static const char input[] = "\202\261\202\361\202\311\202\277\202\315"; /* こんにちは in Shift_JIS */
-      static const uint8_t expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
-      uint8_t *result = u8_strconv_from_encoding (input, "autodetect_jp", handler);
-      ASSERT (result != NULL);
-      ASSERT (u8_strcmp (result, expected) == 0);
-      free (result);
-    }
-  for (h = 0; h < SIZEOF (handlers); h++)
-    {
-      enum iconv_ilseq_handler handler = handlers[h];
-      static const char input[] = "\033$B$3$s$K$A$O\033(B"; /* こんにちは in ISO-2022-JP-2 */
-      static const uint8_t expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
-      uint8_t *result = u8_strconv_from_encoding (input, "autodetect_jp", handler);
-      ASSERT (result != NULL);
-      ASSERT (u8_strcmp (result, expected) == 0);
-      free (result);
+      /* Test conversions from autodetect_jp to UTF-8.  */
+      for (h = 0; h < SIZEOF (handlers); h++)
+        {
+          enum iconv_ilseq_handler handler = handlers[h];
+          static const char input[] = "\244\263\244\363\244\313\244\301\244\317"; /* こんにちは in EUC-JP */
+          static const uint8_t expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
+          uint8_t *result = u8_strconv_from_encoding (input, "autodetect_jp", handler);
+          ASSERT (result != NULL);
+          ASSERT (u8_strcmp (result, expected) == 0);
+          free (result);
+        }
+      for (h = 0; h < SIZEOF (handlers); h++)
+        {
+          enum iconv_ilseq_handler handler = handlers[h];
+          static const char input[] = "\202\261\202\361\202\311\202\277\202\315"; /* こんにちは in Shift_JIS */
+          static const uint8_t expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
+          uint8_t *result = u8_strconv_from_encoding (input, "autodetect_jp", handler);
+          ASSERT (result != NULL);
+          ASSERT (u8_strcmp (result, expected) == 0);
+          free (result);
+        }
+      for (h = 0; h < SIZEOF (handlers); h++)
+        {
+          enum iconv_ilseq_handler handler = handlers[h];
+          static const char input[] = "\033$B$3$s$K$A$O\033(B"; /* こんにちは in ISO-2022-JP-2 */
+          static const uint8_t expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
+          uint8_t *result = u8_strconv_from_encoding (input, "autodetect_jp", handler);
+          ASSERT (result != NULL);
+          ASSERT (u8_strcmp (result, expected) == 0);
+          free (result);
+        }
     }
 # endif
 
diff --git a/tests/uniconv/test-u8-strconv-to-enc.c b/tests/uniconv/test-u8-strconv-to-enc.c
index 59050b9b..00c0f59e 100644
--- a/tests/uniconv/test-u8-strconv-to-enc.c
+++ b/tests/uniconv/test-u8-strconv-to-enc.c
@@ -1,5 +1,5 @@
 /* Test of conversion from UTF-8 to legacy encodings.
-   Copyright (C) 2007-2017 Free Software Foundation, Inc.
+   Copyright (C) 2007-2018 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-- 
cgit v1.2.3