diff options
author | Arjun Shankar <arjun@redhat.com> | 2020-09-25 14:47:06 +0200 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2021-08-27 17:26:08 -0700 |
commit | 453aafef166abc5f3dab268b5bf0959cec8fb92b (patch) | |
tree | eb424ce1ca8171ac6e6bf958280bd1668ddfd90c /intl/dcigettext.c | |
parent | 804887a0c8d546cb4ffc7a57f3623e37c7102ac8 (diff) | |
download | glibc-453aafef166abc5f3dab268b5bf0959cec8fb92b.zip glibc-453aafef166abc5f3dab268b5bf0959cec8fb92b.tar.gz glibc-453aafef166abc5f3dab268b5bf0959cec8fb92b.tar.bz2 |
intl: Handle translation output codesets with suffixes [BZ #26383]
Commit 91927b7c7643 (Rewrite iconv option parsing [BZ #19519]) did not
handle cases where the output codeset for translations (via the `gettext'
family of functions) might have a caller specified encoding suffix such as
TRANSLIT or IGNORE. This led to a regression where translations did not
work when the codeset had a suffix.
This commit fixes the above issue by parsing any suffixes passed to
__dcigettext and adds two new test-cases to intl/tst-codeset.c to
verify correct behaviour. The iconv-internal function __gconv_create_spec
and the static iconv-internal function gconv_destroy_spec are now visible
internally within glibc and used in intl/dcigettext.c.
Diffstat (limited to 'intl/dcigettext.c')
-rw-r--r-- | intl/dcigettext.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/intl/dcigettext.c b/intl/dcigettext.c index 975312a..b65d244 100644 --- a/intl/dcigettext.c +++ b/intl/dcigettext.c @@ -1121,15 +1121,18 @@ _nl_find_msg (struct loaded_l10nfile *domain_file, # ifdef _LIBC - struct gconv_spec conv_spec - = { .fromcode = norm_add_slashes (charset, ""), - .tocode = norm_add_slashes (outcharset, ""), - /* We always want to use transliteration. */ - .translit = true, - .ignore = false - }; + struct gconv_spec conv_spec; + + __gconv_create_spec (&conv_spec, charset, outcharset); + + /* We always want to use transliteration. */ + conv_spec.translit = true; + int r = __gconv_open (&conv_spec, &convd->conv, GCONV_AVOID_NOCONV); + + __gconv_destroy_spec (&conv_spec); + if (__builtin_expect (r != __GCONV_OK, 0)) { /* If the output encoding is the same there is |