about summary refs log tree commit diff
path: root/iconvdata
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-06-19 21:12:06 +0000
committerUlrich Drepper <drepper@redhat.com>2000-06-19 21:12:06 +0000
commitd620426811688301eb1cbe6e63773d6430b2706e (patch)
tree555eb9182298ec1e56db8a5de4f62daa2e654321 /iconvdata
parent01da56ba764e6abc52bfe9a1feeb79d3d67346d1 (diff)
downloadglibc-d620426811688301eb1cbe6e63773d6430b2706e.tar.gz
glibc-d620426811688301eb1cbe6e63773d6430b2706e.tar.xz
glibc-d620426811688301eb1cbe6e63773d6430b2706e.zip
Update.
2000-06-19  Ulrich Drepper  <drepper@redhat.com>

	* iconv/gconv.h (__gconv_trans_fct): Add new parameter.
	General namespace cleanup.
	(struct __gconv_trans_data): Add next field.
	(struct __gconv_step_data): Make __trans a pointer.
	* iconv/gconv_conf.c: Split out code to find gconv directories from
	__gconv_read_conf in new functions.
	* iconv/gconv_int.h: Define new data structure and declare new
	functions for handling of gconv directory list.
	* iconv/gconv_open.c: Allow more than one error handling step being
	used.  Call function to load error handling module if it is none
	of the builtin transformations.
	* iconv/gconv_close.c: Add code to free transliteration data.
	* iconv/gconv_trans.c: Add functions to load and unload modules
	implementing transliteration etc.
	* iconv/skeleton.c: Call all context functions now that more than
	one module is allowed.
	* iconv/loop.c (STANDARD_ERR_HANDLING): New macro.
	* iconv/gconv_simple.c: Use STANDARD_ERR_HANDLING macro for places
	where the full error handling using transliteration is needed.
	* iconvdata/8bit-gap.c: Likewise.
	* iconvdata/8bit-generic.c: Likewise.
	* iconvdata/ansi_x3.110.c: Likewise.
	* iconvdata/big5.c: Likewise.
	* iconvdata/big5hkscs.c: Likewise.
	* iconvdata/euc-cn.c: Likewise.
	* iconvdata/euc-jp.c: Likewise.
	* iconvdata/euc-kr.c: Likewise.
	* iconvdata/euc-tw.c: Likewise.
	* iconvdata/gbgbk.c: Likewise.
	* iconvdata/gbk.c: Likewise.
	* iconvdata/iso-2022-cn.c: Likewise.
	* iconvdata/iso-2022-jp.c: Likewise.
	* iconvdata/iso-2022-kr.c: Likewise.
	* iconvdata/iso646.c: Likewise.
	* iconvdata/iso8859-1.c: Likewise.
	* iconvdata/iso_6937-2.c: Likewise.
	* iconvdata/iso_6937.c: Likewise.
	* iconvdata/johab.c: Likewise.
	* iconvdata/sjis.c: Likewise.
	* iconvdata/t.61.c: Likewise.
	* iconvdata/uhc.c: Likewise.
	* iconvdata/unicode.c: Likewise.
	* iconvdata/utf-16.c: Likewise.
	* libio/iofwide.c: Reset __trans member of __gconv_trans_data
	structure correctly after last change.
	* wcsmbs/btowc.c: Likewise.
	* wcsmbs/mbrtowc.c: Likewise.
	* wcsmbs/mbsnrtowcs.c: Likewise.
	* wcsmbs/mbsrtowcs.c: Likewise.
	* wcsmbs/wcrtomb.c: Likewise.
	* wcsmbs/wcsnrtombs.c: Likewise.
	* wcsmbs/wcsrtombs.c: Likewise.
	* wcsmbs/wctob.c: Likewise.

	* localedata/Makefile: Set -Wno-format for some files since gcc does
	not know all the format specifiers.

2000-06-18  Ulrich Drepper  <drepper@redhat.com>

	* locale/loadlocale.c (_nl_unload_locale): Remove a bit of
	unneeded code.
	* locale/lc-time.c (_nl_init_era_entries): Likewise.
Diffstat (limited to 'iconvdata')
-rw-r--r--iconvdata/8bit-gap.c76
-rw-r--r--iconvdata/8bit-generic.c27
-rw-r--r--iconvdata/ansi_x3.110.c60
-rw-r--r--iconvdata/big5.c20
-rw-r--r--iconvdata/big5hkscs.c20
-rw-r--r--iconvdata/euc-cn.c20
-rw-r--r--iconvdata/euc-jp.c21
-rw-r--r--iconvdata/euc-kr.c20
-rw-r--r--iconvdata/euc-tw.c20
-rw-r--r--iconvdata/gbgbk.c29
-rw-r--r--iconvdata/gbk.c20
-rw-r--r--iconvdata/iso-2022-cn.c21
-rw-r--r--iconvdata/iso-2022-jp.c44
-rw-r--r--iconvdata/iso-2022-kr.c20
-rw-r--r--iconvdata/iso646.c25
-rw-r--r--iconvdata/iso8859-1.c20
-rw-r--r--iconvdata/iso_6937-2.c45
-rw-r--r--iconvdata/iso_6937.c41
-rw-r--r--iconvdata/johab.c42
-rw-r--r--iconvdata/sjis.c46
-rw-r--r--iconvdata/t.61.c42
-rw-r--r--iconvdata/uhc.c42
-rw-r--r--iconvdata/unicode.c21
-rw-r--r--iconvdata/utf-16.c42
24 files changed, 56 insertions, 728 deletions
diff --git a/iconvdata/8bit-gap.c b/iconvdata/8bit-gap.c
index a4a32d3eae..7caa5427d5 100644
--- a/iconvdata/8bit-gap.c
+++ b/iconvdata/8bit-gap.c
@@ -83,75 +83,17 @@ struct gap
     unsigned char res;							      \
 									      \
     if (__builtin_expect (ch, 0) >= 0xffff)				      \
+      rp = NULL;							      \
+    else								      \
+      while (ch > rp->end)						      \
+	++rp;								      \
+    if (__builtin_expect (rp == NULL, 0)				      \
+	|| __builtin_expect (ch < rp->start, 0)				      \
+	|| (res = from_ucs4[ch + rp->idx],				      \
+	    __builtin_expect (res, '\1') == '\0' && ch != 0))		      \
       {									      \
 	/* This is an illegal character.  */				      \
-	if (step_data->__trans.__trans_fct != NULL)			      \
-	  {								      \
-	    result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				  (step, step_data, *inptrp, &inptr, inend,   \
-				   &outptr, irreversible));		      \
-	    if (result != __GCONV_OK)					      \
-	      break;							      \
-	  }								      \
-	else if (! ignore_errors_p ())					      \
-	  {								      \
-	    result = __GCONV_ILLEGAL_INPUT;				      \
-	    break;							      \
-	  }								      \
-									      \
-	++*irreversible;						      \
-	inptr += 4;							      \
-	continue;							      \
-      }									      \
-    while (ch > rp->end)						      \
-      ++rp;								      \
-    if (__builtin_expect (ch < rp->start, 0))				      \
-      {									      \
-	/* This is an illegal character.  */				      \
-	if (step_data->__trans.__trans_fct != NULL)			      \
-	  {								      \
-	    result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				  (step, step_data, *inptrp, &inptr, inend,   \
-				   &outptr, irreversible));		      \
-	    if (result != __GCONV_OK)					      \
-	      break;							      \
-	  }								      \
-	else if (! ignore_errors_p ())					      \
-	  {								      \
-	    result = __GCONV_ILLEGAL_INPUT;				      \
-	    break;							      \
-	  }								      \
-	else								      \
-	  {								      \
-	    ++*irreversible;						      \
-	    inptr += 4;							      \
-	  }								      \
-	continue;							      \
-      }									      \
-									      \
-    res = from_ucs4[ch + rp->idx];					      \
-    if (__builtin_expect (res, '\1') == '\0' && ch != 0)		      \
-      {									      \
-	/* This is an illegal character.  */				      \
-	if (step_data->__trans.__trans_fct != NULL)			      \
-	  {								      \
-	    result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				  (step, step_data, *inptrp, &inptr, inend,   \
-				   &outptr, irreversible));		      \
-	    if (result != __GCONV_OK)					      \
-	      break;							      \
-	  }								      \
-	else if (! ignore_errors_p ())					      \
-	  {								      \
-	    result = __GCONV_ILLEGAL_INPUT;				      \
-	    break;							      \
-	  }								      \
-	else								      \
-	  {								      \
-	    ++*irreversible;						      \
-	    inptr += 4;							      \
-	  }								      \
-	continue;							      \
+	STANDARD_ERR_HANDLER (4);					      \
       }									      \
 									      \
     *outptr++ = res;							      \
diff --git a/iconvdata/8bit-generic.c b/iconvdata/8bit-generic.c
index 02d972e21c..bc05ccd8db 100644
--- a/iconvdata/8bit-generic.c
+++ b/iconvdata/8bit-generic.c
@@ -68,30 +68,11 @@
 	|| (__builtin_expect (from_ucs4[ch], '\1') == '\0' && ch != 0))	      \
       {									      \
 	/* This is an illegal character.  */				      \
-	if (step_data->__trans.__trans_fct != NULL)			      \
-	  {								      \
-	    result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				  (step, step_data, *inptrp, &inptr, inend,   \
-				   &outptr, irreversible));		      \
-	    if (result != __GCONV_OK)					      \
-	      break;							      \
-	  }								      \
-	else if (! ignore_errors_p ())					      \
-	  {								      \
-	    result = __GCONV_ILLEGAL_INPUT;				      \
-	    break;							      \
-	  }								      \
-	else								      \
-	  {								      \
-	    ++*irreversible;						      \
-	    inptr += 4;							      \
-	  }								      \
-      }									      \
-    else								      \
-      {									      \
-	*outptr++ = from_ucs4[ch];					      \
-	inptr += 4;							      \
+	STANDARD_ERR_HANDLER (4);					      \
       }									      \
+									      \
+    *outptr++ = from_ucs4[ch];						      \
+    inptr += 4;								      \
   }
 #define LOOP_NEED_FLAGS
 #include <iconv/loop.c>
diff --git a/iconvdata/ansi_x3.110.c b/iconvdata/ansi_x3.110.c
index 6ec09c3c5c..d55af6fba7 100644
--- a/iconvdata/ansi_x3.110.c
+++ b/iconvdata/ansi_x3.110.c
@@ -497,25 +497,7 @@ static const char from_ucs4[][2] =
 	    if (tmp[0] == '\0')						      \
 	      {								      \
 		/* Illegal characters.  */				      \
-		if (step_data->__trans.__trans_fct != NULL)		      \
-		  {							      \
-		    result = DL_CALL_FCT (step_data->__trans.__trans_fct,     \
-					  (step, step_data, *inptrp, &inptr,  \
-					   inend, &outptr, irreversible));    \
-		    if (result != __GCONV_OK)				      \
-		      break;						      \
-		  }							      \
-		else if (! ignore_errors_p ())				      \
-		  {							      \
-		    result = __GCONV_ILLEGAL_INPUT;			      \
-		    break;						      \
-		  }							      \
-		else							      \
-		  {							      \
-		    ++*irreversible;					      \
-		    inptr += 4;						      \
-		  }							      \
-		continue;						      \
+		STANDARD_ERR_HANDLER (4);				      \
 	      }								      \
 	    tmp[1] = '\0';						      \
 	    cp = tmp;							      \
@@ -555,25 +537,7 @@ static const char from_ucs4[][2] =
 	else								      \
 	  {								      \
 	    /* Illegal characters.  */					      \
-	    if (step_data->__trans.__trans_fct != NULL)			      \
-	      {								      \
-		result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				      (step, step_data, *inptrp, &inptr,      \
-				       inend, &outptr, irreversible));	      \
-		if (result != __GCONV_OK)				      \
-		  break;						      \
-	      }								      \
-	    else if (! ignore_errors_p ())				      \
-	      {								      \
-		result = __GCONV_ILLEGAL_INPUT;				      \
-		break;							      \
-	      }								      \
-	    else							      \
-	      {								      \
-		++*irreversible;					      \
-		inptr += 4;						      \
-	      }								      \
-	    continue;							      \
+	    STANDARD_ERR_HANDLER (4);					      \
 	  }								      \
       }									      \
     else								      \
@@ -583,25 +547,7 @@ static const char from_ucs4[][2] =
 	if (__builtin_expect (cp[0], '\1') == '\0' && ch != 0)		      \
 	  {								      \
 	    /* Illegal characters.  */					      \
-	    if (step_data->__trans.__trans_fct != NULL)			      \
-	      {								      \
-		result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				      (step, step_data, *inptrp, &inptr,      \
-				       inend, &outptr, irreversible));	      \
-		if (result != __GCONV_OK)				      \
-		  break;						      \
-	      }								      \
-	    else if (! ignore_errors_p ())				      \
-	      {								      \
-		result = __GCONV_ILLEGAL_INPUT;				      \
-		break;							      \
-	      }								      \
-	    else							      \
-	      {								      \
-		++*irreversible;					      \
-		inptr += 4;						      \
-	      }								      \
-	    continue;							      \
+	    STANDARD_ERR_HANDLER (4);					      \
 	  }								      \
       }									      \
 									      \
diff --git a/iconvdata/big5.c b/iconvdata/big5.c
index 947a92a341..1ba1b3f28f 100644
--- a/iconvdata/big5.c
+++ b/iconvdata/big5.c
@@ -8585,25 +8585,7 @@ static const char from_ucs4_tab13[][2] =
     if (__builtin_expect (cp[0], '\1') == '\0' && ch != 0)		      \
       {									      \
 	/* Illegal character.  */					      \
-	if (step_data->__trans.__trans_fct != NULL)			      \
-	  {								      \
-	    result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				  (step, step_data, *inptrp, &inptr, inend,   \
-				   &outptr, irreversible));		      \
-	    if (result != __GCONV_OK)					      \
-	      break;							      \
-	  }								      \
-	else if (! ignore_errors_p ())					      \
-	  {								      \
-	    result = __GCONV_ILLEGAL_INPUT;				      \
-	    break;							      \
-	  }								      \
-	else								      \
-	  {								      \
-	    ++*irreversible;						      \
-	    inptr += 4;							      \
-	  }								      \
-	continue;							      \
+	STANDARD_ERR_HANDLER (4);					      \
       }									      \
     else								      \
       {									      \
diff --git a/iconvdata/big5hkscs.c b/iconvdata/big5hkscs.c
index 64923d42af..bf38e15a5a 100644
--- a/iconvdata/big5hkscs.c
+++ b/iconvdata/big5hkscs.c
@@ -12742,25 +12742,7 @@ static const char from_ucs4_tab14[][2] =
     if (__builtin_expect (cp[0], '\1') == '\0' && ch != 0)		      \
       {									      \
 	/* Illegal character.  */					      \
-	if (step_data->__trans.__trans_fct != NULL)			      \
-	  {								      \
-	    result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				  (step, step_data, *inptrp, &inptr, inend,   \
-				   &outptr, irreversible));		      \
-	    if (result != __GCONV_OK)					      \
-	      break;							      \
-	  }								      \
-	else if (! ignore_errors_p ())					      \
-	  {								      \
-	    result = __GCONV_ILLEGAL_INPUT;				      \
-	    break;							      \
-	  }								      \
-	else								      \
-	  {								      \
-	    ++*irreversible;						      \
-	    inptr += 4;							      \
-	  }								      \
-	continue;							      \
+	STANDARD_ERR_HANDLER (4);					      \
       }									      \
     else								      \
       {									      \
diff --git a/iconvdata/euc-cn.c b/iconvdata/euc-cn.c
index 18e73fda6c..58f47eda3f 100644
--- a/iconvdata/euc-cn.c
+++ b/iconvdata/euc-cn.c
@@ -141,25 +141,7 @@
 	    if (__builtin_expect (found, 0) == __UNKNOWN_10646_CHAR)	      \
 	      {								      \
 		/* Illegal character.  */				      \
-		if (step_data->__trans.__trans_fct != NULL)		      \
-		  {							      \
-		    result = DL_CALL_FCT (step_data->__trans.__trans_fct,     \
-					  (step, step_data, *inptrp, &inptr,  \
-					   inend, &outptr, irreversible));    \
-		    if (result != __GCONV_OK)				      \
-		      break;						      \
-		  }							      \
-		else if (! ignore_errors_p ())				      \
-		  {							      \
-		    result = __GCONV_ILLEGAL_INPUT;			      \
-		    break;						      \
-		  }							      \
-		else							      \
-		  {							      \
-		    inptr += 4;						      \
-		    ++*irreversible;					      \
-		  }							      \
-		continue;						      \
+		STANDARD_ERR_HANDLER (4);				      \
 	      }								      \
 									      \
 	    /* It's a GB 2312 character, adjust it for EUC-CN.  */	      \
diff --git a/iconvdata/euc-jp.c b/iconvdata/euc-jp.c
index 3e21d55f12..fc0794d700 100644
--- a/iconvdata/euc-jp.c
+++ b/iconvdata/euc-jp.c
@@ -218,26 +218,7 @@
 		else							      \
 		  {							      \
 		    /* Illegal character.  */				      \
-		    if (step_data->__trans.__trans_fct != NULL)		      \
-		      {							      \
-			result = DL_CALL_FCT (step_data->__trans.__trans_fct, \
-					      (step, step_data, *inptrp,      \
-					       &inptr, inend, &outptr,	      \
-					       irreversible));		      \
-			if (result != __GCONV_OK)			      \
-			  break;					      \
-		      }							      \
-		    else if (! ignore_errors_p ())			      \
-		      {							      \
-			result = __GCONV_ILLEGAL_INPUT;			      \
-			break;						      \
-		      }							      \
-		    else						      \
-		      {							      \
-			inptr += 4;					      \
-			++*irreversible;				      \
-		      }							      \
-		    continue;						      \
+		    STANDARD_ERR_HANDLER (4);				      \
 		  }							      \
 	      }								      \
 	  }								      \
diff --git a/iconvdata/euc-kr.c b/iconvdata/euc-kr.c
index c32b9b3537..abb40c8908 100644
--- a/iconvdata/euc-kr.c
+++ b/iconvdata/euc-kr.c
@@ -146,25 +146,7 @@ euckr_from_ucs4 (uint32_t ch, unsigned char *cp)
     if (__builtin_expect (cp[0], '\1') == '\0' && ch != 0)		      \
       {									      \
 	/* Illegal character.  */					      \
-	if (step_data->__trans.__trans_fct != NULL)			      \
-	  {								      \
-	    result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				  (step, step_data, *inptrp, &inptr, inend,   \
-				   &outptr, irreversible));		      \
-	    if (result != __GCONV_OK)					      \
-	      break;							      \
-	  }								      \
-	else if (! ignore_errors_p ())					      \
-	  {								      \
-	    result = __GCONV_ILLEGAL_INPUT;				      \
-	    break;							      \
-	  }								      \
-	else								      \
-	  {								      \
-	    inptr += 4;							      \
-	    ++*irreversible;						      \
-	  }								      \
-	continue;							      \
+	STANDARD_ERR_HANDLER (4);					      \
       }									      \
 									      \
     *outptr++ = cp[0];							      \
diff --git a/iconvdata/euc-tw.c b/iconvdata/euc-tw.c
index b4cf21ba97..ed7a197d7c 100644
--- a/iconvdata/euc-tw.c
+++ b/iconvdata/euc-tw.c
@@ -193,25 +193,7 @@
 	    if (__builtin_expect (found, 0) == __UNKNOWN_10646_CHAR)	      \
 	      {								      \
 		/* Illegal character.  */				      \
-		if (step_data->__trans.__trans_fct != NULL)		      \
-		  {							      \
-		    result = DL_CALL_FCT (step_data->__trans.__trans_fct,     \
-					  (step, step_data, *inptrp, &inptr,  \
-					   inend, &outptr, irreversible));    \
-		    if (result != __GCONV_OK)				      \
-		      break;						      \
-		  }							      \
-		else if (! ignore_errors_p ())				      \
-		  {							      \
-		    result = __GCONV_ILLEGAL_INPUT;			      \
-		    break;						      \
-		  }							      \
-		else							      \
-		  {							      \
-		    inptr += 4;						      \
-		    ++*irreversible;					      \
-		  }							      \
-		continue;						      \
+		STANDARD_ERR_HANDLER (4);				      \
 	      }								      \
 									      \
 	    /* It's a CNS 11643 character, adjust it for EUC-TW.  */	      \
diff --git a/iconvdata/gbgbk.c b/iconvdata/gbgbk.c
index 0afcd72311..02e25f31e3 100644
--- a/iconvdata/gbgbk.c
+++ b/iconvdata/gbgbk.c
@@ -102,31 +102,12 @@
 		&& __builtin_expect (ch, 0xa1a1) <= 0xa8c0))		      \
 	  {								      \
 	    /* One of the characters we cannot map.  */			      \
-	    if (step_data->__trans.__trans_fct != NULL)			      \
-	      {								      \
-		result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				      (step, step_data, *inptrp, &inptr,      \
-				       inend, &outptr, irreversible));	      \
-		if (result != __GCONV_OK)				      \
-		  break;						      \
-	      }								      \
-	    else if (! ignore_errors_p ())				      \
-	      {								      \
-		result = __GCONV_ILLEGAL_INPUT;				      \
-		break;							      \
-	      }								      \
-	    else							      \
-	      {								      \
-		inptr += 2;						      \
-		++*irreversible;					      \
-	      }								      \
-	  }								      \
-	else								      \
-	  {								      \
-	    /* Copy the two bytes.  */					      \
-	    *outptr++ = *inptr++;					      \
-	    *outptr++ = *inptr++;					      \
+	    STANDARD_ERR_HANDLER (2);					      \
 	  }								      \
+									      \
+	/* Copy the two bytes.  */					      \
+	*outptr++ = *inptr++;						      \
+	*outptr++ = *inptr++;						      \
       }									      \
   }
 #define LOOP_NEED_FLAGS
diff --git a/iconvdata/gbk.c b/iconvdata/gbk.c
index 4505b65c1a..c3010f30d7 100644
--- a/iconvdata/gbk.c
+++ b/iconvdata/gbk.c
@@ -13452,25 +13452,7 @@ static const char __gbk_from_ucs4_tab12[][2] =
       if (__builtin_expect (cp[0], '\1') == '\0' && ch != 0)		      \
 	{								      \
 	  /* Illegal character.  */					      \
-	  if (step_data->__trans.__trans_fct != NULL)			      \
-	    {								      \
-	      result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				    (step, step_data, *inptrp, &inptr, inend, \
-				     &outptr, irreversible));		      \
-	      if (result != __GCONV_OK)					      \
-		break;							      \
-	    }								      \
-	  else if (! ignore_errors_p ())				      \
-	    {								      \
-	      result = __GCONV_ILLEGAL_INPUT;				      \
-	      break;							      \
-	    }								      \
-	  else								      \
-	    {								      \
-	      inptr += 4;						      \
-	      ++*irreversible;						      \
-	    }								      \
-	  continue;							      \
+	  STANDARD_ERR_HANDLER (4);					      \
 	}								      \
       /* See whether there is enough room for the second byte we write.  */   \
       else if (cp[1] != '\0' && __builtin_expect (outptr + 1 >= outend, 0))   \
diff --git a/iconvdata/iso-2022-cn.c b/iconvdata/iso-2022-cn.c
index f2170698dd..6ffa18dc78 100644
--- a/iconvdata/iso-2022-cn.c
+++ b/iconvdata/iso-2022-cn.c
@@ -324,26 +324,7 @@ enum
 		else							      \
 		  {							      \
 		    /* Even this does not work.  Error.  */		      \
-		    if (step_data->__trans.__trans_fct != NULL)		      \
-		      {							      \
-			result = DL_CALL_FCT (step_data->__trans.__trans_fct, \
-					      (step, step_data, *inptrp,      \
-					       &inptr, inend, &outptr,	      \
-					       irreversible));		      \
-			if (result != __GCONV_OK)			      \
-			  break;					      \
-		      }							      \
-		    else if (! ignore_errors_p ())			      \
-		      {							      \
-			result = __GCONV_ILLEGAL_INPUT;			      \
-			break;						      \
-		      }							      \
-		    else						      \
-		      {							      \
-			inptr += 4;					      \
-			++*irreversible;				      \
-		      }							      \
-		    continue;						      \
+		    STANDARD_ERR_HANDLER (4);				      \
 		  }							      \
 	      }								      \
 	  }								      \
diff --git a/iconvdata/iso-2022-jp.c b/iconvdata/iso-2022-jp.c
index ab42bcc75c..ecfdae4e47 100644
--- a/iconvdata/iso-2022-jp.c
+++ b/iconvdata/iso-2022-jp.c
@@ -703,26 +703,7 @@ gconv_end (struct __gconv_step *data)
 		else if (__builtin_expect (var, iso2022jp2) == iso2022jp)     \
 		  {							      \
 		    /* We have no other choice.  */			      \
-		    if (step_data->__trans.__trans_fct != NULL)		      \
-		      {							      \
-			result = DL_CALL_FCT (step_data->__trans.__trans_fct, \
-					      (step, step_data, *inptrp,      \
-					       &inptr, inend, &outptr,	      \
-					       irreversible));		      \
-			if (result != __GCONV_OK)			      \
-			  break;					      \
-		      }							      \
-		    else if (! ignore_errors_p ())			      \
-		      {							      \
-			result = __GCONV_ILLEGAL_INPUT;			      \
-			break;						      \
-		      }							      \
-		    else						      \
-		      {							      \
-			inptr += 4;					      \
-			++*irreversible;				      \
-		      }							      \
-		    continue;						      \
+		    STANDARD_ERR_HANDLER (4);				      \
 		  }							      \
 		else							      \
 		  {							      \
@@ -888,28 +869,7 @@ gconv_end (struct __gconv_step *data)
 				      }					      \
 				    else				      \
 				      {					      \
-					if (step_data->__trans.__trans_fct    \
-					    != NULL)			      \
-					  {				      \
-					    result = DL_CALL_FCT	      \
-  					      (step_data->__trans.__trans_fct,\
-					       (step, step_data, *inptrp,     \
-						&inptr, inend, &outptr,	      \
-						irreversible));		      \
-					    if (result != __GCONV_OK)	      \
-					      break;			      \
-					  }				      \
-					else if (! ignore_errors_p ())	      \
-					  {				      \
-					     result = __GCONV_ILLEGAL_INPUT;  \
-					     break;			      \
-					  }				      \
-					else				      \
-					  {				      \
-					    ++*irreversible;		      \
-					    inptr += 4;			      \
-					  }				      \
-					continue;			      \
+					STANDARD_ERR_HANDLER (4);	      \
 				      }					      \
 				  }					      \
 			      }						      \
diff --git a/iconvdata/iso-2022-kr.c b/iconvdata/iso-2022-kr.c
index 52031ca177..56e17a2f96 100644
--- a/iconvdata/iso-2022-kr.c
+++ b/iconvdata/iso-2022-kr.c
@@ -255,25 +255,7 @@ enum
 	if (__builtin_expect (written, 0) == __UNKNOWN_10646_CHAR)	      \
 	  {								      \
 	    /* Illegal character.  */					      \
-	    if (step_data->__trans.__trans_fct != NULL)			      \
-	      {								      \
-		result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				      (step, step_data, *inptrp, &inptr,      \
-				       inend, &outptr, irreversible));	      \
-		if (result != __GCONV_OK)				      \
-		  break;						      \
-	      }								      \
-	    else if (! ignore_errors_p ())				      \
-	      {								      \
-		result = __GCONV_ILLEGAL_INPUT;				      \
-		break;							      \
-	      }								      \
-	    else							      \
-	      {								      \
-		++*irreversible;					      \
-		inptr += 4;						      \
-	      }								      \
-	    continue;							      \
+	    STANDARD_ERR_HANDLER (4);					      \
 	  }								      \
 	else								      \
 	  {								      \
diff --git a/iconvdata/iso646.c b/iconvdata/iso646.c
index 66f89589cc..99dc0251b0 100644
--- a/iconvdata/iso646.c
+++ b/iconvdata/iso646.c
@@ -885,29 +885,10 @@ gconv_end (struct __gconv_step *data)
 									      \
     if (__builtin_expect (failure, __GCONV_OK) == __GCONV_ILLEGAL_INPUT)      \
       {									      \
-	if (step_data->__trans.__trans_fct != NULL)			      \
-	  {								      \
-	    result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				  (step, step_data, *inptrp, &inptr, inend,   \
-				   &outptr, irreversible));		      \
-	    if (result != __GCONV_OK)					      \
-	      break;							      \
-	  }								      \
-	else if (! ignore_errors_p ())					      \
-	  {								      \
-	    /* Exit the loop with an error.  */				      \
-	    result = __GCONV_ILLEGAL_INPUT;				      \
-	    break;							      \
-	  }								      \
-	else								      \
-	  {								      \
-	    ++*irreversible;						      \
-	    inptr += 4;							      \
-	  }								      \
-	continue;							      \
+	STANDARD_ERR_HANDLER (4);					      \
       }									      \
-    else								      \
-      *outptr++ = (unsigned char) ch;					      \
+									      \
+    *outptr++ = (unsigned char) ch;					      \
     inptr += 4;								      \
   }
 #define LOOP_NEED_FLAGS
diff --git a/iconvdata/iso8859-1.c b/iconvdata/iso8859-1.c
index a6134816db..bedc425ec3 100644
--- a/iconvdata/iso8859-1.c
+++ b/iconvdata/iso8859-1.c
@@ -49,25 +49,7 @@
     if (__builtin_expect (ch, 0) > 0xff)				      \
       {									      \
 	/* We have an illegal character.  */				      \
-	if (step_data->__trans.__trans_fct != NULL)			      \
-	  {								      \
-	    result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				  (step, step_data, *inptrp, &inptr, inend,   \
-				   &outptr, irreversible));		      \
-	    if (result != __GCONV_OK)					      \
-	      break;							      \
-	  }								      \
-	else if (! ignore_errors_p ())					      \
-	  {								      \
-	    result = __GCONV_ILLEGAL_INPUT;				      \
-	    break;							      \
-	  }								      \
-	else								      \
-	  {								      \
-	    inptr += 4;							      \
-	    ++*irreversible;						      \
-	  }								      \
-	continue;							      \
+	STANDARD_ERR_HANDLER (4);					      \
       }									      \
     else								      \
       *outptr++ = (unsigned char) ch;					      \
diff --git a/iconvdata/iso_6937-2.c b/iconvdata/iso_6937-2.c
index cde210844d..dda8acd53f 100644
--- a/iconvdata/iso_6937-2.c
+++ b/iconvdata/iso_6937-2.c
@@ -565,50 +565,17 @@ static const char from_ucs4[][2] =
 	  default:							      \
 	    /* Illegal characters.  */					      \
 	    cp = NULL;							      \
-	    if (step_data->__trans.__trans_fct != NULL)			      \
-	      {								      \
-		result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				      (step, step_data, *inptrp, &inptr,      \
-				       inend, &outptr, irreversible));	      \
-		if (result != __GCONV_OK)				      \
-		  break;						      \
-	      }								      \
-	    else if (! ignore_errors_p ())				      \
-	      {								      \
-	        /* This is an illegal character.  */			      \
-		result = __GCONV_ILLEGAL_INPUT;				      \
-		break;							      \
-	      }								      \
-	    else							      \
-	      {								      \
-		inptr += 4;						      \
-		++*irreversible;					      \
-	      }								      \
-	    continue;							      \
+	    break;							      \
+	  }								      \
+	if (cp == NULL)							      \
+	  {								      \
+	    STANDARD_ERR_HANDLER (4);					      \
 	  }								      \
       }									      \
     else if (__builtin_expect (from_ucs4[ch][0], '\1') == '\0' && ch != 0)    \
       {									      \
 	/* Illegal characters.  */					      \
-	if (step_data->__trans.__trans_fct != NULL)			      \
-	  {								      \
-	    result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				  (step, step_data, *inptrp, &inptr, inend,   \
-				   &outptr, irreversible));		      \
-	    if (result != __GCONV_OK)					      \
-	      break;							      \
-	  }								      \
-	else if (! ignore_errors_p ())					      \
-	  {								      \
-	    result = __GCONV_ILLEGAL_INPUT;				      \
-	    break;							      \
-	  }								      \
-	else								      \
-	  {								      \
-	    inptr += 4;							      \
-	    ++*irreversible;						      \
-	  }								      \
-	continue;							      \
+	STANDARD_ERR_HANDLER (4);					      \
       }									      \
     else								      \
       cp = from_ucs4[ch];						      \
diff --git a/iconvdata/iso_6937.c b/iconvdata/iso_6937.c
index e767291adf..d51f321d33 100644
--- a/iconvdata/iso_6937.c
+++ b/iconvdata/iso_6937.c
@@ -542,50 +542,13 @@ static const char from_ucs4[][2] =
 	if (__builtin_expect (fail, 0))					      \
 	  {								      \
 	    /* Illegal characters.  */					      \
-	    if (step_data->__trans.__trans_fct != NULL)			      \
-	      {								      \
-		result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				      (step, step_data, *inptrp, &inptr,      \
-				       inend, &outptr, irreversible));	      \
-		if (result != __GCONV_OK)				      \
-		  break;						      \
-	      }								      \
-	    else if (! ignore_errors_p ())				      \
-	      {								      \
-	        /* This is an illegal character.  */			      \
-		result = __GCONV_ILLEGAL_INPUT;				      \
-		break;							      \
-	      }								      \
-	    else							      \
-	      {								      \
-		inptr += 4;						      \
-		++*irreversible;					      \
-	      }								      \
-	    continue;							      \
+	    STANDARD_ERR_HANDLER (4);					      \
 	  }								      \
       }									      \
     else if (__builtin_expect (from_ucs4[ch][0], '\1') == '\0' && ch != 0)    \
       {									      \
 	/* Illegal characters.  */					      \
-	if (step_data->__trans.__trans_fct != NULL)			      \
-	  {								      \
-	    result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				  (step, step_data, *inptrp, &inptr, inend,   \
-				   &outptr, irreversible));		      \
-	    if (result != __GCONV_OK)					      \
-	      break;							      \
-	  }								      \
-	else if (! ignore_errors_p ())					      \
-	  {								      \
-	    result = __GCONV_ILLEGAL_INPUT;				      \
-	    break;							      \
-	  }								      \
-	else								      \
-	  {								      \
-	    inptr += 4;							      \
-	    ++*irreversible;						      \
-	  }								      \
-	continue;							      \
+	STANDARD_ERR_HANDLER (4);					      \
       }									      \
     else								      \
       cp = from_ucs4[ch];						      \
diff --git a/iconvdata/johab.c b/iconvdata/johab.c
index d2947dcd89..46649c5923 100644
--- a/iconvdata/johab.c
+++ b/iconvdata/johab.c
@@ -396,26 +396,7 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
 	      }								      \
 	    if (__builtin_expect (written, 0) == __UNKNOWN_10646_CHAR)	      \
 	      {								      \
-		if (step_data->__trans.__trans_fct != NULL)		      \
-		  {							      \
-		    result = DL_CALL_FCT (step_data->__trans.__trans_fct,     \
-					  (step, step_data, *inptrp, &inptr,  \
- 					   inend, &outptr, irreversible));    \
-		    if (result != __GCONV_OK)				      \
-		      break;						      \
-		  }							      \
-		else if (! ignore_errors_p ())				      \
-		  {							      \
-		    /* This is an illegal character.  */		      \
-		    result = __GCONV_ILLEGAL_INPUT;			      \
-		    break;						      \
-		  }							      \
-		else							      \
-		  {							      \
-		    inptr += 4;						      \
-		    ++*irreversible;					      \
-		  }							      \
-		continue;						      \
+		STANDARD_ERR_HANDLER (4);				      \
 	      }								      \
 									      \
 	    outptr[0] -= 0x4a;						      \
@@ -441,26 +422,7 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
 	      }								      \
 	    if (__builtin_expect (written, 1) == __UNKNOWN_10646_CHAR)	      \
 	      {								      \
-		if (step_data->__trans.__trans_fct != NULL)		      \
-		  {							      \
-		    result = DL_CALL_FCT (step_data->__trans.__trans_fct,     \
-					  (step, step_data, *inptrp, &inptr,  \
-					   inend, &outptr, irreversible));    \
-		    if (result != __GCONV_OK)				      \
-		      break;						      \
-		  }							      \
-		else if (! ignore_errors_p ())				      \
-		  {							      \
-		    /* This is an illegal character.  */		      \
-		    result = __GCONV_ILLEGAL_INPUT;			      \
-		    break;						      \
-		  }							      \
-		else							      \
-		  {							      \
-		    inptr += 4;						      \
-		    ++*irreversible;					      \
-		  }							      \
-		continue;						      \
+		STANDARD_ERR_HANDLER (4);				      \
 	      }								      \
 									      \
 	    outptr[0] -= 0x4a;						      \
diff --git a/iconvdata/sjis.c b/iconvdata/sjis.c
index aa51259355..08dce1c64b 100644
--- a/iconvdata/sjis.c
+++ b/iconvdata/sjis.c
@@ -4466,29 +4466,8 @@ static const char from_ucs4_extra[0x100][2] =
 		 && __builtin_expect (ch, 0xff01) <= 0xffef)		      \
 	  cp = from_ucs4_extra[ch - 0xff00];				      \
 	else								      \
-	  {								      \
-	    /* Illegal character.  */					      \
-	    if (step_data->__trans.__trans_fct != NULL)			      \
-	      {								      \
-		result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				      (step, step_data, *inptrp, &inptr,      \
-				       inend, &outptr, irreversible));	      \
-		if (result != __GCONV_OK)				      \
-		  break;						      \
-	      }								      \
-	    else if (! ignore_errors_p ())				      \
-	      {								      \
-	        /* This is an illegal character.  */			      \
-		result = __GCONV_ILLEGAL_INPUT;				      \
-		break;							      \
-	      }								      \
-	    else							      \
-	      {								      \
-		inptr += 4;						      \
-		++*irreversible;					      \
-	      }								      \
-	    continue;							      \
-	  }								      \
+	  /* Illegal character.  */					      \
+	  cp = "";							      \
       }									      \
     else								      \
       cp = from_ucs4_lat1[ch];						      \
@@ -4496,26 +4475,7 @@ static const char from_ucs4_extra[0x100][2] =
     if (__builtin_expect (cp[0], '\1') == '\0' && ch != 0)		      \
       {									      \
 	/* Illegal character.  */					      \
-	if (step_data->__trans.__trans_fct != NULL)			      \
-	  {								      \
-	    result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				  (step, step_data, *inptrp, &inptr, inend,   \
-				   &outptr, irreversible));		      \
-	    if (result != __GCONV_OK)					      \
-	      break;							      \
-	  }								      \
-	else if (! ignore_errors_p ())					      \
-	  {								      \
-	    /* This is an illegal character.  */			      \
-	    result = __GCONV_ILLEGAL_INPUT;				      \
-	    break;							      \
-	  }								      \
-	else								      \
-	  {								      \
-	    inptr += 4;							      \
-	    ++*irreversible;						      \
-	  }								      \
-	continue;							      \
+	STANDARD_ERR_HANDLER (4);					      \
       }									      \
     else								      \
       {									      \
diff --git a/iconvdata/t.61.c b/iconvdata/t.61.c
index 3c1a69e4ab..611eca8b39 100644
--- a/iconvdata/t.61.c
+++ b/iconvdata/t.61.c
@@ -469,26 +469,7 @@ static const char from_ucs4[][2] =
 		 || __builtin_expect (ch, 0x2d8) == 0x02dc)		      \
 	  {								      \
 	    /* Illegal characters.  */					      \
-	    if (step_data->__trans.__trans_fct != NULL)			      \
-	      {								      \
-		result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				      (step, step_data, *inptrp, &inptr,      \
- 				       inend, &outptr, irreversible));	      \
-		if (result != __GCONV_OK)				      \
-		  break;						      \
-	      }								      \
-	    else if (! ignore_errors_p ())				      \
-	      {								      \
-	        /* This is an illegal character.  */			      \
-		result = __GCONV_ILLEGAL_INPUT;				      \
-		break;							      \
-	      }								      \
-	    else							      \
-	      {								      \
-		inptr += 4;						      \
-		++*irreversible;					      \
-	      }								      \
-	    continue;							      \
+	    STANDARD_ERR_HANDLER (4);					      \
 	  }								      \
 	else								      \
 	  {								      \
@@ -506,26 +487,7 @@ static const char from_ucs4[][2] =
 	if (__builtin_expect (cp[0], '\1') == '\0' && ch != 0)		      \
 	  {								      \
 	    /* Illegal.  */						      \
-	    if (step_data->__trans.__trans_fct != NULL)			      \
-	      {								      \
-		result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				      (step, step_data, *inptrp, &inptr,      \
-				       inend, &outptr, irreversible));	      \
-		if (result != __GCONV_OK)				      \
-		  break;						      \
-	      }								      \
-	    else if (! ignore_errors_p ())				      \
-	      {								      \
-	        /* This is an illegal character.  */			      \
-		result = __GCONV_ILLEGAL_INPUT;				      \
-		break;							      \
-	      }								      \
-	    else							      \
-	      {								      \
-		inptr += 4;						      \
-		++*irreversible;					      \
-	      }								      \
-	    continue;							      \
+	    STANDARD_ERR_HANDLER (4);					      \
 	  }								      \
       }									      \
 									      \
diff --git a/iconvdata/uhc.c b/iconvdata/uhc.c
index 5526e9b5ba..38ae65ba2e 100644
--- a/iconvdata/uhc.c
+++ b/iconvdata/uhc.c
@@ -3221,26 +3221,7 @@ static const char uhc_hangul_from_ucs[11172][2] =
 	  }								      \
 	if (__builtin_expect (written, 0) == __UNKNOWN_10646_CHAR)	      \
 	  {								      \
-	    if (step_data->__trans.__trans_fct != NULL)			      \
-	      {								      \
-		result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				      (step, step_data, *inptrp, &inptr,      \
-				       inend, &outptr, irreversible));	      \
-		if (result != __GCONV_OK)				      \
-		  break;						      \
-	      }								      \
-	    else if (! ignore_errors_p ())				      \
-	      {								      \
-	        /* This is an illegal character.  */			      \
-		result = __GCONV_ILLEGAL_INPUT;				      \
-		break;							      \
-	      }								      \
-	    else							      \
-	      {								      \
-		inptr += 4;						      \
-		++*irreversible;					      \
-	      }								      \
-	    continue;							      \
+	    STANDARD_ERR_HANDLER (4);					      \
 	  }								      \
 									      \
 	*outptr++ |= 0x80;						      \
@@ -3261,26 +3242,7 @@ static const char uhc_hangul_from_ucs[11172][2] =
 	  }								      \
 	if (__builtin_expect (written, 0) == __UNKNOWN_10646_CHAR)	      \
 	  {								      \
-	    if (step_data->__trans.__trans_fct != NULL)			      \
-	      {								      \
-		result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				      (step, step_data, *inptrp, &inptr,      \
-				       inend, &outptr, irreversible));	      \
-		if (result != __GCONV_OK)				      \
-		  break;						      \
-	      }								      \
-	    else if (! ignore_errors_p ())				      \
-	      {								      \
-	        /* This is an illegal character.  */			      \
-		result = __GCONV_ILLEGAL_INPUT;				      \
-		break;							      \
-	      }								      \
-	    else							      \
-	      {								      \
-		inptr += 4;						      \
-		++*irreversible;					      \
-	      }								      \
-	    continue;							      \
+	    STANDARD_ERR_HANDLER (4);					      \
 	  }								      \
 									      \
 	*outptr++ |= 0x80;						      \
diff --git a/iconvdata/unicode.c b/iconvdata/unicode.c
index 9caa95df0f..d927cdf667 100644
--- a/iconvdata/unicode.c
+++ b/iconvdata/unicode.c
@@ -152,26 +152,7 @@ gconv_end (struct __gconv_step *data)
 									      \
     if (__builtin_expect (c, 0) >= 0x10000)				      \
       {									      \
-	if (step_data->__trans.__trans_fct != NULL)			      \
-	  {								      \
-	    result = DL_CALL_FCT (step_data->__trans.__trans_fct,	      \
-				  (step, step_data, *inptrp, &inptr, inend,   \
-				   &outptr, irreversible));		      \
-	    if (result != __GCONV_OK)					      \
-	      break;							      \
-	  }								      \
-	else if (! ignore_errors_p ())					      \
-	  {								      \
-	    /* This is an illegal character.  */			      \
-	    result = __GCONV_ILLEGAL_INPUT;				      \
-	    break;							      \
-	  }								      \
-	else								      \
-	  {								      \
-	    ++*irreversible;						      \
-	    inptr += 4;							      \
-	  }								      \
-	continue;							      \
+	STANDARD_ERR_HANDLER (4);					      \
       }									      \
     else								      \
       {									      \
diff --git a/iconvdata/utf-16.c b/iconvdata/utf-16.c
index fd7bba72bf..4b7fefaf28 100644
--- a/iconvdata/utf-16.c
+++ b/iconvdata/utf-16.c
@@ -202,26 +202,7 @@ gconv_end (struct __gconv_step *data)
 	  {								      \
 	    if (__builtin_expect (c, 0) >= 0x110000)			      \
 	      {								      \
-		if (step_data->__trans.__trans_fct != NULL)		      \
-		  {							      \
-		    result = DL_CALL_FCT (step_data->__trans.__trans_fct,     \
-					  (step, step_data, *inptrp, &inptr,  \
-					   inend, &outptr, irreversible));    \
-		    if (result != __GCONV_OK)				      \
-		      break;						      \
-		  }							      \
-		else if (! ignore_errors_p ())				      \
-		  {							      \
-		    /* This is an illegal character.  */		      \
-		    result = __GCONV_ILLEGAL_INPUT;			      \
-		    break;						      \
-		  }							      \
-		else							      \
-		  {							      \
-		    ++*irreversible;					      \
-		    inptr += 4;						      \
-		  }							      \
-		continue;						      \
+		STANDARD_ERR_HANDLER (4);				      \
 	      }								      \
 									      \
 	    /* Generate a surrogate character.  */			      \
@@ -245,26 +226,7 @@ gconv_end (struct __gconv_step *data)
 	  {								      \
 	    if (__builtin_expect (c, 0) >= 0x110000)			      \
 	      {								      \
-		if (step_data->__trans.__trans_fct != NULL)		      \
-		  {							      \
-		    result = DL_CALL_FCT (step_data->__trans.__trans_fct,     \
-					  (step, step_data, *inptrp, &inptr,  \
-					   inend, &outptr, irreversible));    \
-		    if (result != __GCONV_OK)				      \
-		      break;						      \
-		  }							      \
-		else if (! ignore_errors_p ())				      \
-		  {							      \
-		    /* This is an illegal character.  */		      \
-		    result = __GCONV_ILLEGAL_INPUT;			      \
-		    break;						      \
-		  }							      \
-		else							      \
-		  {							      \
-		    ++*irreversible;					      \
-		    inptr += 4;						      \
-		  }							      \
-		continue;						      \
+		STANDARD_ERR_HANDLER (4);				      \
 	      }								      \
 									      \
 	    /* Generate a surrogate character.  */			      \