X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Funicodeio.c;h=13888529258acbdaf60e30cbdec5b3c76c6a85c7;hb=023946e6df1ce4ce382f2385306427413fe46085;hp=148d64ea60a34bc36f53fc9aec3403ef64cbcfef;hpb=269accf808a245264aa79c30adbdee7dfa952451;p=gnulib.git diff --git a/lib/unicodeio.c b/lib/unicodeio.c index 148d64ea6..138885292 100644 --- a/lib/unicodeio.c +++ b/lib/unicodeio.c @@ -28,7 +28,11 @@ #endif #include -#include +#if HAVE_STRING_H +# include +#else +# include +#endif #include #ifndef errno @@ -117,7 +121,7 @@ print_unicode_char (FILE *stream, unsigned int code) if (!initialized) { - extern const char *locale_charset (void); + extern const char *locale_charset PARAMS ((void)); const char *charset = locale_charset (); is_utf8 = (charset != NULL && !strcmp (charset, UTF8_NAME)); @@ -167,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);