From 04af1c4cda5f02dee8f95b6befd46e6fd89726bb Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 9 Sep 2024 16:10:31 +0200 Subject: [PATCH] Drop workarounds for glibc 2.1 and Solaris 9. * gettext-tools/src/read-po-lex.c (po_lex_charset_set): Remove glibc 2.1 and Solaris 9 workarounds. * gettext-tools/src/recode-sr-latin.c (process): Likewise. * gettext-tools/src/write-po.c (wrap): Likewise. * gettext-tools/src/x-python.c (set_current_file_source_encoding): Likewise. * gettext-tools/src/xgettext.c (main): Likewise. * libtextstyle/gnulib-local/lib/iconv-ostream.oo.c (iconv_ostream::free, iconv_ostream_create): Likewise. --- gettext-tools/src/read-po-lex.c | 19 ------------------- gettext-tools/src/recode-sr-latin.c | 13 +++---------- gettext-tools/src/write-po.c | 19 ------------------- gettext-tools/src/x-python.c | 11 ++--------- gettext-tools/src/xgettext.c | 11 ++--------- .../gnulib-local/lib/iconv-ostream.oo.c | 17 +---------------- 6 files changed, 8 insertions(+), 82 deletions(-) diff --git a/gettext-tools/src/read-po-lex.c b/gettext-tools/src/read-po-lex.c index 5ca52f00d..b1ed37923 100644 --- a/gettext-tools/src/read-po-lex.c +++ b/gettext-tools/src/read-po-lex.c @@ -227,25 +227,6 @@ Message conversion to user's charset might not work.\n"), { /* Use iconv() to parse multibyte characters. */ #if HAVE_ICONV - /* Avoid glibc-2.1 bug with EUC-KR. */ -# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \ - && !defined _LIBICONV_VERSION - if (strcmp (ps->po_lex_charset, "EUC-KR") == 0) - ps->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 (ps->po_lex_charset, "GB2312") == 0 - || strcmp (ps->po_lex_charset, "EUC-TW") == 0 - || strcmp (ps->po_lex_charset, "BIG5") == 0 - || strcmp (ps->po_lex_charset, "BIG5-HKSCS") == 0 - || strcmp (ps->po_lex_charset, "GBK") == 0 - || strcmp (ps->po_lex_charset, "GB18030") == 0) - ps->po_lex_iconv = (iconv_t)(-1); - else -# endif ps->po_lex_iconv = iconv_open ("UTF-8", ps->po_lex_charset); if (ps->po_lex_iconv == (iconv_t)(-1)) { diff --git a/gettext-tools/src/recode-sr-latin.c b/gettext-tools/src/recode-sr-latin.c index d5989319f..6a9971ffa 100644 --- a/gettext-tools/src/recode-sr-latin.c +++ b/gettext-tools/src/recode-sr-latin.c @@ -275,16 +275,9 @@ process (FILE *stream) if (need_code_conversion) { #if HAVE_ICONV - /* Avoid glibc-2.1 bug with EUC-KR. */ -# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \ - && !defined _LIBICONV_VERSION - if (strcmp (locale_code, "EUC-KR") != 0) -# endif - { - conv_to_utf8 = iconv_open ("UTF-8", locale_code); - /* TODO: Maybe append //TRANSLIT here? */ - conv_from_utf8 = iconv_open (locale_code, "UTF-8"); - } + conv_to_utf8 = iconv_open ("UTF-8", locale_code); + /* TODO: Maybe append //TRANSLIT here? */ + conv_from_utf8 = iconv_open (locale_code, "UTF-8"); if (conv_to_utf8 == (iconv_t)(-1)) error (EXIT_FAILURE, 0, _("Cannot convert from \"%s\" to \"%s\". %s relies on iconv(), and iconv() does not support this conversion."), diff --git a/gettext-tools/src/write-po.c b/gettext-tools/src/write-po.c index eeb190a0e..c50fff73e 100644 --- a/gettext-tools/src/write-po.c +++ b/gettext-tools/src/write-po.c @@ -685,25 +685,6 @@ wrap (const message_ty *mp, ostream_t stream, /* Invalid PO file encoding. */ conv = (iconv_t)(-1); else - /* Avoid glibc-2.1 bug with EUC-KR. */ -# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \ - && !defined _LIBICONV_VERSION - 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 (canon_charset, "GB2312") == 0 - || strcmp (canon_charset, "EUC-TW") == 0 - || strcmp (canon_charset, "BIG5") == 0 - || strcmp (canon_charset, "BIG5-HKSCS") == 0 - || strcmp (canon_charset, "GBK") == 0 - || strcmp (canon_charset, "GB18030") == 0) - conv = (iconv_t)(-1); - else -# endif /* Use iconv() to parse multibyte characters. */ conv = iconv_open ("UTF-8", canon_charset); diff --git a/gettext-tools/src/x-python.c b/gettext-tools/src/x-python.c index 42bfd9d2d..0c85c3799 100644 --- a/gettext-tools/src/x-python.c +++ b/gettext-tools/src/x-python.c @@ -618,16 +618,9 @@ set_current_file_source_encoding (const char *canon_encoding) && xgettext_current_file_source_encoding != po_charset_utf8) { #if HAVE_ICONV - iconv_t cd; + iconv_t cd = + iconv_open (po_charset_utf8, xgettext_current_file_source_encoding); - /* Avoid glibc-2.1 bug with EUC-KR. */ -# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \ - && !defined _LIBICONV_VERSION - if (strcmp (xgettext_current_file_source_encoding, "EUC-KR") == 0) - cd = (iconv_t)(-1); - else -# endif - cd = iconv_open (po_charset_utf8, xgettext_current_file_source_encoding); if (cd == (iconv_t)(-1)) error_at_line (EXIT_FAILURE, 0, logical_file_name, line_number - 1, _("Cannot convert from \"%s\" to \"%s\". %s relies on iconv(), and iconv() does not support this conversion."), diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c index a9c2f04dd..928a3d752 100644 --- a/gettext-tools/src/xgettext.c +++ b/gettext-tools/src/xgettext.c @@ -808,16 +808,9 @@ xgettext cannot work without keywords to look for")); && xgettext_global_source_encoding != po_charset_utf8) { #if HAVE_ICONV - iconv_t cd; + iconv_t cd = + iconv_open (po_charset_utf8, xgettext_global_source_encoding); - /* Avoid glibc-2.1 bug with EUC-KR. */ -# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \ - && !defined _LIBICONV_VERSION - if (strcmp (xgettext_global_source_encoding, "EUC-KR") == 0) - cd = (iconv_t)(-1); - else -# endif - cd = iconv_open (po_charset_utf8, xgettext_global_source_encoding); if (cd == (iconv_t)(-1)) error (EXIT_FAILURE, 0, _("Cannot convert from \"%s\" to \"%s\". %s relies on iconv(), and iconv() does not support this conversion."), diff --git a/libtextstyle/gnulib-local/lib/iconv-ostream.oo.c b/libtextstyle/gnulib-local/lib/iconv-ostream.oo.c index 9c6e02a9f..60cb17437 100644 --- a/libtextstyle/gnulib-local/lib/iconv-ostream.oo.c +++ b/libtextstyle/gnulib-local/lib/iconv-ostream.oo.c @@ -155,11 +155,6 @@ iconv_ostream::free (iconv_ostream_t stream) /* Silently ignore the few bytes in stream->buf[] that don't correspond to a character. */ - /* Avoid glibc-2.1 bug and Solaris 2.7 bug. */ - #if defined _LIBICONV_VERSION \ - || !(((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) \ - && !defined __UCLIBC__) \ - || defined __sun) { char outbuffer[2048]; char *outptr = outbuffer; @@ -173,7 +168,6 @@ iconv_ostream::free (iconv_ostream_t stream) ostream_write_mem (stream->destination, outbuffer, sizeof (outbuffer) - outsize); } - #endif iconv_close (stream->cd); free (stream->from_encoding); @@ -194,16 +188,7 @@ iconv_ostream_create (const char *from_encoding, const char *to_encoding, stream->from_encoding = xstrdup (from_encoding); stream->to_encoding = xstrdup (to_encoding); - /* Avoid glibc-2.1 bug with EUC-KR. */ - #if ((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) \ - && !defined __UCLIBC__) \ - && !defined _LIBICONV_VERSION - if (c_strcasecmp (from_encoding, "EUC-KR") == 0 - || c_strcasecmp (to_encoding, "EUC-KR") == 0) - stream->cd = (iconv_t)(-1): - else - #endif - stream->cd = iconv_open (to_encoding, from_encoding); + stream->cd = iconv_open (to_encoding, from_encoding); if (stream->cd == (iconv_t)(-1)) { if (iconv_open ("UTF-8", from_encoding) == (iconv_t)(-1)) -- 2.47.3