diff options
author | Jim Meyering <jim@meyering.net> | 2000-04-07 09:41:38 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2000-04-07 09:41:38 +0000 |
commit | 6b0a7a91d40c19bfa70e2edafe88bf927079266a (patch) | |
tree | 1ede835f140ca9d06cd87df7e9f3c14b3e953cce /lib/unicodeio.c | |
parent | 4259b70042ac4f74fb961f90289ce211baf2a109 (diff) | |
download | coreutils-6b0a7a91d40c19bfa70e2edafe88bf927079266a.tar.xz |
(print_unicode_char): Avoid triggering Solaris iconv bug.
Deal with the different error behaviour of Irix iconv.
Diffstat (limited to 'lib/unicodeio.c')
-rw-r--r-- | lib/unicodeio.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/unicodeio.c b/lib/unicodeio.c index 9948a4eb5..a846bb09e 100644 --- a/lib/unicodeio.c +++ b/lib/unicodeio.c @@ -171,12 +171,18 @@ print_unicode_char (FILE *stream, unsigned int code) /* Convert the character from UTF-8 to the locale's charset. */ res = iconv (utf8_to_local, &inptr, &inbytesleft, &outptr, &outbytesleft); - if (inbytesleft > 0 || res == (size_t)(-1)) + if (inbytesleft > 0 || res == (size_t)(-1) + /* Irix iconv() inserts a NUL byte if it cannot convert. */ +# if !defined _LIBICONV_VERSION && (defined sgi || defined __sgi) + || (res > 0 && code != 0 && outptr - outbuf == 1 && *outbuf == '\0') +# endif + ) error (1, res == (size_t)(-1) ? errno : 0, _("cannot convert U+%04X to local character set"), code); - /* Avoid glibc-2.1 bug. */ -# if defined _LIBICONV_VERSION || !(__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) + /* Avoid glibc-2.1 bug and Solaris 2.7 bug. */ +# if defined _LIBICONV_VERSION \ + || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun) /* Get back to the initial shift state. */ res = iconv (utf8_to_local, NULL, NULL, &outptr, &outbytesleft); |