From 6fddc78cd057b8f3e89842ccbabcf1646bb37cd9 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 23 May 2001 19:42:49 +0000 Subject: [PATCH] Avoid crash on EUC-KR PO file. --- lib/ChangeLog | 6 ++++++ lib/linebreak.c | 18 ++++++++++++++++-- src/ChangeLog | 4 ++++ src/write-po.c | 6 ++++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/lib/ChangeLog b/lib/ChangeLog index d5cfefa6e..03cb9a0cf 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,9 @@ +2001-05-23 Bruno Haible + + * linebreak.c (mbs_possible_linebreaks): Avoid broken EUC-KR + conversion in glibc-2.1. + (mbs_width_linebreaks): Likewise. + 2001-05-02 Bruno Haible * linebreak.c (iconv_string_keeping_offsets): Work around a glibc-2.1 diff --git a/lib/linebreak.c b/lib/linebreak.c index 164f730fd..e3bacae29 100644 --- a/lib/linebreak.c +++ b/lib/linebreak.c @@ -1711,7 +1711,14 @@ mbs_possible_linebreaks (s, n, encoding, p) else { #if HAVE_ICONV - iconv_t to_utf8 = iconv_open (UTF8_NAME, encoding); + iconv_t to_utf8; + /* Avoid glibc-2.1 bug with EUC-KR. */ +# if (__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) && !defined _LIBICONV_VERSION + if (STREQ (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)) + to_utf8 = (iconv_t)(-1); + else +# endif + to_utf8 = iconv_open (UTF8_NAME, encoding); if (to_utf8 != (iconv_t)(-1)) { /* Determine the length of the resulting UTF-8 string. */ @@ -1790,7 +1797,14 @@ mbs_width_linebreaks (s, n, width, start_column, at_end_columns, o, encoding, p) else { #if HAVE_ICONV - iconv_t to_utf8 = iconv_open (UTF8_NAME, encoding); + iconv_t to_utf8; + /* Avoid glibc-2.1 bug with EUC-KR. */ +# if (__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) && !defined _LIBICONV_VERSION + if (STREQ (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)) + to_utf8 = (iconv_t)(-1); + else +# endif + to_utf8 = iconv_open (UTF8_NAME, encoding); if (to_utf8 != (iconv_t)(-1)) { /* Determine the length of the resulting UTF-8 string. */ diff --git a/src/ChangeLog b/src/ChangeLog index 36abf66ec..5556d532c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2001-05-23 Bruno Haible + + * write-po.c (wrap): Avoid broken EUC-KR conversion in glibc-2.1. + 2001-05-21 Bruno Haible * xgettext.c (construct_header): Replace 8-bit with 8bit. diff --git a/src/write-po.c b/src/write-po.c index 48eeb67c4..64fecf419 100644 --- a/src/write-po.c +++ b/src/write-po.c @@ -211,6 +211,12 @@ wrap (fp, line_prefix, name, value, do_wrap, charset) /* Write a PO file in old format, with extraneous backslashes. */ conv = (iconv_t)(-1); else + /* Avoid glibc-2.1 bug with EUC-KR. */ +# if (__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) && !defined _LIBICONV_VERSION + if (strcmp (charset, "EUC-KR") == 0) + conv = (iconv_t)(-1); + else +# endif /* Use iconv() to parse multibyte characters. */ conv = iconv_open ("UTF-8", charset); #endif -- 2.47.2