about summary refs log tree commit diff
path: root/iconvdata
diff options
context:
space:
mode:
Diffstat (limited to 'iconvdata')
-rw-r--r--iconvdata/Makefile6
-rw-r--r--iconvdata/ibm1364.c3
-rw-r--r--iconvdata/ibm930.c3
-rw-r--r--iconvdata/ibm933.c3
-rw-r--r--iconvdata/ibm935.c3
-rw-r--r--iconvdata/ibm937.c3
-rw-r--r--iconvdata/ibm939.c3
-rw-r--r--iconvdata/iso-2022-cn-ext.c8
-rw-r--r--iconvdata/iso-2022-cn.c8
-rw-r--r--iconvdata/iso-2022-jp-3.c9
-rw-r--r--iconvdata/iso-2022-jp.c69
-rw-r--r--iconvdata/iso-2022-kr.c4
-rw-r--r--iconvdata/tst-iconv7.c61
13 files changed, 141 insertions, 42 deletions
diff --git a/iconvdata/Makefile b/iconvdata/Makefile
index 4ac5de30e5..1a46a64ccd 100644
--- a/iconvdata/Makefile
+++ b/iconvdata/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1997-2004,2005,2006,2007 Free Software Foundation, Inc.
+# Copyright (C) 1997-2004,2005,2006,2007,2008 Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 
 # The GNU C Library is free software; you can redistribute it and/or
@@ -67,7 +67,7 @@ include ../Makeconfig
 
 ifeq (yes,$(build-shared))
 tests = bug-iconv1 bug-iconv2 tst-loading tst-e2big tst-iconv4 bug-iconv4 \
-	tst-iconv6 bug-iconv5 bug-iconv6
+	tst-iconv6 bug-iconv5 bug-iconv6 tst-iconv7
 ifeq ($(have-thread-library),yes)
 tests += bug-iconv3
 endif
@@ -365,6 +365,8 @@ $(objpfx)tst-loading.out: $(objpfx)gconv-modules \
 			  $(addprefix $(objpfx),$(modules.so))
 $(objpfx)tst-iconv4.out: $(objpfx)gconv-modules \
 			 $(addprefix $(objpfx),$(modules.so))
+$(objpfx)tst-iconv7.out: $(objpfx)gconv-modules \
+			 $(addprefix $(objpfx),$(modules.so))
 
 $(objpfx)iconv-test.out: run-iconv-test.sh $(objpfx)gconv-modules \
 			 $(addprefix $(objpfx),$(modules.so)) \
diff --git a/iconvdata/ibm1364.c b/iconvdata/ibm1364.c
index 1d46cf6dfb..6881341c43 100644
--- a/iconvdata/ibm1364.c
+++ b/iconvdata/ibm1364.c
@@ -1,5 +1,5 @@
 /* Conversion from and to IBM1364.
-   Copyright (C) 2005 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2008 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Masahide Washizawa <washi@jp.ibm.com>, 2005.
 
@@ -387,6 +387,7 @@ enum
 #define LOOP_NEED_FLAGS
 #define EXTRA_LOOP_DECLS	, int *curcsp
 #define INIT_PARAMS		int curcs = *curcsp & ~7
+#define REINIT_PARAMS		curcs = *curcsp & ~7
 #define UPDATE_PARAMS		*curcsp = curcs
 #include <iconv/loop.c>
 
diff --git a/iconvdata/ibm930.c b/iconvdata/ibm930.c
index f5e2cb1dd3..67d07918fb 100644
--- a/iconvdata/ibm930.c
+++ b/iconvdata/ibm930.c
@@ -1,5 +1,5 @@
 /* Conversion from and to IBM930.
-   Copyright (C) 2000-2002 Free Software Foundation, Inc.
+   Copyright (C) 2000-2002, 2008 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Masahide Washizawa <washi@yamato.ibm.co.jp>, 2000.
 
@@ -277,6 +277,7 @@ enum
 #define LOOP_NEED_FLAGS
 #define EXTRA_LOOP_DECLS	, int *curcsp
 #define INIT_PARAMS		int curcs = *curcsp & ~7
+#define REINIT_PARAMS		curcs = *curcsp & ~7
 #define UPDATE_PARAMS		*curcsp = curcs
 #include <iconv/loop.c>
 
diff --git a/iconvdata/ibm933.c b/iconvdata/ibm933.c
index 389028ebc4..db822eaab1 100644
--- a/iconvdata/ibm933.c
+++ b/iconvdata/ibm933.c
@@ -1,5 +1,5 @@
 /* Conversion from and to IBM933.
-   Copyright (C) 2000-2002 Free Software Foundation, Inc.
+   Copyright (C) 2000-2002, 2008 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Masahide Washizawa <washi@yamato.ibm.co.jp>, 2000.
 
@@ -272,6 +272,7 @@ enum
 #define LOOP_NEED_FLAGS
 #define EXTRA_LOOP_DECLS	, int *curcsp
 #define INIT_PARAMS		int curcs = *curcsp & ~7
+#define REINIT_PARAMS		curcs = *curcsp & ~7
 #define UPDATE_PARAMS		*curcsp = curcs
 #include <iconv/loop.c>
 
diff --git a/iconvdata/ibm935.c b/iconvdata/ibm935.c
index 647573945f..5b9af9ae82 100644
--- a/iconvdata/ibm935.c
+++ b/iconvdata/ibm935.c
@@ -1,5 +1,5 @@
 /* Conversion from and to IBM935
-   Copyright (C) 2000-2002 Free Software Foundation, Inc.
+   Copyright (C) 2000-2002, 2008 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Masahide Washizawa <washi@yamato.ibm.co.jp>, 2000.
 
@@ -272,6 +272,7 @@ enum
 #define LOOP_NEED_FLAGS
 #define EXTRA_LOOP_DECLS	, int *curcsp
 #define INIT_PARAMS		int curcs = *curcsp & ~7
+#define REINIT_PARAMS		curcs = *curcsp & ~7
 #define UPDATE_PARAMS		*curcsp = curcs
 #include <iconv/loop.c>
 
diff --git a/iconvdata/ibm937.c b/iconvdata/ibm937.c
index 2d46115942..52f7aeaffc 100644
--- a/iconvdata/ibm937.c
+++ b/iconvdata/ibm937.c
@@ -1,5 +1,5 @@
 /* Conversion from and to IBM937.
-   Copyright (C) 2000-2002 Free Software Foundation, Inc.
+   Copyright (C) 2000-2002, 2008 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Masahide Washizawa <washi@yamato.ibm.co.jp>, 2000.
 
@@ -272,6 +272,7 @@ enum
 #define LOOP_NEED_FLAGS
 #define EXTRA_LOOP_DECLS	, int *curcsp
 #define INIT_PARAMS		int curcs = *curcsp & ~7
+#define REINIT_PARAMS		curcs = *curcsp & ~7
 #define UPDATE_PARAMS		*curcsp = curcs
 #include <iconv/loop.c>
 
diff --git a/iconvdata/ibm939.c b/iconvdata/ibm939.c
index 50b083f492..9f3a3632bf 100644
--- a/iconvdata/ibm939.c
+++ b/iconvdata/ibm939.c
@@ -1,5 +1,5 @@
 /* Conversion to and from IBM939.
-   Copyright (C) 2000-2002, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2000-2002, 2005, 2008 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Masahide Washizawa <washi@yamato.ibm.co.jp>, 2000.
 
@@ -277,6 +277,7 @@ enum
 #define LOOP_NEED_FLAGS
 #define EXTRA_LOOP_DECLS	, int *curcsp
 #define INIT_PARAMS		int curcs = *curcsp & ~7
+#define REINIT_PARAMS		curcs = *curcsp & ~7
 #define UPDATE_PARAMS		*curcsp = curcs
 #include <iconv/loop.c>
 
diff --git a/iconvdata/iso-2022-cn-ext.c b/iconvdata/iso-2022-cn-ext.c
index fd02d63592..3ffaf19881 100644
--- a/iconvdata/iso-2022-cn-ext.c
+++ b/iconvdata/iso-2022-cn-ext.c
@@ -1,5 +1,5 @@
 /* Conversion module for ISO-2022-CN-EXT.
-   Copyright (C) 2000-2002, 2004, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2000-2002, 2004, 2007, 2008 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
 
@@ -648,6 +648,12 @@ enum
 #define EXTRA_LOOP_DECLS	, int *setp
 #define INIT_PARAMS		int set = (*setp >> 3) & CURRENT_MASK; \
 				int ann = (*setp >> 3) & ~CURRENT_MASK
+#define REINIT_PARAMS		do					      \
+				  {					      \
+				    set = (*setp >> 3) & CURRENT_MASK;	      \
+				    ann = (*setp >> 3) & ~CURRENT_MASK;	      \
+				  }					      \
+				while (0)
 #define UPDATE_PARAMS		*setp = (set | ann) << 3
 #define LOOP_NEED_FLAGS
 #include <iconv/loop.c>
diff --git a/iconvdata/iso-2022-cn.c b/iconvdata/iso-2022-cn.c
index 1613cf2329..7247dd2c4e 100644
--- a/iconvdata/iso-2022-cn.c
+++ b/iconvdata/iso-2022-cn.c
@@ -1,5 +1,5 @@
 /* Conversion module for ISO-2022-CN.
-   Copyright (C) 1999, 2000-2002, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000-2002, 2007, 2008 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
 
@@ -393,6 +393,12 @@ enum
 #define EXTRA_LOOP_DECLS	, int *setp
 #define INIT_PARAMS		int set = *setp & CURRENT_SEL_MASK; \
 				int ann = *setp & CURRENT_ANN_MASK
+#define REINIT_PARAMS		do					      \
+				  {					      \
+				    set = *setp & CURRENT_SEL_MASK;	      \
+				    ann = *setp & CURRENT_ANN_MASK;	      \
+				  }					      \
+				while (0)
 #define UPDATE_PARAMS		*setp = set | ann
 #include <iconv/loop.c>
 
diff --git a/iconvdata/iso-2022-jp-3.c b/iconvdata/iso-2022-jp-3.c
index bbccc2e965..7df8ea14ea 100644
--- a/iconvdata/iso-2022-jp-3.c
+++ b/iconvdata/iso-2022-jp-3.c
@@ -1,5 +1,6 @@
 /* Conversion module for ISO-2022-JP-3.
-   Copyright (C) 1998-1999, 2000-2002, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1998-1999, 2000-2002, 2004, 2008
+   Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998,
    and Bruno Haible <bruno@clisp.org>, 2002.
@@ -759,6 +760,12 @@ static const struct
 #define EXTRA_LOOP_DECLS	, int *statep
 #define INIT_PARAMS		int set = *statep & CURRENT_SEL_MASK;	      \
 				uint32_t lasttwo = *statep >> 6
+#define REINIT_PARAMS		do					      \
+				  {					      \
+				    set = *statep & CURRENT_SEL_MASK;	      \
+				    lasttwo = *statep >> 6;		      \
+				  }					      \
+				while (0)
 #define UPDATE_PARAMS		*statep = set | (lasttwo << 6)
 #include <iconv/loop.c>
 
diff --git a/iconvdata/iso-2022-jp.c b/iconvdata/iso-2022-jp.c
index a9612e99ab..e14b79615b 100644
--- a/iconvdata/iso-2022-jp.c
+++ b/iconvdata/iso-2022-jp.c
@@ -715,8 +715,7 @@ static const cvlist_t conversion_lists[4] =
 	       list that depends on the current language tag.  */	      \
 	    cvlist_t conversion_list;					      \
 	    unsigned char buf[2];					      \
-									      \
-	    result = __GCONV_ILLEGAL_INPUT;				      \
+	    int res = __GCONV_ILLEGAL_INPUT;				      \
 									      \
 	    if (var == iso2022jp2)					      \
 	      conversion_list = conversion_lists[tag >> 8];		      \
@@ -735,7 +734,7 @@ static const cvlist_t conversion_lists[4] =
 			{						      \
 			  if (__builtin_expect (outptr + 3 > outend, 0))      \
 			    {						      \
-			      result = __GCONV_FULL_OUTPUT;		      \
+			      res = __GCONV_FULL_OUTPUT;		      \
 			      break;					      \
 			    }						      \
 			  *outptr++ = ESC;				      \
@@ -746,13 +745,13 @@ static const cvlist_t conversion_lists[4] =
 									      \
 		      if (__builtin_expect (outptr + 3 > outend, 0))	      \
 			{						      \
-			  result = __GCONV_FULL_OUTPUT;			      \
+			  res = __GCONV_FULL_OUTPUT;			      \
 			  break;					      \
 			}						      \
 		      *outptr++ = ESC;					      \
 		      *outptr++ = 'N';					      \
 		      *outptr++ = ch - 0x80;				      \
-		      result = __GCONV_OK;				      \
+		      res = __GCONV_OK;					      \
 		      break;						      \
 		    }							      \
 									      \
@@ -774,7 +773,7 @@ static const cvlist_t conversion_lists[4] =
 				  if (__builtin_expect (outptr + 3 > outend,  \
 							0))		      \
 				    {					      \
-				      result = __GCONV_FULL_OUTPUT;	      \
+				      res = __GCONV_FULL_OUTPUT;	      \
 				      break;				      \
 				    }					      \
 				  *outptr++ = ESC;			      \
@@ -785,13 +784,13 @@ static const cvlist_t conversion_lists[4] =
 									      \
 			      if (__builtin_expect (outptr + 3 > outend, 0))  \
 				{					      \
-				  result = __GCONV_FULL_OUTPUT;		      \
+				  res = __GCONV_FULL_OUTPUT;		      \
 				  break;				      \
 				}					      \
 			      *outptr++ = ESC;				      \
 			      *outptr++ = 'N';				      \
 			      *outptr++ = res;				      \
-			      result = __GCONV_OK;			      \
+			      res = __GCONV_OK;				      \
 			      break;					      \
 			    }						      \
 			}						      \
@@ -810,7 +809,7 @@ static const cvlist_t conversion_lists[4] =
 			{						      \
 			  if (__builtin_expect (outptr + 3 > outend, 0))      \
 			    {						      \
-			      result = __GCONV_FULL_OUTPUT;		      \
+			      res = __GCONV_FULL_OUTPUT;		      \
 			      break;					      \
 			    }						      \
 			  *outptr++ = ESC;				      \
@@ -821,11 +820,11 @@ static const cvlist_t conversion_lists[4] =
 									      \
 		      if (__builtin_expect (outptr + 1 > outend, 0))	      \
 			{						      \
-			  result = __GCONV_FULL_OUTPUT;			      \
+			  res = __GCONV_FULL_OUTPUT;			      \
 			  break;					      \
 			}						      \
 		      *outptr++ = buf[0];				      \
-		      result = __GCONV_OK;				      \
+		      res = __GCONV_OK;					      \
 		      break;						      \
 		    }							      \
 									      \
@@ -837,7 +836,7 @@ static const cvlist_t conversion_lists[4] =
 			{						      \
 			  if (__builtin_expect (outptr + 3 > outend, 0))      \
 			    {						      \
-			      result = __GCONV_FULL_OUTPUT;		      \
+			      res = __GCONV_FULL_OUTPUT;		      \
 			      break;					      \
 			    }						      \
 			  *outptr++ = ESC;				      \
@@ -848,12 +847,12 @@ static const cvlist_t conversion_lists[4] =
 									      \
 		      if (__builtin_expect (outptr + 2 > outend, 0))	      \
 			{						      \
-			  result = __GCONV_FULL_OUTPUT;			      \
+			  res = __GCONV_FULL_OUTPUT;			      \
 			  break;					      \
 			}						      \
 		      *outptr++ = buf[0];				      \
 		      *outptr++ = buf[1];				      \
-		      result = __GCONV_OK;				      \
+		      res = __GCONV_OK;					      \
 		      break;						      \
 		    }							      \
 									      \
@@ -869,7 +868,7 @@ static const cvlist_t conversion_lists[4] =
 			{						      \
 			  if (__builtin_expect (outptr + 4 > outend, 0))      \
 			    {						      \
-			      result = __GCONV_FULL_OUTPUT;		      \
+			      res = __GCONV_FULL_OUTPUT;		      \
 			      break;					      \
 			    }						      \
 			  *outptr++ = ESC;				      \
@@ -881,12 +880,12 @@ static const cvlist_t conversion_lists[4] =
 									      \
 		      if (__builtin_expect (outptr + 2 > outend, 0))	      \
 			{						      \
-			  result = __GCONV_FULL_OUTPUT;			      \
+			  res = __GCONV_FULL_OUTPUT;			      \
 			  break;					      \
 			}						      \
 		      *outptr++ = buf[0];				      \
 		      *outptr++ = buf[1];				      \
-		      result = __GCONV_OK;				      \
+		      res = __GCONV_OK;					      \
 		      break;						      \
 		    }							      \
 									      \
@@ -903,7 +902,7 @@ static const cvlist_t conversion_lists[4] =
 			{						      \
 			  if (__builtin_expect (outptr + 3 > outend, 0))      \
 			    {						      \
-			      result = __GCONV_FULL_OUTPUT;		      \
+			      res = __GCONV_FULL_OUTPUT;		      \
 			      break;					      \
 			    }						      \
 			  *outptr++ = ESC;				      \
@@ -914,12 +913,12 @@ static const cvlist_t conversion_lists[4] =
 									      \
 		      if (__builtin_expect (outptr + 2 > outend, 0))	      \
 			{						      \
-			  result = __GCONV_FULL_OUTPUT;			      \
+			  res = __GCONV_FULL_OUTPUT;			      \
 			  break;					      \
 			}						      \
 		      *outptr++ = buf[0];				      \
 		      *outptr++ = buf[1];				      \
-		      result = __GCONV_OK;				      \
+		      res = __GCONV_OK;					      \
 		      break;						      \
 		    }							      \
 									      \
@@ -936,7 +935,7 @@ static const cvlist_t conversion_lists[4] =
 			{						      \
 			  if (__builtin_expect (outptr + 4 > outend, 0))      \
 			    {						      \
-			      result = __GCONV_FULL_OUTPUT;		      \
+			      res = __GCONV_FULL_OUTPUT;		      \
 			      break;					      \
 			    }						      \
 			  *outptr++ = ESC;				      \
@@ -948,12 +947,12 @@ static const cvlist_t conversion_lists[4] =
 									      \
 		      if (__builtin_expect (outptr + 2 > outend, 0))	      \
 			{						      \
-			  result = __GCONV_FULL_OUTPUT;			      \
+			  res = __GCONV_FULL_OUTPUT;			      \
 			  break;					      \
 			}						      \
 		      *outptr++ = buf[0];				      \
 		      *outptr++ = buf[1];				      \
-		      result = __GCONV_OK;				      \
+		      res = __GCONV_OK;					      \
 		      break;						      \
 		    }							      \
 									      \
@@ -972,7 +971,7 @@ static const cvlist_t conversion_lists[4] =
 			{						      \
 			  if (__builtin_expect (outptr + 3 > outend, 0))      \
 			    {						      \
-			      result = __GCONV_FULL_OUTPUT;		      \
+			      res = __GCONV_FULL_OUTPUT;		      \
 			      break;					      \
 			    }						      \
 			  *outptr++ = ESC;				      \
@@ -983,11 +982,11 @@ static const cvlist_t conversion_lists[4] =
 									      \
 		      if (__builtin_expect (outptr + 1 > outend, 0))	      \
 			{						      \
-			  result = __GCONV_FULL_OUTPUT;			      \
+			  res = __GCONV_FULL_OUTPUT;			      \
 			  break;					      \
 			}						      \
 		      *outptr++ = buf[0] - 0x80;			      \
-		      result = __GCONV_OK;				      \
+		      res = __GCONV_OK;					      \
 		      break;						      \
 		    }							      \
 									      \
@@ -996,13 +995,16 @@ static const cvlist_t conversion_lists[4] =
 		default:						      \
 		  abort ();						      \
 		}							      \
-	    while (result == __GCONV_ILLEGAL_INPUT			      \
+	    while (res == __GCONV_ILLEGAL_INPUT				      \
 		   && (conversion_list = CVLIST_REST (conversion_list)) != 0);\
 									      \
-	    if (result == __GCONV_FULL_OUTPUT)				      \
-	      break;							      \
+	    if (res == __GCONV_FULL_OUTPUT)				      \
+	      {								      \
+		result = res;						      \
+		break;							      \
+	      }								      \
 									      \
-	    if (result == __GCONV_ILLEGAL_INPUT)			      \
+	    if (res == __GCONV_ILLEGAL_INPUT)				      \
 	      {								      \
 		STANDARD_TO_LOOP_ERR_HANDLER (4);			      \
 	      }								      \
@@ -1017,6 +1019,13 @@ static const cvlist_t conversion_lists[4] =
 #define INIT_PARAMS		int set = *setp & CURRENT_SEL_MASK;	      \
 				int set2 = *setp & CURRENT_ASSIGN_MASK;	      \
 				int tag = *setp & CURRENT_TAG_MASK;
+#define REINIT_PARAMS		do					      \
+				  {					      \
+				    set = *setp & CURRENT_SEL_MASK;	      \
+				    set2 = *setp & CURRENT_ASSIGN_MASK;	      \
+				    tag = *setp & CURRENT_TAG_MASK;	      \
+				  }					      \
+				while (0)
 #define UPDATE_PARAMS		*setp = set | set2 | tag
 #include <iconv/loop.c>
 
diff --git a/iconvdata/iso-2022-kr.c b/iconvdata/iso-2022-kr.c
index 6439b0a469..556a33d449 100644
--- a/iconvdata/iso-2022-kr.c
+++ b/iconvdata/iso-2022-kr.c
@@ -1,5 +1,6 @@
 /* Conversion module for ISO-2022-KR.
-   Copyright (C) 1998, 1999, 2000-2002, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000-2002, 2007, 2008
+   Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
@@ -261,6 +262,7 @@ enum
 #define LOOP_NEED_FLAGS
 #define EXTRA_LOOP_DECLS	, int *setp
 #define INIT_PARAMS		int set = *setp
+#define REINIT_PARAMS		set = *setp
 #define UPDATE_PARAMS		*setp = set
 #include <iconv/loop.c>
 
diff --git a/iconvdata/tst-iconv7.c b/iconvdata/tst-iconv7.c
new file mode 100644
index 0000000000..a01e3d8425
--- /dev/null
+++ b/iconvdata/tst-iconv7.c
@@ -0,0 +1,61 @@
+#include <iconv.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static int
+do_test (void)
+{
+  setlocale (LC_ALL, "de_DE.UTF-8");
+
+  iconv_t cd = iconv_open ("ISO-2022-JP//TRANSLIT", "");
+  if (cd == (iconv_t) -1)
+    {
+      puts ("iconv_open failed");
+      return 1;
+    }
+
+  char instr1[] = "\xc2\xa3\xe2\x82\xac\n";
+  const char expstr1[] = "\033$B!r\033(BEUR\n";
+  char outstr[32];
+  size_t inlen = sizeof (instr1);
+  size_t outlen = sizeof (outstr);
+  char *inptr = instr1;
+  char *outptr = outstr;
+  size_t r = iconv (cd, &inptr, &inlen, &outptr, &outlen);
+  if (r != 1
+      || inlen != 0
+      || outlen != sizeof (outstr) - sizeof (expstr1)
+      || memcmp (outstr, expstr1, sizeof (expstr1)) != 0)
+    {
+      puts ("wrong first conversion");
+      return 1;
+    }
+
+  char instr2[] = "\xe3\x88\xb1\n";
+  const char expstr2[] = "(\033$B3t\033(B)\n";
+  inlen = sizeof (instr2);
+  outlen = sizeof (outstr);
+  inptr = instr2;
+  outptr = outstr;
+  r = iconv (cd, &inptr, &inlen, &outptr, &outlen);
+  if (r != 1
+      || inlen != 0
+      || outlen != sizeof (outstr) - sizeof (expstr2)
+      || memcmp (outstr, expstr2, sizeof (expstr2)) != 0)
+    {
+      puts ("wrong second conversion");
+      return 1;
+    }
+
+  if (iconv_close (cd) != 0)
+    {
+      puts ("iconv_close failed");
+      return 1;
+    }
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"