about summary refs log tree commit diff
path: root/iconv
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-09-24 04:19:03 +0000
committerUlrich Drepper <drepper@redhat.com>2002-09-24 04:19:03 +0000
commitfa00744e514a99087f5fe70cac9334b29a04c93a (patch)
treeafb188699c7ba3d139c0c1e5962a749bec6480b7 /iconv
parentf2a444335f8deabb58145db315b33a87e4f576da (diff)
downloadglibc-fa00744e514a99087f5fe70cac9334b29a04c93a.tar.gz
glibc-fa00744e514a99087f5fe70cac9334b29a04c93a.tar.xz
glibc-fa00744e514a99087f5fe70cac9334b29a04c93a.zip
Update.
	* iconv/iconv_prog.c (main): Provide an error message that identifies
	the wrong encoding.

2002-09-22  Bruno Haible  <bruno@clisp.org>

	* iconvdata/tscii.c: New file.
	* iconvdata/testdata/TSCII: New file.
	* iconvdata/testdata/TSCII..UTF8: New file.
	* iconvdata/TSCII.precomposed: New file.
	* iconvdata/TSCII.irreversible: New file.
	* iconvdata/gconv-modules (TSCII): New module.
	* iconvdata/Makefile (modules): Add TSCII.
	(distribute): Add tscii.c.
	* iconvdata/tst-table-from.c (try, utf8_decode, main): Double output
	buffer size.
	* iconvdata/tst-tables.sh: Add TSCII.
	* iconvdata/TESTS: Add TSCII.

2002-09-22  Bruno Haible  <bruno@clisp.org>

	Revert 2002-04-18 patch.
	* iconvdata/euc-jisx0213.c (EMIT_SHIFT_TO_INIT, BODY for
	FROM_DIRECTION): Make the FROM direction stateful again.
	* iconvdata/shift_jisx0213.c (EMIT_SHIFT_TO_INIT, BODY for
	FROM_DIRECTION): Likewise.

2002-09-22  Bruno Haible  <bruno@clisp.org>
Diffstat (limited to 'iconv')
-rw-r--r--iconv/iconv_prog.c46
1 files changed, 42 insertions, 4 deletions
diff --git a/iconv/iconv_prog.c b/iconv/iconv_prog.c
index a67c6ebad1..dd1b9689b6 100644
--- a/iconv/iconv_prog.c
+++ b/iconv/iconv_prog.c
@@ -28,6 +28,7 @@
 #include <langinfo.h>
 #include <locale.h>
 #include <search.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -216,10 +217,47 @@ main (int argc, char *argv[])
       if (cd == (iconv_t) -1)
 	{
 	  if (errno == EINVAL)
-	    error (EXIT_FAILURE, 0,
-		   _("conversion from `%s' to `%s' not supported"),
-		   from_code[0] ? from_code : nl_langinfo (CODESET),
-		   orig_to_code[0] ? orig_to_code : nl_langinfo (CODESET));
+	    {
+	      /* Try to be nice with the user and tell her which of the
+		 two encoding names is wrong.  This is possible because
+		 all supported encodings can be converted from/to Unicode,
+		 in other words, because the graph of encodings is
+		 connected.  */
+	      bool from_wrong =
+		(iconv_open ("UTF-8", from_code) == (iconv_t) -1
+		 && errno == EINVAL);
+	      bool to_wrong =
+		(iconv_open (to_code, "UTF-8") == (iconv_t) -1
+		 && errno == EINVAL);
+	      const char *from_pretty =
+		(from_code[0] ? from_code : nl_langinfo (CODESET));
+	      const char *to_pretty =
+		(orig_to_code[0] ? orig_to_code : nl_langinfo (CODESET));
+
+	      if (from_wrong)
+		{
+		  if (to_wrong)
+		    error (EXIT_FAILURE, 0,
+			   _("\
+conversions from `%s' and to `%s' are not supported"),
+			   from_pretty, to_pretty);
+		  else
+		    error (EXIT_FAILURE, 0,
+			   _("conversion from `%s' is not supported"),
+			   from_pretty);
+		}
+	      else
+		{
+		  if (to_wrong)
+		    error (EXIT_FAILURE, 0,
+			   _("conversion to `%s' is not supported"),
+			   to_pretty);
+		  else
+		    error (EXIT_FAILURE, 0,
+			   _("conversion from `%s' to `%s' is not supported"),
+			   from_pretty, to_pretty);
+		}
+	    }
 	  else
 	    error (EXIT_FAILURE, errno,
 		   _("failed to start conversion processing"));