From: Bruno Haible Date: Fri, 10 Jan 2003 19:25:39 +0000 (+0000) Subject: Work around Solaris 2.9 iconv() bug: iconv eats a byte without producing any X-Git-Tag: v0.12~1183 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=667cfd2f40296f9bdeb8d214a5a2140ca1315bb5;p=thirdparty%2Fgettext.git Work around Solaris 2.9 iconv() bug: iconv eats a byte without producing any output. --- diff --git a/lib/ChangeLog b/lib/ChangeLog index 931782918..940df1a6e 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,8 @@ +2003-01-10 Bruno Haible + + * linebreak.c (mbs_possible_linebreaks, mbs_width_linebreaks): + Work around Solaris 2.9 iconv() bug. + 2003-01-08 Bruno Haible * safe-read.h: Update from current gnulib version. diff --git a/lib/linebreak.c b/lib/linebreak.c index 200272e88..42d0ea10b 100644 --- a/lib/linebreak.c +++ b/lib/linebreak.c @@ -1,5 +1,5 @@ /* linebreak.c - line breaking of Unicode strings - Copyright (C) 2001-2002 Free Software Foundation, Inc. + Copyright (C) 2001-2003 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software; you can redistribute it and/or modify @@ -1392,7 +1392,7 @@ iconv_string_length (iconv_t cd, const char *s, size_t n) return (size_t)(-1); count += outptr - tmpbuf; } - /* Avoid glibc-2.1 bug and Solaris 2.7 bug. */ + /* Avoid glibc-2.1 bug and Solaris 2.7-2.9 bug. */ #if defined _LIBICONV_VERSION \ || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun) { @@ -1501,6 +1501,18 @@ mbs_possible_linebreaks (const char *s, size_t n, const char *encoding, if (STREQ (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)) to_utf8 = (iconv_t)(-1); else +# endif + /* Avoid Solaris 2.9 bug with GB2312, EUC-TW, BIG5, BIG5-HKSCS, GBK, + GB18030. */ +# if defined __sun && !defined _LIBICONV_VERSION + if ( STREQ (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0) + || STREQ (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0) + || STREQ (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0) + || STREQ (encoding, "BIG5-HKSCS", 'B', 'I', 'G', '5', '-', 'H', 'K', 'S', 'C') + || STREQ (encoding, "GBK", 'G', 'B', 'K', 0, 0, 0, 0, 0, 0) + || STREQ (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0)) + to_utf8 = (iconv_t)(-1); + else # endif to_utf8 = iconv_open (UTF8_NAME, encoding); if (to_utf8 != (iconv_t)(-1)) @@ -1582,6 +1594,18 @@ mbs_width_linebreaks (const char *s, size_t n, if (STREQ (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)) to_utf8 = (iconv_t)(-1); else +# endif + /* Avoid Solaris 2.9 bug with GB2312, EUC-TW, BIG5, BIG5-HKSCS, GBK, + GB18030. */ +# if defined __sun && !defined _LIBICONV_VERSION + if ( STREQ (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0) + || STREQ (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0) + || STREQ (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0) + || STREQ (encoding, "BIG5-HKSCS", 'B', 'I', 'G', '5', '-', 'H', 'K', 'S', 'C') + || STREQ (encoding, "GBK", 'G', 'B', 'K', 0, 0, 0, 0, 0, 0) + || STREQ (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0)) + to_utf8 = (iconv_t)(-1); + else # endif to_utf8 = iconv_open (UTF8_NAME, encoding); if (to_utf8 != (iconv_t)(-1)) diff --git a/src/ChangeLog b/src/ChangeLog index 07cce3d16..7f0c0750d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2003-01-10 Bruno Haible + + * po-charset.c (po_lex_charset_set): Work around Solaris 2.9 iconv() + bug. + * write-po.c (wrap): Likewise. + 2003-01-08 Bruno Haible * project-id: Make it work with configure files that use diff --git a/src/po-charset.c b/src/po-charset.c index 79cfbeea7..e43772009 100644 --- a/src/po-charset.c +++ b/src/po-charset.c @@ -1,5 +1,5 @@ /* Charset handling while reading PO files. - Copyright (C) 2001-2002 Free Software Foundation, Inc. + Copyright (C) 2001-2003 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software; you can redistribute it and/or modify @@ -262,6 +262,18 @@ Message conversion to user's charset might not work.\n"), if (strcmp (po_lex_charset, "EUC-KR") == 0) po_lex_iconv = (iconv_t)(-1); else +# endif + /* Avoid Solaris 2.9 bug with GB2312, EUC-TW, BIG5, BIG5-HKSCS, + GBK, GB18030. */ +# if defined __sun && !defined _LIBICONV_VERSION + if ( strcmp (po_lex_charset, "GB2312") == 0 + || strcmp (po_lex_charset, "EUC-TW") == 0 + || strcmp (po_lex_charset, "BIG5") == 0 + || strcmp (po_lex_charset, "BIG5-HKSCS") == 0 + || strcmp (po_lex_charset, "GBK") == 0 + || strcmp (po_lex_charset, "GB18030") == 0) + po_lex_iconv = (iconv_t)(-1); + else # endif po_lex_iconv = iconv_open ("UTF-8", po_lex_charset); if (po_lex_iconv == (iconv_t)(-1)) diff --git a/src/write-po.c b/src/write-po.c index 5424661ae..5208f3bef 100644 --- a/src/write-po.c +++ b/src/write-po.c @@ -1,5 +1,5 @@ /* GNU gettext - internationalization aids - Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc. + Copyright (C) 1995-1998, 2000-2003 Free Software Foundation, Inc. This file was written by Peter Miller @@ -238,6 +238,18 @@ wrap (FILE *fp, const char *line_prefix, const char *name, const char *value, if (strcmp (canon_charset, "EUC-KR") == 0) conv = (iconv_t)(-1); else +# endif + /* Avoid Solaris 2.9 bug with GB2312, EUC-TW, BIG5, BIG5-HKSCS, GBK, + GB18030. */ +# if defined __sun && !defined _LIBICONV_VERSION + if ( strcmp (po_lex_charset, "GB2312") == 0 + || strcmp (po_lex_charset, "EUC-TW") == 0 + || strcmp (po_lex_charset, "BIG5") == 0 + || strcmp (po_lex_charset, "BIG5-HKSCS") == 0 + || strcmp (po_lex_charset, "GBK") == 0 + || strcmp (po_lex_charset, "GB18030") == 0) + conv = (iconv_t)(-1); + else # endif /* Use iconv() to parse multibyte characters. */ conv = iconv_open ("UTF-8", canon_charset);